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 hy...
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 . ...
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 ( ) ...
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 = ...
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 ( ) , ( element...
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 ( ) ; } els...
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 ...
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 ) ...
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 bon...
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 ) ;...
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...
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 i...
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 = c...
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 ( ) ; i...
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 ) ) || ! do...
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 . getConnectedAto...
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 bon...
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 ( ...
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...
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 ...
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 ( ! titl...
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 : c...
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 >=...
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 ) ; IA...
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 <...
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...
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 ++ )...
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 ++ )...
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 > ( ) ...
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 = NITROG...
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...
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 ( ) ...
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 ....
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 val...
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 ....
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 ( ...
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 . bo...
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...
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 ( ) , getParameterName...
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...
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 ...
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 ...
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 ) . getBe...
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 ...
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 ) ;...
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 , coordinat...
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 ...
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 ...
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 ( ...
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 Ri...
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...
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 ] ...
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 - point...
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 ++ ) { polar...
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 += ge...
calculate bond polarizability .