idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
28,200
AtomSymbol generatePeriodicSymbol ( final int number , final int hydrogens , final int mass , final int charge , final int unpaired , HydrogenPosition position ) { TextOutline element = number == 0 ? new TextOutline ( "*" , font ) : new TextOutline ( Elements . ofNumber ( number ) . symbol ( ) , font ) ; TextOutline hydrogenAdjunct = defaultHydrogenLabel ; TextOutline hydrogenCount = new TextOutline ( Integer . toString ( hydrogens ) , font ) . resize ( scriptSize , scriptSize ) ; TextOutline chargeAdjunct = new TextOutline ( chargeAdjunctText ( charge , unpaired ) , font ) . resize ( scriptSize , scriptSize ) ; TextOutline massAdjunct = new TextOutline ( Integer . toString ( mass ) , font ) . resize ( scriptSize , scriptSize ) ; hydrogenAdjunct = positionHydrogenLabel ( position , element , hydrogenAdjunct ) ; hydrogenCount = positionSubscript ( hydrogenAdjunct , hydrogenCount ) ; chargeAdjunct = positionChargeLabel ( hydrogens , position , chargeAdjunct , element , hydrogenAdjunct ) ; massAdjunct = positionMassLabel ( massAdjunct , element ) ; if ( position == Left ) { final double nudgeX = hydrogenXDodge ( hydrogens , mass , element , hydrogenAdjunct , hydrogenCount , massAdjunct ) ; hydrogenAdjunct = hydrogenAdjunct . translate ( nudgeX , 0 ) ; hydrogenCount = hydrogenCount . translate ( nudgeX , 0 ) ; } final List < TextOutline > adjuncts = new ArrayList < TextOutline > ( 4 ) ; if ( hydrogens > 0 ) adjuncts . add ( hydrogenAdjunct ) ; if ( hydrogens > 1 ) adjuncts . add ( hydrogenCount ) ; if ( charge != 0 || unpaired > 0 ) adjuncts . add ( chargeAdjunct ) ; if ( mass > 0 ) adjuncts . add ( massAdjunct ) ; return new AtomSymbol ( element , adjuncts ) ; }
Generate an atom symbol for a periodic element with the specified number of hydrogens ionic charge mass
28,201
TextOutline positionHydrogenLabel ( HydrogenPosition position , TextOutline element , TextOutline hydrogen ) { final Rectangle2D elementBounds = element . getBounds ( ) ; final Rectangle2D hydrogenBounds = hydrogen . getBounds ( ) ; switch ( position ) { case Above : return hydrogen . translate ( 0 , ( elementBounds . getMinY ( ) - padding ) - hydrogenBounds . getMaxY ( ) ) ; case Right : return hydrogen . translate ( ( elementBounds . getMaxX ( ) + padding ) - hydrogenBounds . getMinX ( ) , 0 ) ; case Below : return hydrogen . translate ( 0 , ( elementBounds . getMaxY ( ) + padding ) - hydrogenBounds . getMinY ( ) ) ; case Left : return hydrogen . translate ( ( elementBounds . getMinX ( ) - padding ) - hydrogenBounds . getMaxX ( ) , 0 ) ; } return hydrogen ; }
Position the hydrogen label relative to the element label .
28,202
TextOutline positionSubscript ( TextOutline label , TextOutline subscript ) { final Rectangle2D hydrogenBounds = label . getBounds ( ) ; final Rectangle2D hydrogenCountBounds = subscript . getBounds ( ) ; subscript = subscript . translate ( ( hydrogenBounds . getMaxX ( ) + padding ) - hydrogenCountBounds . getMinX ( ) , ( hydrogenBounds . getMaxY ( ) + ( hydrogenCountBounds . getHeight ( ) / 2 ) ) - hydrogenCountBounds . getMaxY ( ) ) ; return subscript ; }
Positions an outline in the subscript position relative to another primary label .
28,203
TextOutline positionChargeLabel ( int hydrogens , HydrogenPosition position , TextOutline charge , TextOutline element , TextOutline hydrogen ) { final Rectangle2D chargeBounds = charge . getBounds ( ) ; Rectangle2D referenceBounds = element . getBounds ( ) ; if ( hydrogens > 0 && position == Right ) referenceBounds = hydrogen . getBounds ( ) ; else if ( hydrogens > 1 && position == Above ) referenceBounds = hydrogen . getBounds ( ) ; return charge . translate ( ( referenceBounds . getMaxX ( ) + padding ) - chargeBounds . getMinX ( ) , ( referenceBounds . getMinY ( ) - ( chargeBounds . getHeight ( ) / 2 ) ) - chargeBounds . getMinY ( ) ) ; }
Position the charge label on the top right of either the element or hydrogen label . Where the charge is placed depends on the number of hydrogens and their position relative to the element symbol .
28,204
TextOutline positionMassLabel ( TextOutline massLabel , TextOutline elementLabel ) { final Rectangle2D elementBounds = elementLabel . getBounds ( ) ; final Rectangle2D massBounds = massLabel . getBounds ( ) ; return massLabel . translate ( ( elementBounds . getMinX ( ) - padding ) - massBounds . getMaxX ( ) , ( elementBounds . getMinY ( ) - ( massBounds . getHeight ( ) / 2 ) ) - massBounds . getMinY ( ) ) ; }
Position the mass label relative to the element label . The mass adjunct is position to the top left of the element label .
28,205
private double hydrogenXDodge ( int hydrogens , int mass , TextOutline elementLabel , TextOutline hydrogenLabel , TextOutline hydrogenCount , TextOutline massLabel ) { if ( mass < 0 && hydrogens > 1 ) { return ( elementLabel . getBounds ( ) . getMinX ( ) - padding ) - hydrogenCount . getBounds ( ) . getMaxX ( ) ; } else if ( mass >= 0 ) { if ( hydrogens > 1 ) { return ( massLabel . getBounds ( ) . getMinX ( ) + padding ) - hydrogenCount . getBounds ( ) . getMaxX ( ) ; } else if ( hydrogens > 0 ) { return ( massLabel . getBounds ( ) . getMinX ( ) - padding ) - hydrogenLabel . getBounds ( ) . getMaxX ( ) ; } } return 0 ; }
If the hydrogens are position in from of the element we may need to move the hydrogen and hydrogen count labels . This code assesses the positions of the mass hydrogen and hydrogen count labels and determines the x - axis adjustment needed for the hydrogen label to dodge a collision .
28,206
private boolean isMajorIsotope ( int number , int mass ) { try { IIsotope isotope = Isotopes . getInstance ( ) . getMajorIsotope ( number ) ; return isotope != null && isotope . getMassNumber ( ) . equals ( mass ) ; } catch ( IOException e ) { return false ; } }
Utility to determine if the specified mass is the major isotope for the given atomic number .
28,207
static String chargeAdjunctText ( final int charge , final int unpaired ) { StringBuilder sb = new StringBuilder ( ) ; if ( unpaired == 1 ) { if ( charge != 0 ) { sb . append ( '(' ) . append ( BULLET ) . append ( ')' ) ; } else { sb . append ( BULLET ) ; } } else if ( unpaired > 1 ) { if ( charge != 0 ) { sb . append ( '(' ) . append ( unpaired ) . append ( BULLET ) . append ( ')' ) ; } else { sb . append ( unpaired ) . append ( BULLET ) ; } } final char sign = charge < 0 ? MINUS : PLUS ; final int coefficient = Math . abs ( charge ) ; if ( coefficient > 1 ) sb . append ( coefficient ) ; if ( coefficient > 0 ) sb . append ( sign ) ; return sb . toString ( ) ; }
Create the charge adjunct text for the specified charge and number of unpaired electrons .
28,208
static String accessPseudoLabel ( IPseudoAtom atom , String defaultLabel ) { String label = atom . getLabel ( ) ; if ( label != null && ! label . isEmpty ( ) ) return label ; return defaultLabel ; }
Safely access the label of a pseudo atom . If the label is null or empty the default label is returned .
28,209
private void add ( Cycle cycle ) { if ( cycle . length ( ) <= limit ) cycles . put ( cycle . length ( ) , cycle ) ; }
Add a newly discovered initial cycle .
28,210
public static IAtomContainer assign ( final IAtomContainer container ) { GraphUtil . EdgeToBondMap edgeToBond = GraphUtil . EdgeToBondMap . withSpaceFor ( container ) ; new NonplanarBonds ( container , GraphUtil . toAdjList ( container , edgeToBond ) , edgeToBond ) ; return container ; }
Assign non - planar up and down labels to indicate tetrahedral configuration . Currently all existing directional labels are removed before assigning new labels .
28,211
private void snapBondToPosition ( IAtom beg , IBond bond , Point2d tP ) { IAtom end = bond . getOther ( beg ) ; Point2d bP = beg . getPoint2d ( ) ; Point2d eP = end . getPoint2d ( ) ; Vector2d curr = new Vector2d ( eP . x - bP . x , eP . y - bP . y ) ; Vector2d dest = new Vector2d ( tP . x - bP . x , tP . y - bP . y ) ; double theta = Math . atan2 ( curr . y , curr . x ) - Math . atan2 ( dest . y , dest . x ) ; double sin = Math . sin ( theta ) ; double cos = Math . cos ( theta ) ; bond . setFlag ( CDKConstants . VISITED , true ) ; Deque < IAtom > queue = new ArrayDeque < > ( ) ; queue . add ( end ) ; while ( ! queue . isEmpty ( ) ) { IAtom atom = queue . poll ( ) ; if ( ! atom . getFlag ( CDKConstants . VISITED ) ) { rotate ( atom . getPoint2d ( ) , bP , cos , sin ) ; atom . setFlag ( CDKConstants . VISITED , true ) ; } for ( IBond b : container . getConnectedBondsList ( atom ) ) if ( ! b . getFlag ( CDKConstants . VISITED ) ) { queue . add ( b . getOther ( atom ) ) ; b . setFlag ( CDKConstants . VISITED , true ) ; } } }
tP = target point
28,212
private IBond findBond ( IAtom beg1 , IAtom beg2 , IAtom end ) { IBond bond = container . getBond ( beg1 , end ) ; if ( bond != null ) return bond ; return container . getBond ( beg2 , end ) ; }
Find a bond between two possible atoms . For example beg1 - end or beg2 - end .
28,213
private void setWedge ( IBond bond , IAtom end , IBond . Stereo style ) { if ( ! bond . getEnd ( ) . equals ( end ) ) bond . setAtoms ( new IAtom [ ] { bond . getEnd ( ) , bond . getBegin ( ) } ) ; bond . setStereo ( style ) ; }
Sets a wedge bond because wedges are relative we may need to flip the storage order on the bond .
28,214
private int nAdjacentCentres ( int i ) { int n = 0 ; for ( IAtom atom : tetrahedralElements [ i ] . getLigands ( ) ) if ( tetrahedralElements [ atomToIndex . get ( atom ) ] != null ) n ++ ; return n ; }
Obtain the number of centres adjacent to the atom at the index i .
28,215
private boolean isSp3Carbon ( IAtom atom , int deg ) { Integer elem = atom . getAtomicNumber ( ) ; Integer hcnt = atom . getImplicitHydrogenCount ( ) ; if ( elem == null || hcnt == null ) return false ; if ( elem == 6 && hcnt <= 1 && deg + hcnt == 4 ) { List < IAtom > terminals = new ArrayList < > ( ) ; for ( IBond bond : container . getConnectedBondsList ( atom ) ) { IAtom nbr = bond . getOther ( atom ) ; if ( container . getConnectedBondsCount ( nbr ) == 1 ) { for ( IAtom terminal : terminals ) { if ( Objects . equals ( terminal . getAtomicNumber ( ) , nbr . getAtomicNumber ( ) ) && Objects . equals ( terminal . getMassNumber ( ) , nbr . getMassNumber ( ) ) && Objects . equals ( terminal . getFormalCharge ( ) , nbr . getFormalCharge ( ) ) && Objects . equals ( terminal . getImplicitHydrogenCount ( ) , nbr . getImplicitHydrogenCount ( ) ) ) { return false ; } } terminals . add ( nbr ) ; } } return true ; } return false ; }
indicates where an atom is a Sp3 carbon and is possibly a stereo - centre
28,216
private boolean isCisTransEndPoint ( int idx ) { IAtom atom = container . getAtom ( idx ) ; if ( atom . getAtomicNumber ( ) == null || atom . getFormalCharge ( ) == null || atom . getImplicitHydrogenCount ( ) == null ) return false ; final int chg = atom . getFormalCharge ( ) ; final int btypes = getBondTypes ( idx ) ; switch ( atom . getAtomicNumber ( ) ) { case 6 : case 14 : case 32 : return chg == 0 && btypes == 0x0102 ; case 7 : if ( chg == 0 ) return btypes == 0x0101 ; if ( chg == + 1 ) return btypes == 0x0102 ; default : return false ; } }
Checks if the atom can be involved in a double - bond .
28,217
private int getBondTypes ( int idx ) { int btypes = container . getAtom ( idx ) . getImplicitHydrogenCount ( ) ; for ( int end : graph [ idx ] ) { IBond bond = edgeToBond . get ( idx , end ) ; if ( bond . getOrder ( ) == SINGLE ) btypes += 0x00_0001 ; else if ( bond . getOrder ( ) == DOUBLE ) btypes += 0x00_0100 ; else btypes += 0x01_0000 ; } return btypes ; }
Generate a bond type code for a given atom . The bond code can be quickly tested to count the number of single double or other bonds .
28,218
private List < IBond > findUnspecifiedDoubleBonds ( int [ ] [ ] adjList ) { List < IBond > unspecifiedDoubleBonds = new ArrayList < > ( ) ; for ( IBond bond : container . bonds ( ) ) { if ( bond . getOrder ( ) != DOUBLE ) continue ; final IAtom aBeg = bond . getBegin ( ) ; final IAtom aEnd = bond . getEnd ( ) ; final int beg = atomToIndex . get ( aBeg ) ; final int end = atomToIndex . get ( aEnd ) ; if ( ringSearch . cyclic ( beg , end ) ) continue ; if ( ( doubleBondElements [ beg ] != null && doubleBondElements [ beg ] . getStereoBond ( ) . equals ( bond ) ) || ( doubleBondElements [ end ] != null && doubleBondElements [ end ] . getStereoBond ( ) . equals ( bond ) ) ) continue ; if ( tetrahedralElements [ beg ] != null || tetrahedralElements [ end ] != null ) continue ; if ( ! isCisTransEndPoint ( beg ) || ! isCisTransEndPoint ( end ) ) continue ; if ( ! hasOnlyPlainBonds ( beg , bond ) || ! hasOnlyPlainBonds ( end , bond ) ) continue ; if ( hasLinearEqualPaths ( adjList , beg , end ) || hasLinearEqualPaths ( adjList , end , beg ) ) continue ; unspecifiedDoubleBonds . add ( bond ) ; } return unspecifiedDoubleBonds ; }
Locates double bonds to mark as unspecified stereochemistry .
28,219
public static boolean isValidDoubleBondConfiguration ( IAtomContainer container , IBond bond ) { List < IAtom > connectedAtoms = container . getConnectedAtomsList ( bond . getBegin ( ) ) ; IAtom from = null ; for ( IAtom connectedAtom : connectedAtoms ) { if ( ! connectedAtom . equals ( bond . getEnd ( ) ) ) { from = connectedAtom ; } } boolean [ ] array = new boolean [ container . getBondCount ( ) ] ; for ( int i = 0 ; i < array . length ; i ++ ) { array [ i ] = true ; } if ( isStartOfDoubleBond ( container , bond . getBegin ( ) , from , array ) && isEndOfDoubleBond ( container , bond . getEnd ( ) , bond . getBegin ( ) , array ) && ! bond . getFlag ( CDKConstants . ISAROMATIC ) ) { return ( true ) ; } else { return ( false ) ; } }
Tells if a certain bond is center of a valid double bond configuration .
28,220
public static boolean isLeft ( IAtom whereIs , IAtom viewFrom , IAtom viewTo ) { double angle = giveAngleBothMethods ( viewFrom , viewTo , whereIs , false ) ; if ( angle < 0 ) { return ( false ) ; } else { return ( true ) ; } }
Says if an atom is on the left side of a another atom seen from a certain atom or not .
28,221
public static boolean closeEnoughToBond ( IAtom atom1 , IAtom atom2 , double distanceFudgeFactor ) { if ( ! atom1 . equals ( atom2 ) ) { double distanceBetweenAtoms = atom1 . getPoint3d ( ) . distance ( atom2 . getPoint3d ( ) ) ; double bondingDistance = atom1 . getCovalentRadius ( ) + atom2 . getCovalentRadius ( ) ; if ( distanceBetweenAtoms <= ( distanceFudgeFactor * bondingDistance ) ) { return true ; } } return false ; }
Returns true if the two atoms are within the distance fudge factor of each other .
28,222
public static double giveAngleBothMethods ( IAtom from , IAtom to1 , IAtom to2 , boolean bool ) { return giveAngleBothMethods ( from . getPoint2d ( ) , to1 . getPoint2d ( ) , to2 . getPoint2d ( ) , bool ) ; }
Gives the angle between two lines starting at atom from and going to to1 and to2 . If bool = false the angle starts from the middle line and goes from 0 to PI or 0 to - PI if the to2 is on the left or right side of the line . If bool = true the angle goes from 0 to 2PI .
28,223
private static boolean isEndOfDoubleBond ( IAtomContainer container , IAtom atom , IAtom parent , boolean [ ] doubleBondConfiguration ) { if ( container . indexOf ( container . getBond ( atom , parent ) ) == - 1 || doubleBondConfiguration . length <= container . indexOf ( container . getBond ( atom , parent ) ) || ! doubleBondConfiguration [ container . indexOf ( container . getBond ( atom , parent ) ) ] ) { return false ; } int hcount ; if ( atom . getImplicitHydrogenCount ( ) == CDKConstants . UNSET ) hcount = 0 ; else hcount = atom . getImplicitHydrogenCount ( ) ; int lengthAtom = container . getConnectedAtomsList ( atom ) . size ( ) + hcount ; if ( parent . getImplicitHydrogenCount ( ) == CDKConstants . UNSET ) hcount = 0 ; else hcount = parent . getImplicitHydrogenCount ( ) ; int lengthParent = container . getConnectedAtomsList ( parent ) . size ( ) + hcount ; if ( container . getBond ( atom , parent ) != null ) { if ( container . getBond ( atom , parent ) . getOrder ( ) == Order . DOUBLE && ( lengthAtom == 3 || ( lengthAtom == 2 && atom . getSymbol ( ) . equals ( "N" ) ) ) && ( lengthParent == 3 || ( lengthParent == 2 && parent . getSymbol ( ) . equals ( "N" ) ) ) ) { List < IAtom > atoms = container . getConnectedAtomsList ( atom ) ; IAtom one = null ; IAtom two = null ; for ( IAtom conAtom : atoms ) { if ( ! conAtom . equals ( parent ) && one == null ) { one = conAtom ; } else if ( ! conAtom . equals ( parent ) && one != null ) { two = conAtom ; } } String [ ] morgannumbers = MorganNumbersTools . getMorganNumbersWithElementSymbol ( container ) ; if ( ( one != null && two == null && atom . getSymbol ( ) . equals ( "N" ) && Math . abs ( giveAngleBothMethods ( parent , atom , one , true ) ) > Math . PI / 10 ) || ( ! atom . getSymbol ( ) . equals ( "N" ) && one != null && two != null && ! morgannumbers [ container . indexOf ( one ) ] . equals ( morgannumbers [ container . indexOf ( two ) ] ) ) ) { return ( true ) ; } else { return ( false ) ; } } } return ( false ) ; }
Says if an atom is the end of a double bond configuration
28,224
private static boolean isStartOfDoubleBond ( IAtomContainer container , IAtom a , IAtom parent , boolean [ ] doubleBondConfiguration ) { int hcount ; if ( a . getImplicitHydrogenCount ( ) == CDKConstants . UNSET ) hcount = 0 ; else hcount = a . getImplicitHydrogenCount ( ) ; int lengthAtom = container . getConnectedAtomsList ( a ) . size ( ) + hcount ; if ( lengthAtom != 3 && ( lengthAtom != 2 && ! ( a . getSymbol ( ) . equals ( "N" ) ) ) ) { return ( false ) ; } List < IAtom > atoms = container . getConnectedAtomsList ( a ) ; IAtom one = null ; IAtom two = null ; boolean doubleBond = false ; IAtom nextAtom = null ; for ( IAtom atom : atoms ) { if ( ! atom . equals ( parent ) && container . getBond ( atom , a ) . getOrder ( ) == Order . DOUBLE && isEndOfDoubleBond ( container , atom , a , doubleBondConfiguration ) ) { doubleBond = true ; nextAtom = atom ; } if ( ! atom . equals ( nextAtom ) && one == null ) { one = atom ; } else if ( ! atom . equals ( nextAtom ) && one != null ) { two = atom ; } } String [ ] morgannumbers = MorganNumbersTools . getMorganNumbersWithElementSymbol ( container ) ; if ( one != null && ( ( ! a . getSymbol ( ) . equals ( "N" ) && two != null && ! morgannumbers [ container . indexOf ( one ) ] . equals ( morgannumbers [ container . indexOf ( two ) ] ) && doubleBond && doubleBondConfiguration [ container . indexOf ( container . getBond ( a , nextAtom ) ) ] ) || ( doubleBond && a . getSymbol ( ) . equals ( "N" ) && Math . abs ( giveAngleBothMethods ( nextAtom , a , parent , true ) ) > Math . PI / 10 ) ) ) { return ( true ) ; } else { return ( false ) ; } }
Says if an atom is the start of a double bond configuration
28,225
public static int isTetrahedral ( IAtomContainer container , IAtom atom , boolean strict ) { List < IAtom > atoms = container . getConnectedAtomsList ( atom ) ; if ( atoms . size ( ) != 4 ) { return ( 0 ) ; } List < IBond > bonds = container . getConnectedBondsList ( atom ) ; int up = 0 ; int down = 0 ; for ( IBond bond : bonds ) { if ( bond . getStereo ( ) == IBond . Stereo . NONE || bond . getStereo ( ) == CDKConstants . UNSET ) { } else if ( bond . getStereo ( ) == IBond . Stereo . UP ) { up ++ ; } else if ( bond . getStereo ( ) == IBond . Stereo . DOWN ) { down ++ ; } } if ( up == 1 && down == 1 ) { return 1 ; } if ( up == 2 && down == 2 ) { if ( stereosAreOpposite ( container , atom ) ) { return 2 ; } return 0 ; } if ( up == 1 && down == 0 && ! strict ) { return 3 ; } if ( down == 1 && up == 0 && ! strict ) { return 4 ; } if ( down == 2 && up == 1 && ! strict ) { return 5 ; } if ( down == 1 && up == 2 && ! strict ) { return 6 ; } return 0 ; }
Says if an atom as a center of a tetrahedral chirality . This method uses wedge bonds . 3D coordinates are not taken into account . If there are no wedge bonds around a potential stereo center it will not be found .
28,226
public static boolean stereosAreOpposite ( IAtomContainer container , IAtom atom ) { List < IAtom > atoms = container . getConnectedAtomsList ( atom ) ; TreeMap < Double , Integer > hm = new TreeMap < Double , Integer > ( ) ; for ( int i = 1 ; i < atoms . size ( ) ; i ++ ) { hm . put ( giveAngle ( atom , atoms . get ( 0 ) , atoms . get ( i ) ) , i ) ; } Object [ ] ohere = hm . values ( ) . toArray ( ) ; IBond . Stereo stereoOne = container . getBond ( atom , atoms . get ( 0 ) ) . getStereo ( ) ; IBond . Stereo stereoOpposite = container . getBond ( atom , atoms . get ( ( Integer ) ohere [ 1 ] ) ) . getStereo ( ) ; return stereoOpposite == stereoOne ; }
Says if of four atoms connected two one atom the up and down bonds are opposite or not i . e . if it s tetrehedral or square planar . The method does not check if there are four atoms and if two or up and two are down
28,227
public static double giveAngle ( IAtom from , IAtom to1 , IAtom to2 ) { return ( giveAngleBothMethods ( from , to1 , to2 , true ) ) ; }
Calls giveAngleBothMethods with bool = true .
28,228
public static double giveAngleFromMiddle ( IAtom from , IAtom to1 , IAtom to2 ) { return ( giveAngleBothMethods ( from , to1 , to2 , false ) ) ; }
Calls giveAngleBothMethods with bool = false .
28,229
public INode getNode ( IAtom atom ) { for ( Map . Entry < INode , IAtom > v : nodeBondMap . entrySet ( ) ) { if ( v . getValue ( ) . equals ( atom ) ) { return v . getKey ( ) ; } } return null ; }
Return a node for a given atom else return null
28,230
public INode addNode ( VFAtomMatcher matcher , IAtom atom ) { NodeBuilder node = new NodeBuilder ( matcher ) ; nodesList . add ( node ) ; nodeBondMap . put ( node , atom ) ; return node ; }
Add and return a node for a query atom
28,231
public IEdge connect ( INode source , INode target , VFBondMatcher matcher ) { NodeBuilder sourceImpl = ( NodeBuilder ) source ; NodeBuilder targetImpl = ( NodeBuilder ) target ; EdgeBuilder edge = new EdgeBuilder ( sourceImpl , targetImpl , matcher ) ; sourceImpl . addNeighbor ( targetImpl ) ; targetImpl . addNeighbor ( sourceImpl ) ; sourceImpl . addEdge ( edge ) ; targetImpl . addEdge ( edge ) ; edgesList . add ( edge ) ; return edge ; }
Construct and return an edge for a given query and target node
28,232
private IAtomContainer getMoleculeFromID ( IAtomContainerSet molSet , String id ) { for ( IAtomContainer mol : molSet . atomContainers ( ) ) { if ( mol . getID ( ) . equals ( id ) ) return mol ; } return null ; }
Get the IAtomContainer contained in a IAtomContainerSet object with a ID .
28,233
public int [ ] getRandomNextPermutation ( ) { int d = maxRank - currentRank ; int r = this . random . nextInt ( d ) ; this . currentRank += Math . max ( 1 , r ) ; return this . getCurrentPermutation ( ) ; }
Randomly skip ahead in the list of permutations .
28,234
public Object [ ] toArray ( ) { IAtomContainer [ ] ret = new IAtomContainer [ coordinates . size ( ) ] ; int index = 0 ; for ( Point3d [ ] coords : coordinates ) { try { IAtomContainer conf = ( IAtomContainer ) atomContainer . clone ( ) ; for ( int i = 0 ; i < coords . length ; i ++ ) { IAtom atom = conf . getAtom ( i ) ; atom . setPoint3d ( coords [ i ] ) ; } ret [ index ++ ] = conf ; } catch ( CloneNotSupportedException e ) { e . printStackTrace ( ) ; } } return ret ; }
Returns the conformers in the form of an array of IAtomContainers .
28,235
public boolean add ( IAtomContainer atomContainer ) { if ( this . atomContainer == null ) { this . atomContainer = atomContainer ; title = ( String ) atomContainer . getTitle ( ) ; } if ( title == null ) { throw new IllegalArgumentException ( "At least one of the input molecules does not have a title" ) ; } if ( ! title . equals ( atomContainer . getTitle ( ) ) ) throw new IllegalArgumentException ( "The input molecules does not have the same title ('" + title + "') as the other conformers ('" + atomContainer . getTitle ( ) + "')" ) ; if ( atomContainer . getAtomCount ( ) != this . atomContainer . getAtomCount ( ) ) throw new IllegalArgumentException ( "Doesn't have the same number of atoms as the rest of the conformers" ) ; coordinates . add ( getCoordinateList ( atomContainer ) ) ; return true ; }
Add a conformer to the end of the list .
28,236
public boolean remove ( Object o ) { IAtomContainer atomContainer = ( IAtomContainer ) o ; if ( atomContainer == null ) return false ; int index = indexOf ( atomContainer ) ; if ( index >= 0 ) { remove ( index ) ; return true ; } return false ; }
Remove the specified conformer .
28,237
public IAtomContainer get ( int i ) { Point3d [ ] tmp = coordinates . get ( i ) ; for ( int j = 0 ; j < atomContainer . getAtomCount ( ) ; j ++ ) { IAtom atom = atomContainer . getAtom ( j ) ; atom . setPoint3d ( tmp [ j ] ) ; } return atomContainer ; }
Get the conformer at a specified position .
28,238
public IAtomContainer remove ( int i ) { IAtomContainer oldAtomContainer = get ( i ) ; coordinates . remove ( i ) ; return oldAtomContainer ; }
Removes the conformer at the specified position .
28,239
public int indexOf ( Object o ) { IAtomContainer atomContainer = ( IAtomContainer ) o ; if ( ! atomContainer . getTitle ( ) . equals ( title ) ) return - 1 ; if ( atomContainer . getAtomCount ( ) != this . atomContainer . getAtomCount ( ) ) return - 1 ; boolean coordsMatch ; int index = 0 ; for ( Point3d [ ] coords : coordinates ) { coordsMatch = true ; for ( int i = 0 ; i < atomContainer . getAtomCount ( ) ; i ++ ) { Point3d p = atomContainer . getAtom ( i ) . getPoint3d ( ) ; if ( ! ( p . x == coords [ i ] . x && p . y == coords [ i ] . y && p . z == coords [ i ] . z ) ) { coordsMatch = false ; break ; } } if ( coordsMatch ) return index ; index ++ ; } return - 1 ; }
Returns the lowest index at which the specific IAtomContainer appears in the list or - 1 if is not found .
28,240
public int lastIndexOf ( Object o ) { IAtomContainer atomContainer = ( IAtomContainer ) o ; if ( ! atomContainer . getTitle ( ) . equals ( title ) ) return - 1 ; if ( atomContainer . getAtomCount ( ) != coordinates . get ( 0 ) . length ) return - 1 ; boolean coordsMatch ; for ( int j = coordinates . size ( ) - 1 ; j >= 0 ; j -- ) { Point3d [ ] coords = coordinates . get ( j ) ; coordsMatch = true ; for ( int i = 0 ; i < atomContainer . getAtomCount ( ) ; i ++ ) { Point3d p = atomContainer . getAtom ( i ) . getPoint3d ( ) ; if ( ! ( p . x == coords [ i ] . x && p . y == coords [ i ] . y && p . z == coords [ i ] . z ) ) { coordsMatch = false ; break ; } } if ( coordsMatch ) return j ; } return - 1 ; }
Returns the highest index at which the specific IAtomContainer appears in the list or - 1 if is not found .
28,241
public static int [ ] getInt2DColumnSum ( int [ ] [ ] apsp ) { int [ ] colSum = new int [ apsp . length ] ; int sum ; for ( int i = 0 ; i < apsp . length ; i ++ ) { sum = 0 ; for ( int j = 0 ; j < apsp . length ; j ++ ) { sum += apsp [ i ] [ j ] ; } colSum [ i ] = sum ; } return colSum ; }
Sums up the columns in a 2D int matrix .
28,242
public static IAtom [ ] findClosestByBond ( IAtomContainer atomContainer , IAtom atom , int max ) { IAtomContainer mol = atomContainer . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; List < IAtom > v = new ArrayList < IAtom > ( ) ; v . add ( atom ) ; breadthFirstSearch ( atomContainer , v , mol , max ) ; IAtom [ ] returnValue = new IAtom [ mol . getAtomCount ( ) - 1 ] ; int k = 0 ; for ( int i = 0 ; i < mol . getAtomCount ( ) ; i ++ ) { if ( ! mol . getAtom ( i ) . equals ( atom ) ) { returnValue [ k ] = mol . getAtom ( i ) ; k ++ ; } } return ( returnValue ) ; }
Returns the atoms which are closest to an atom in an AtomContainer by bonds . If number of atoms in or below sphere x&lt ; max and number of atoms in or below sphere x + 1&gt ; max then atoms in or below sphere x + 1 are returned .
28,243
public static int breadthFirstTargetSearch ( IAtomContainer atomContainer , List < IAtom > sphere , IAtom target , int pathLength , int cutOff ) { if ( pathLength == 0 ) resetFlags ( atomContainer ) ; pathLength ++ ; if ( pathLength > cutOff ) { return - 1 ; } IAtom nextAtom ; List < IAtom > newSphere = new ArrayList < IAtom > ( ) ; for ( IAtom atom : sphere ) { List < IBond > bonds = atomContainer . getConnectedBondsList ( atom ) ; for ( IBond bond : bonds ) { if ( ! bond . getFlag ( CDKConstants . VISITED ) ) { bond . setFlag ( CDKConstants . VISITED , true ) ; } nextAtom = bond . getOther ( atom ) ; if ( ! nextAtom . getFlag ( CDKConstants . VISITED ) ) { if ( nextAtom . equals ( target ) ) { return pathLength ; } newSphere . add ( nextAtom ) ; nextAtom . setFlag ( CDKConstants . VISITED , true ) ; } } } if ( newSphere . size ( ) > 0 ) { return breadthFirstTargetSearch ( atomContainer , newSphere , target , pathLength , cutOff ) ; } return - 1 ; }
Performs a breadthFirstTargetSearch in an AtomContainer starting with a particular sphere which usually consists of one start atom . While searching the graph the method marks each visited atom . It then puts all the atoms connected to the atoms in the given sphere into a new vector which forms the sphere to search for the next recursive method call . The method keeps track of the sphere count and returns it as soon as the target atom is encountered .
28,244
public static int getMolecularGraphRadius ( IAtomContainer atomContainer ) { int natom = atomContainer . getAtomCount ( ) ; int [ ] [ ] admat = AdjacencyMatrix . getMatrix ( atomContainer ) ; int [ ] [ ] distanceMatrix = computeFloydAPSP ( admat ) ; int [ ] eta = new int [ natom ] ; for ( int i = 0 ; i < natom ; i ++ ) { int max = - 99999 ; for ( int j = 0 ; j < natom ; j ++ ) { if ( distanceMatrix [ i ] [ j ] > max ) max = distanceMatrix [ i ] [ j ] ; } eta [ i ] = max ; } int min = 999999 ; for ( int anEta : eta ) { if ( anEta < min ) min = anEta ; } return min ; }
Returns the radius of the molecular graph .
28,245
public static int getVertexCountAtDistance ( IAtomContainer atomContainer , int distance ) { int natom = atomContainer . getAtomCount ( ) ; int [ ] [ ] admat = AdjacencyMatrix . getMatrix ( atomContainer ) ; int [ ] [ ] distanceMatrix = computeFloydAPSP ( admat ) ; int matches = 0 ; for ( int i = 0 ; i < natom ; i ++ ) { for ( int j = 0 ; j < natom ; j ++ ) { if ( distanceMatrix [ i ] [ j ] == distance ) matches ++ ; } } return matches / 2 ; }
Returns the number of vertices that are a distance d apart .
28,246
public static List < List < IAtom > > getAllPaths ( IAtomContainer atomContainer , IAtom start , IAtom end ) { List < List < IAtom > > allPaths = new ArrayList < List < IAtom > > ( ) ; if ( start . equals ( end ) ) return allPaths ; findPathBetween ( allPaths , atomContainer , start , end , new ArrayList < IAtom > ( ) ) ; return allPaths ; }
Get a list of all the paths between two atoms .
28,247
public Color getAtomColor ( IAtom atom , Color defaultColor ) { Color color = defaultColor ; if ( atom . getAtomicNumber ( ) == null ) return defaultColor ; int atomnumber = atom . getAtomicNumber ( ) ; switch ( atomnumber ) { case 1 : color = HYDROGEN ; break ; case 6 : color = CARBON ; break ; case 7 : color = NITROGEN ; break ; case 8 : color = OXYGEN ; break ; case 15 : color = PHOSPHORUS ; break ; case 16 : color = SULPHUR ; break ; case 17 : color = CHLORINE ; break ; } return color ; }
Returns the CDK scheme color for the given atom s element or defaults to the given color if no color is defined .
28,248
private IRing prepareRing ( List vec , IAtomContainer mol ) { int atomCount = vec . size ( ) ; IRing ring = mol . getBuilder ( ) . newInstance ( IRing . class , atomCount ) ; IAtom [ ] atoms = new IAtom [ atomCount ] ; vec . toArray ( atoms ) ; ring . setAtoms ( atoms ) ; try { IBond b ; for ( int i = 0 ; i < atomCount - 1 ; i ++ ) { b = mol . getBond ( atoms [ i ] , atoms [ i + 1 ] ) ; if ( b != null ) { ring . addBond ( b ) ; } else { logger . error ( "This should not happen." ) ; } } b = mol . getBond ( atoms [ 0 ] , atoms [ atomCount - 1 ] ) ; if ( b != null ) { ring . addBond ( b ) ; } else { logger . error ( "This should not happen either." ) ; } } catch ( Exception exc ) { logger . debug ( exc ) ; } logger . debug ( "found Ring " , ring ) ; return ring ; }
Returns the ring that is formed by the atoms in the given vector .
28,249
private void trim ( IAtom atom , IAtomContainer molecule ) { List < IBond > bonds = molecule . getConnectedBondsList ( atom ) ; for ( int i = 0 ; i < bonds . size ( ) ; i ++ ) { molecule . removeElectronContainer ( ( IBond ) bonds . get ( i ) ) ; } }
removes all bonds connected to the given atom leaving it with degree zero .
28,250
private void initPath ( IAtomContainer molecule ) { for ( int i = 0 ; i < molecule . getAtomCount ( ) ; i ++ ) { IAtom atom = molecule . getAtom ( i ) ; atom . setProperty ( PATH , new ArrayList < IAtom > ( ) ) ; } }
initializes a path vector in every Atom of the given molecule
28,251
private List < IAtom > getUnion ( List < IAtom > list1 , List < IAtom > list2 ) { List < IAtom > is = new ArrayList < IAtom > ( list1 ) ; for ( int f = list2 . size ( ) - 1 ; f > - 1 ; f -- ) { if ( ! list1 . contains ( list2 . get ( f ) ) ) is . add ( list2 . get ( f ) ) ; } return is ; }
Returns a Vector that contains the union of Vectors vec1 and vec2
28,252
private void breakBond ( IAtom atom , IAtomContainer molecule ) { Iterator < IBond > bonds = molecule . bonds ( ) . iterator ( ) ; while ( bonds . hasNext ( ) ) { IBond bond = ( IBond ) bonds . next ( ) ; if ( bond . contains ( atom ) ) { molecule . removeElectronContainer ( bond ) ; break ; } } }
Eliminates one bond of this atom from the molecule
28,253
private IBond checkEdges ( IRing ring , IAtomContainer molecule ) { IRing r1 , r2 ; IRingSet ringSet = ring . getBuilder ( ) . newInstance ( IRingSet . class ) ; IBond bond ; int minMaxSize = Integer . MAX_VALUE ; int minMax = 0 ; logger . debug ( "Molecule: " + molecule ) ; Iterator < IBond > bonds = ring . bonds ( ) . iterator ( ) ; while ( bonds . hasNext ( ) ) { bond = ( IBond ) bonds . next ( ) ; molecule . removeElectronContainer ( bond ) ; r1 = getRing ( bond . getBegin ( ) , molecule ) ; r2 = getRing ( bond . getEnd ( ) , molecule ) ; logger . debug ( "checkEdges: " + bond ) ; if ( r1 . getAtomCount ( ) > r2 . getAtomCount ( ) ) { ringSet . addAtomContainer ( r1 ) ; } else { ringSet . addAtomContainer ( r2 ) ; } molecule . addBond ( bond ) ; } for ( int i = 0 ; i < ringSet . getAtomContainerCount ( ) ; i ++ ) { if ( ( ( IRing ) ringSet . getAtomContainer ( i ) ) . getBondCount ( ) < minMaxSize ) { minMaxSize = ( ( IRing ) ringSet . getAtomContainer ( i ) ) . getBondCount ( ) ; minMax = i ; } } return ( IBond ) ring . getElectronContainer ( minMax ) ; }
Selects an optimum edge for elimination in structures without N2 nodes .
28,254
private void setBond ( ) throws Exception { List data = new Vector ( ) ; st . nextToken ( ) ; String scode = st . nextToken ( ) ; String sid1 = st . nextToken ( ) ; String sid2 = st . nextToken ( ) ; String slen = st . nextToken ( ) ; String sk2 = st . nextToken ( ) ; String sk3 = st . nextToken ( ) ; String sk4 = st . nextToken ( ) ; String sbci = st . nextToken ( ) ; try { double len = new Double ( slen ) . doubleValue ( ) ; double k2 = new Double ( sk2 ) . doubleValue ( ) ; double k3 = new Double ( sk3 ) . doubleValue ( ) ; double k4 = new Double ( sk4 ) . doubleValue ( ) ; double bci = new Double ( sbci ) . doubleValue ( ) ; data . add ( new Double ( len ) ) ; data . add ( new Double ( k2 ) ) ; data . add ( new Double ( k3 ) ) ; data . add ( new Double ( k4 ) ) ; data . add ( new Double ( bci ) ) ; } catch ( NumberFormatException nfe ) { throw new IOException ( "setBond: Malformed Number due to:" + nfe ) ; } key = "bond" + sid1 + ";" + sid2 ; parameterSet . put ( key , data ) ; }
Sets the bond attribute stored into the parameter set
28,255
private void setAngle ( ) throws Exception { List data = new Vector ( ) ; st . nextToken ( ) ; String scode = st . nextToken ( ) ; String sid1 = st . nextToken ( ) ; String sid2 = st . nextToken ( ) ; String sid3 = st . nextToken ( ) ; String value1 = st . nextToken ( ) ; String value2 = st . nextToken ( ) ; String value3 = st . nextToken ( ) ; String value4 = st . nextToken ( ) ; try { double va1 = new Double ( value1 ) . doubleValue ( ) ; double va2 = new Double ( value2 ) . doubleValue ( ) ; double va3 = new Double ( value3 ) . doubleValue ( ) ; double va4 = new Double ( value4 ) . doubleValue ( ) ; data . add ( new Double ( va1 ) ) ; data . add ( new Double ( va2 ) ) ; data . add ( new Double ( va3 ) ) ; data . add ( new Double ( va4 ) ) ; key = "angle" + sid1 + ";" + sid2 + ";" + sid3 ; if ( parameterSet . containsKey ( key ) ) { data = ( Vector ) parameterSet . get ( key ) ; data . add ( new Double ( va1 ) ) ; data . add ( new Double ( va2 ) ) ; data . add ( new Double ( va3 ) ) ; data . add ( new Double ( va4 ) ) ; } parameterSet . put ( key , data ) ; } catch ( NumberFormatException nfe ) { throw new IOException ( "setAngle: Malformed Number due to:" + nfe ) ; } }
Sets the angle attribute stored into the parameter set
28,256
private void setTorsion ( ) throws Exception { List data = null ; st . nextToken ( ) ; String scode = st . nextToken ( ) ; String sid1 = st . nextToken ( ) ; String sid2 = st . nextToken ( ) ; String sid3 = st . nextToken ( ) ; String sid4 = st . nextToken ( ) ; String value1 = st . nextToken ( ) ; String value2 = st . nextToken ( ) ; String value3 = st . nextToken ( ) ; String value4 = st . nextToken ( ) ; String value5 = st . nextToken ( ) ; try { double va1 = new Double ( value1 ) . doubleValue ( ) ; double va2 = new Double ( value2 ) . doubleValue ( ) ; double va3 = new Double ( value3 ) . doubleValue ( ) ; double va4 = new Double ( value4 ) . doubleValue ( ) ; double va5 = new Double ( value5 ) . doubleValue ( ) ; key = "torsion" + scode + ";" + sid1 + ";" + sid2 + ";" + sid3 + ";" + sid4 ; LOG . debug ( "key = " + key ) ; if ( parameterSet . containsKey ( key ) ) { data = ( Vector ) parameterSet . get ( key ) ; data . add ( new Double ( va1 ) ) ; data . add ( new Double ( va2 ) ) ; data . add ( new Double ( va3 ) ) ; data . add ( new Double ( va4 ) ) ; data . add ( new Double ( va5 ) ) ; LOG . debug ( "data = " + data ) ; } else { data = new Vector ( ) ; data . add ( new Double ( va1 ) ) ; data . add ( new Double ( va2 ) ) ; data . add ( new Double ( va3 ) ) ; data . add ( new Double ( va4 ) ) ; data . add ( new Double ( va5 ) ) ; LOG . debug ( "data = " + data ) ; } parameterSet . put ( key , data ) ; } catch ( NumberFormatException nfe ) { throw new IOException ( "setTorsion: Malformed Number due to:" + nfe ) ; } }
Sets the torsion attribute stored into the parameter set
28,257
private void setDefaultStrBnd ( ) throws Exception { LOG . debug ( "Sets the Default Stretch-Bend Parameters" ) ; List data = new Vector ( ) ; stDFSB . nextToken ( ) ; String sIR = stDFSB . nextToken ( ) ; String sJR = stDFSB . nextToken ( ) ; String sKR = stDFSB . nextToken ( ) ; String skbaIJK = stDFSB . nextToken ( ) ; String skbaKJI = stDFSB . nextToken ( ) ; try { key = "DFSB" + sIR + ";" + sJR + ";" + sKR ; double kbaIJK = new Double ( skbaIJK ) . doubleValue ( ) ; double kbaKJI = new Double ( skbaKJI ) . doubleValue ( ) ; data . add ( new Double ( kbaIJK ) ) ; data . add ( new Double ( kbaKJI ) ) ; parameterSet . put ( key , data ) ; } catch ( NumberFormatException nfe ) { throw new IOException ( "setDFSB: Malformed Number due to:" + nfe ) ; } }
Sets the Default Stretch - Bend Parameters into the parameter set
28,258
public boolean cyclic ( IBond bond ) { int u = container . indexOf ( bond . getBegin ( ) ) ; int v = container . indexOf ( bond . getEnd ( ) ) ; if ( u < 0 || v < 0 ) throw new NoSuchElementException ( "atoms of the bond are not found in the container" ) ; return searcher . cyclic ( u , v ) ; }
Determine whether the bond is cyclic . Note this currently requires a linear search to look - up the indices of each atoms .
28,259
private IAtomContainer toFragment ( int [ ] vertices ) { int n = vertices . length ; Set < IAtom > atoms = new HashSet < IAtom > ( n > 3 ? n + 1 + n / 3 : n ) ; List < IBond > bonds = new ArrayList < IBond > ( ) ; for ( int v : vertices ) { atoms . add ( container . getAtom ( v ) ) ; } for ( IBond bond : container . bonds ( ) ) { IAtom either = bond . getBegin ( ) ; IAtom other = bond . getEnd ( ) ; if ( atoms . contains ( either ) && atoms . contains ( other ) ) { bonds . add ( bond ) ; } } IAtomContainer fragment = container . getBuilder ( ) . newInstance ( IAtomContainer . class , 0 , 0 , 0 , 0 ) ; fragment . setAtoms ( atoms . toArray ( new IAtom [ n ] ) ) ; fragment . setBonds ( bonds . toArray ( new IBond [ bonds . size ( ) ] ) ) ; return fragment ; }
Utility method for creating a fragment from an array of vertices
28,260
public void setParameters ( Object [ ] params ) throws CDKException { if ( params . length != 2 ) { throw new CDKException ( "RotatableBondsCount expects two parameters" ) ; } if ( ! ( params [ 0 ] instanceof Boolean ) || ! ( params [ 1 ] instanceof Boolean ) ) { throw new CDKException ( "The parameters must be of type Boolean" ) ; } includeTerminals = ( Boolean ) params [ 0 ] ; excludeAmides = ( Boolean ) params [ 1 ] ; }
Sets the parameters attribute of the RotatableBondsCountDescriptor object
28,261
public Object [ ] getParameters ( ) { Object [ ] params = new Object [ 2 ] ; params [ 0 ] = includeTerminals ; params [ 1 ] = excludeAmides ; return params ; }
Gets the parameters attribute of the RotatableBondsCountDescriptor object
28,262
public DescriptorValue calculate ( IAtomContainer ac ) { ac = clone ( ac ) ; int rotatableBondsCount = 0 ; int degree0 ; int degree1 ; IRingSet ringSet ; try { ringSet = new SpanningTree ( ac ) . getBasicRings ( ) ; } catch ( NoSuchAtomException e ) { return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new IntegerResult ( ( int ) Double . NaN ) , getDescriptorNames ( ) , e ) ; } for ( IBond bond : ac . bonds ( ) ) { if ( ringSet . getRings ( bond ) . getAtomContainerCount ( ) > 0 ) { bond . setFlag ( CDKConstants . ISINRING , true ) ; } } for ( IBond bond : ac . bonds ( ) ) { IAtom atom0 = bond . getBegin ( ) ; IAtom atom1 = bond . getEnd ( ) ; if ( atom0 . getSymbol ( ) . equals ( "H" ) || atom1 . getSymbol ( ) . equals ( "H" ) ) continue ; if ( bond . getOrder ( ) == Order . SINGLE ) { if ( ( BondManipulator . isLowerOrder ( ac . getMaximumBondOrder ( atom0 ) , IBond . Order . TRIPLE ) ) && ( BondManipulator . isLowerOrder ( ac . getMaximumBondOrder ( atom1 ) , IBond . Order . TRIPLE ) ) ) { if ( ! bond . getFlag ( CDKConstants . ISINRING ) ) { if ( excludeAmides && ( isAmide ( atom0 , atom1 , ac ) || isAmide ( atom1 , atom0 , ac ) ) ) { continue ; } degree0 = ac . getConnectedBondsCount ( atom0 ) - getConnectedHCount ( ac , atom0 ) ; degree1 = ac . getConnectedBondsCount ( atom1 ) - getConnectedHCount ( ac , atom1 ) ; if ( ( degree0 == 1 ) || ( degree1 == 1 ) ) { if ( includeTerminals ) { rotatableBondsCount += 1 ; } } else { rotatableBondsCount += 1 ; } } } } } return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new IntegerResult ( rotatableBondsCount ) , getDescriptorNames ( ) ) ; }
The method calculates the number of rotatable bonds of an atom container . If the boolean parameter is set to true terminal bonds are included .
28,263
private List < List < Integer > > assignRingGroups ( List < Integer [ ] > rBondsArray ) { List < List < Integer > > ringGroups ; ringGroups = new ArrayList < List < Integer > > ( ) ; for ( int i = 0 ; i < rBondsArray . size ( ) - 1 ; i ++ ) { for ( int j = 0 ; j < rBondsArray . get ( i ) . length ; j ++ ) { for ( int k = i + 1 ; k < rBondsArray . size ( ) ; k ++ ) { for ( int l = 0 ; l < rBondsArray . get ( k ) . length ; l ++ ) { if ( Objects . equals ( rBondsArray . get ( i ) [ j ] , rBondsArray . get ( k ) [ l ] ) ) { if ( i != k ) { ringGroups . add ( new ArrayList < Integer > ( ) ) ; ringGroups . get ( ringGroups . size ( ) - 1 ) . add ( i ) ; ringGroups . get ( ringGroups . size ( ) - 1 ) . add ( k ) ; } } } } } } while ( combineGroups ( ringGroups ) ) ; for ( int i = 0 ; i < rBondsArray . size ( ) ; i ++ ) { boolean found = false ; for ( int j = 0 ; j < ringGroups . size ( ) ; j ++ ) { if ( ringGroups . get ( j ) . contains ( i ) ) { found = true ; break ; } } if ( ! found ) { ringGroups . add ( new ArrayList < Integer > ( ) ) ; ringGroups . get ( ringGroups . size ( ) - 1 ) . add ( i ) ; } } return ringGroups ; }
Assigns a set of rings to groups each sharing a bond .
28,264
private List < Integer > getAtomNosForRingGroup ( IAtomContainer molecule , List < Integer > ringGroup , IRingSet ringSet ) { List < Integer > atc = new ArrayList < Integer > ( ) ; for ( Integer i : ringGroup ) { for ( IAtom atom : ringSet . getAtomContainer ( i ) . atoms ( ) ) { if ( atc . size ( ) > 0 ) { if ( ! atc . contains ( molecule . indexOf ( atom ) ) ) { atc . add ( molecule . indexOf ( atom ) ) ; } } else { atc . add ( molecule . indexOf ( atom ) ) ; } } } return atc ; }
Gets the List of atom nos corresponding to a particular set of fused rings .
28,265
private List < Integer > getBondNosForRingGroup ( IAtomContainer molecule , List < Integer > ringGroup , IRingSet ringSet ) { List < Integer > btc = new ArrayList < Integer > ( ) ; for ( Integer i : ringGroup ) { for ( IBond bond : ringSet . getAtomContainer ( i ) . bonds ( ) ) { if ( btc . size ( ) > 0 ) { if ( ! btc . contains ( molecule . indexOf ( bond ) ) ) { btc . add ( molecule . indexOf ( bond ) ) ; } } else { btc . add ( molecule . indexOf ( bond ) ) ; } } } return btc ; }
Gets the List of bond nos corresponding to a particular set of fused rings .
28,266
private List < Integer [ ] > getAtomNoPairsForRingGroup ( IAtomContainer molecule , List < Integer > bondsToCheck ) { List < Integer [ ] > aptc = new ArrayList < Integer [ ] > ( ) ; for ( Integer i : bondsToCheck ) { Integer [ ] aps = new Integer [ 2 ] ; aps [ 0 ] = molecule . indexOf ( molecule . getBond ( i ) . getBegin ( ) ) ; aps [ 1 ] = molecule . indexOf ( molecule . getBond ( i ) . getEnd ( ) ) ; aptc . add ( aps ) ; } return aptc ; }
Gets List of atom number pairs for each bond in a list of bonds for the molecule .
28,267
private List < Integer > getFreeValenciesForRingGroup ( IAtomContainer molecule , List < Integer > atomsToCheck , Matrix M , IRingSet rs ) { List < Integer > fvtc = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < atomsToCheck . size ( ) ; i ++ ) { int j = atomsToCheck . get ( i ) ; if ( ( "C" . equals ( molecule . getAtom ( j ) . getSymbol ( ) ) ) && ( molecule . getAtom ( j ) . getHybridization ( ) == Hybridization . PLANAR3 ) ) { for ( IAtomContainer ac : rs . atomContainers ( ) ) { if ( ac . contains ( molecule . getAtom ( j ) ) ) { if ( ( int ) molecule . getBondOrderSum ( molecule . getAtom ( j ) ) == 2 && ac . getAtomCount ( ) == 5 ) { molecule . getAtom ( j ) . setImplicitHydrogenCount ( 1 ) ; break ; } } } } int implicitH = 0 ; if ( molecule . getAtom ( j ) . getImplicitHydrogenCount ( ) == null ) { CDKHydrogenAdder ha = CDKHydrogenAdder . getInstance ( molecule . getBuilder ( ) ) ; try { ha . addImplicitHydrogens ( molecule , molecule . getAtom ( j ) ) ; implicitH = molecule . getAtom ( j ) . getImplicitHydrogenCount ( ) ; } catch ( CDKException e ) { } } else { implicitH = molecule . getAtom ( j ) . getImplicitHydrogenCount ( ) ; } fvtc . add ( molecule . getAtom ( j ) . getValency ( ) - ( implicitH + ( int ) molecule . getBondOrderSum ( molecule . getAtom ( j ) ) ) + M . sumOfRow ( i ) ) ; } return fvtc ; }
Function to set up an array of integers corresponding to indicate how many free valencies need fulfilling for each atom through ring bonds .
28,268
public Iterable < IChemModel > chemModels ( ) { return new Iterable < IChemModel > ( ) { public Iterator < IChemModel > iterator ( ) { return new ChemModelIterator ( ) ; } } ; }
Returns an Iterable to ChemModels in this container .
28,269
protected void growChemModelArray ( ) { ChemModel [ ] newchemModels = new ChemModel [ chemModels . length + growArraySize ] ; System . arraycopy ( chemModels , 0 , newchemModels , 0 , chemModels . length ) ; chemModels = newchemModels ; }
Grows the chemModel array by a given size .
28,270
public StereoEncoder create ( IAtomContainer container , int [ ] [ ] graph ) { int n = container . getAtomCount ( ) ; BondMap map = new BondMap ( n ) ; List < StereoEncoder > encoders = new ArrayList < StereoEncoder > ( 1 ) ; for ( IBond bond : container . bonds ( ) ) { if ( isDoubleBond ( bond ) ) map . add ( bond ) ; } Set < IAtom > visited = new HashSet < IAtom > ( n ) ; for ( IAtom a : map . atoms ( ) ) { List < IBond > bonds = map . bonds ( a ) ; if ( bonds . size ( ) == 2 ) { IAtom s = bonds . get ( 0 ) . getOther ( a ) ; IAtom e = bonds . get ( 1 ) . getOther ( a ) ; IAtom sParent = a ; IAtom eParent = a ; visited . add ( a ) ; visited . add ( s ) ; visited . add ( e ) ; int size = 2 ; while ( s != null && map . cumulated ( s ) ) { IAtom p = map . bonds ( s ) . get ( 0 ) . getOther ( s ) ; IAtom q = map . bonds ( s ) . get ( 1 ) . getOther ( s ) ; sParent = s ; s = visited . add ( p ) ? p : visited . add ( q ) ? q : null ; size ++ ; } while ( e != null && map . cumulated ( e ) ) { IAtom p = map . bonds ( e ) . get ( 0 ) . getOther ( e ) ; IAtom q = map . bonds ( e ) . get ( 1 ) . getOther ( e ) ; eParent = e ; e = visited . add ( p ) ? p : visited . add ( q ) ? q : null ; size ++ ; } if ( s != null && e != null ) { if ( isOdd ( size ) ) { StereoEncoder encoder = GeometricDoubleBondEncoderFactory . newEncoder ( container , s , sParent , e , eParent , graph ) ; if ( encoder != null ) { encoders . add ( encoder ) ; } } else { StereoEncoder encoder = axialEncoder ( container , s , e ) ; if ( encoder != null ) { encoders . add ( encoder ) ; } } } } } return encoders . isEmpty ( ) ? StereoEncoder . EMPTY : new MultiStereoEncoder ( encoders ) ; }
Create a stereo encoder for cumulative double bonds .
28,271
private static StereoEncoder axial3DEncoder ( IAtomContainer container , IAtom start , List < IBond > startBonds , IAtom end , List < IBond > endBonds ) { Point3d [ ] coordinates = new Point3d [ 4 ] ; PermutationParity perm = new CombinedPermutationParity ( fill3DCoordinates ( container , start , startBonds , coordinates , 0 ) , fill3DCoordinates ( container , end , endBonds , coordinates , 2 ) ) ; GeometricParity geom = new Tetrahedral3DParity ( coordinates ) ; int u = container . indexOf ( start ) ; int v = container . indexOf ( end ) ; return new GeometryEncoder ( new int [ ] { u , v } , perm , geom ) ; }
Create an encoder for axial 3D stereochemistry for the given start and end atoms .
28,272
private static boolean has2DCoordinates ( List < IBond > bonds ) { for ( IBond bond : bonds ) { if ( bond . getBegin ( ) . getPoint2d ( ) == null || bond . getEnd ( ) . getPoint2d ( ) == null ) return false ; } return true ; }
Check if all atoms in the bond list have 2D coordinates . There is some redundant checking but the list will typically be short .
28,273
private static boolean has3DCoordinates ( List < IBond > bonds ) { for ( IBond bond : bonds ) { if ( bond . getBegin ( ) . getPoint3d ( ) == null || bond . getEnd ( ) . getPoint3d ( ) == null ) return false ; } return true ; }
Check if all atoms in the bond list have 3D coordinates . There is some redundant checking but the list will typically be short .
28,274
static int elevation ( IBond bond ) { IBond . Stereo stereo = bond . getStereo ( ) ; if ( stereo == null ) return 0 ; switch ( stereo ) { case UP : case DOWN_INVERTED : return + 1 ; case DOWN : case UP_INVERTED : return - 1 ; default : return 0 ; } }
Access the elevation of a bond .
28,275
protected List < Map < IAtom , IAtom > > getOverLaps ( IAtomContainer source , IAtomContainer target , boolean removeHydrogen ) throws CDKException { mappings = new ArrayList < Map < IAtom , IAtom > > ( ) ; connectedBondOrder = new TreeMap < Integer , Double > ( ) ; this . source = source ; this . target = target ; if ( source . getAtomCount ( ) == 1 || ( source . getAtomCount ( ) > 0 && source . getBondCount ( ) == 0 ) ) { setSourceSingleAtomMap ( removeHydrogen ) ; } if ( target . getAtomCount ( ) == 1 || ( target . getAtomCount ( ) > 0 && target . getBondCount ( ) == 0 ) ) { setTargetSingleAtomMap ( removeHydrogen ) ; } postFilter ( ) ; return mappings ; }
Returns single mapping solutions .
28,276
public void generateFragments ( IAtomContainer atomContainer ) throws CDKException { Set < Long > fragmentSet = new HashSet < Long > ( ) ; frameMap . clear ( ) ; ringMap . clear ( ) ; run ( atomContainer , fragmentSet ) ; }
Perform the fragmentation procedure .
28,277
public String [ ] getFragments ( ) { List < String > allfrags = new ArrayList < String > ( ) ; allfrags . addAll ( getSmilesFromAtomContainers ( frameMap . values ( ) ) ) ; allfrags . addAll ( getSmilesFromAtomContainers ( ringMap . values ( ) ) ) ; return allfrags . toArray ( new String [ ] { } ) ; }
This returns the frameworks and ring systems from a Murcko fragmentation .
28,278
int [ ] [ ] paths ( ) { int [ ] [ ] paths = new int [ this . paths . size ( ) ] [ 0 ] ; for ( int i = 0 ; i < this . paths . size ( ) ; i ++ ) { paths [ i ] = this . paths . get ( i ) ; } return paths ; }
The paths of the shortest cycles that paths are closed walks such that the first and last vertex is the same .
28,279
public void addNode ( CDKRNode newNode ) { getGraph ( ) . add ( newNode ) ; getGraphBitSet ( ) . set ( getGraph ( ) . size ( ) - 1 ) ; }
Adds a new node to the CDKRGraph .
28,280
private void parseRec ( BitSet traversed , BitSet extension , BitSet forbidden ) throws CDKException { BitSet newTraversed = null ; BitSet newExtension = null ; BitSet newForbidden = null ; BitSet potentialNode = null ; checkTimeOut ( ) ; if ( extension . isEmpty ( ) ) { solution ( traversed ) ; } else { potentialNode = ( ( BitSet ) getGraphBitSet ( ) . clone ( ) ) ; potentialNode . andNot ( forbidden ) ; potentialNode . or ( traversed ) ; if ( mustContinue ( potentialNode ) ) { setNbIteration ( getNbIteration ( ) + 1 ) ; for ( int x = extension . nextSetBit ( 0 ) ; x >= 0 && ! isStop ( ) ; x = extension . nextSetBit ( x + 1 ) ) { newForbidden = ( BitSet ) forbidden . clone ( ) ; newForbidden . or ( ( getGraph ( ) . get ( x ) ) . getForbidden ( ) ) ; if ( traversed . isEmpty ( ) ) { newExtension = ( BitSet ) ( ( getGraph ( ) . get ( x ) ) . getExtension ( ) . clone ( ) ) ; } else { newExtension = ( BitSet ) extension . clone ( ) ; newExtension . or ( ( getGraph ( ) . get ( x ) ) . getExtension ( ) ) ; } newExtension . andNot ( newForbidden ) ; newTraversed = ( BitSet ) traversed . clone ( ) ; newTraversed . set ( x ) ; forbidden . set ( x ) ; parseRec ( newTraversed , newExtension , newForbidden ) ; } } } }
Parsing of the CDKRGraph . This is the recursive method to perform a query . The method will recursively parse the CDKRGraph thru connected nodes and visiting the CDKRGraph using allowed adjacency relationship .
28,281
private BitSet buildB ( BitSet sourceBitSet , BitSet targetBitSet ) throws CDKException { this . setSourceBitSet ( sourceBitSet ) ; this . setTargetBitSet ( targetBitSet ) ; BitSet bistSet = new BitSet ( ) ; for ( Iterator < CDKRNode > i = getGraph ( ) . iterator ( ) ; i . hasNext ( ) ; ) { CDKRNode rNode = i . next ( ) ; checkTimeOut ( ) ; if ( ( sourceBitSet . get ( rNode . getRMap ( ) . getId1 ( ) ) || sourceBitSet . isEmpty ( ) ) && ( targetBitSet . get ( rNode . getRMap ( ) . getId2 ( ) ) || targetBitSet . isEmpty ( ) ) ) { bistSet . set ( getGraph ( ) . indexOf ( rNode ) ) ; } } return bistSet ; }
Builds the initial extension set . This is the set of node that may be used as seed for the CDKRGraph parsing . This set depends on the constrains defined by the user .
28,282
public BitSet projectG1 ( BitSet set ) { BitSet projection = new BitSet ( getFirstGraphSize ( ) ) ; CDKRNode xNode = null ; for ( int x = set . nextSetBit ( 0 ) ; x >= 0 ; x = set . nextSetBit ( x + 1 ) ) { xNode = getGraph ( ) . get ( x ) ; projection . set ( xNode . getRMap ( ) . getId1 ( ) ) ; } return projection ; }
Projects a CDKRGraph bitset on the source graph G1 .
28,283
public BitSet projectG2 ( BitSet set ) { BitSet projection = new BitSet ( getSecondGraphSize ( ) ) ; CDKRNode xNode = null ; for ( int x = set . nextSetBit ( 0 ) ; x >= 0 ; x = set . nextSetBit ( x + 1 ) ) { xNode = getGraph ( ) . get ( x ) ; projection . set ( xNode . getRMap ( ) . getId2 ( ) ) ; } return projection ; }
Projects a CDKRGraph bitset on the source graph G2 .
28,284
private boolean isContainedIn ( BitSet sourceBitSet , BitSet targetBitSet ) { boolean result = false ; if ( sourceBitSet . isEmpty ( ) ) { return true ; } BitSet setA = ( BitSet ) sourceBitSet . clone ( ) ; setA . and ( targetBitSet ) ; if ( setA . equals ( sourceBitSet ) ) { result = true ; } return result ; }
Test if set sourceBitSet is contained in set targetBitSet .
28,285
public boolean compare ( Object object ) { if ( ! ( object instanceof IChemObject ) ) { return false ; } ChemObject chemObj = ( ChemObject ) object ; return Objects . equal ( identifier , chemObj . identifier ) ; }
Compares a IChemObject with this IChemObject .
28,286
public void addReport ( ValidationReport report ) { errors . addAll ( report . errors ) ; warnings . addAll ( report . warnings ) ; oks . addAll ( report . oks ) ; cdkErrors . addAll ( report . cdkErrors ) ; }
Merges the tests with the tests in this ValidationReport .
28,287
private static double [ ] toVector ( Point3d src , Point3d dest ) { return new double [ ] { dest . x - src . x , dest . y - src . y , dest . z - src . z } ; }
Create a vector by specifying the source and destination coordinates .
28,288
private static double [ ] crossProduct ( double [ ] u , double [ ] v ) { return new double [ ] { ( u [ 1 ] * v [ 2 ] ) - ( v [ 1 ] * u [ 2 ] ) , ( u [ 2 ] * v [ 0 ] ) - ( v [ 2 ] * u [ 0 ] ) , ( u [ 0 ] * v [ 1 ] ) - ( v [ 0 ] * u [ 1 ] ) } ; }
Cross product of two 3D coordinates
28,289
public static boolean hasGraphRepresentation ( IAtomContainer molecule ) { for ( IBond bond : molecule . bonds ( ) ) if ( bond . getAtomCount ( ) != 2 ) return false ; return true ; }
Checks whether all bonds have exactly two atoms .
28,290
List < IStereoElement > recognise ( Set < Projection > projections ) { if ( ! projections . contains ( Projection . Haworth ) && ! projections . contains ( Projection . Chair ) ) return Collections . emptyList ( ) ; List < IStereoElement > elements = new ArrayList < IStereoElement > ( ) ; RingSearch ringSearch = new RingSearch ( container , graph ) ; for ( int [ ] isolated : ringSearch . isolated ( ) ) { if ( isolated . length < 5 || isolated . length > 7 ) continue ; int [ ] cycle = Arrays . copyOf ( GraphUtil . cycle ( graph , isolated ) , isolated . length ) ; Point2d [ ] points = coordinatesOfCycle ( cycle , container ) ; Turn [ ] turns = turns ( points ) ; WoundProjection projection = WoundProjection . ofTurns ( turns ) ; if ( ! projections . contains ( projection . projection ) ) continue ; if ( projection . projection == Projection . Haworth && ! checkHaworthAlignment ( points ) ) continue ; final Point2d horizontalXy = horizontalOffset ( points , turns , projection . projection ) ; if ( 1 - Math . abs ( horizontalXy . y ) < QUART_CARDINALITY_THRESHOLD ) continue ; int [ ] above = cycle . clone ( ) ; int [ ] below = cycle . clone ( ) ; if ( ! assignSubstituents ( cycle , above , below , projection , horizontalXy ) ) continue ; elements . addAll ( newTetrahedralCenters ( cycle , above , below , projection ) ) ; } return elements ; }
Recognise the cyclic carbohydrate projections .
28,291
static Turn [ ] turns ( Point2d [ ] points ) { final Turn [ ] turns = new Turn [ points . length ] ; for ( int i = 1 ; i <= points . length ; i ++ ) { Point2d prevXy = points [ i - 1 ] ; Point2d currXy = points [ i % points . length ] ; Point2d nextXy = points [ ( i + 1 ) % points . length ] ; int parity = ( int ) Math . signum ( det ( prevXy . x , prevXy . y , currXy . x , currXy . y , nextXy . x , nextXy . y ) ) ; if ( parity == 0 ) return null ; turns [ i % points . length ] = parity < 0 ? Right : Turn . Left ; } return turns ; }
Determine the turns in the polygon formed of the provided coordinates .
28,292
private List < ITetrahedralChirality > newTetrahedralCenters ( int [ ] cycle , int [ ] above , int [ ] below , WoundProjection type ) { List < ITetrahedralChirality > centers = new ArrayList < ITetrahedralChirality > ( cycle . length ) ; for ( int i = 1 ; i <= cycle . length ; i ++ ) { final int prev = cycle [ i - 1 ] ; final int curr = cycle [ i % cycle . length ] ; final int next = cycle [ ( i + 1 ) % cycle . length ] ; final int up = above [ i % cycle . length ] ; final int down = below [ i % cycle . length ] ; if ( ! stereocenters . isStereocenter ( curr ) ) continue ; if ( ! isPlanarSigmaBond ( bonds . get ( curr , prev ) ) || ! isPlanarSigmaBond ( bonds . get ( curr , next ) ) || ( up != curr && ! isPlanarSigmaBond ( bonds . get ( curr , up ) ) ) || ( down != curr && ! isPlanarSigmaBond ( bonds . get ( curr , down ) ) ) ) return Collections . emptyList ( ) ; centers . add ( new TetrahedralChirality ( container . getAtom ( curr ) , new IAtom [ ] { container . getAtom ( up ) , container . getAtom ( prev ) , container . getAtom ( down ) , container . getAtom ( next ) } , type . winding ) ) ; } return centers ; }
Create the tetrahedral stereocenters for the provided cycle .
28,293
private static Point2d [ ] coordinatesOfCycle ( int [ ] cycle , IAtomContainer container ) { Point2d [ ] points = new Point2d [ cycle . length ] ; for ( int i = 0 ; i < cycle . length ; i ++ ) { points [ i ] = container . getAtom ( cycle [ i ] ) . getPoint2d ( ) ; } return points ; }
Obtain the coordinates of atoms in a cycle .
28,294
private static int [ ] filter ( int [ ] org , int skip1 , int skip2 ) { int n = 0 ; int [ ] dest = new int [ org . length - 2 ] ; for ( int w : org ) { if ( w != skip1 && w != skip2 ) dest [ n ++ ] = w ; } return dest ; }
Filter an array excluding two provided values . These values must be present in the input .
28,295
private boolean checkHaworthAlignment ( Point2d [ ] points ) { for ( int i = 0 ; i < points . length ; i ++ ) { Point2d curr = points [ i ] ; Point2d next = points [ ( i + 1 ) % points . length ] ; double deltaY = curr . y - next . y ; if ( Math . abs ( deltaY ) < CARDINALITY_THRESHOLD ) return true ; } return false ; }
Ensures at least one cyclic bond is horizontal .
28,296
private Point2d horizontalOffset ( Point2d [ ] points , Turn [ ] turns , Projection projection ) { if ( projection != Projection . Chair ) return new Point2d ( 0 , 0 ) ; int offset = chairCenterOffset ( turns ) ; int prev = ( offset + 5 ) % 6 ; int next = ( offset + 7 ) % 6 ; double deltaX = points [ prev ] . x - points [ next ] . x ; double deltaY = points [ prev ] . y - points [ next ] . y ; double mag = Math . sqrt ( deltaX * deltaX + deltaY * deltaY ) ; deltaX /= mag ; deltaY /= mag ; if ( deltaX < 0 ) { deltaX = - deltaX ; deltaY = - deltaY ; } return new Point2d ( 1 - deltaX , deltaY ) ; }
Determine the horizontal offset of the projection . This allows projections that are drawn at angle to be correctly interpreted . Currently only projections of chair conformations are considered .
28,297
public double getPolarizabilitiyFactorForAtom ( IAtomContainer atomContainer , IAtom atom ) { IAtomContainer acH = atomContainer . getBuilder ( ) . newInstance ( IAtomContainer . class , atomContainer ) ; addExplicitHydrogens ( acH ) ; return getKJPolarizabilityFactor ( acH , atom ) ; }
Gets the polarizabilitiyFactorForAtom .
28,298
public double calculateKJMeanMolecularPolarizability ( IAtomContainer atomContainer ) { double polarizabilitiy = 0 ; IAtomContainer acH = atomContainer . getBuilder ( ) . newInstance ( IAtomContainer . class , atomContainer ) ; addExplicitHydrogens ( acH ) ; for ( int i = 0 ; i < acH . getAtomCount ( ) ; i ++ ) { polarizabilitiy += getKJPolarizabilityFactor ( acH , acH . getAtom ( i ) ) ; } return polarizabilitiy ; }
calculates the mean molecular polarizability as described in paper of Kang and Jhorn .
28,299
public double calculateBondPolarizability ( IAtomContainer atomContainer , IBond bond ) { double polarizabilitiy = 0 ; IAtomContainer acH = atomContainer . getBuilder ( ) . newInstance ( IAtomContainer . class , atomContainer ) ; addExplicitHydrogens ( acH ) ; if ( bond . getAtomCount ( ) == 2 ) { polarizabilitiy += getKJPolarizabilityFactor ( acH , bond . getBegin ( ) ) ; polarizabilitiy += getKJPolarizabilityFactor ( acH , bond . getEnd ( ) ) ; } return ( polarizabilitiy / 2 ) ; }
calculate bond polarizability .