idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
28,400 | public static Map < String , IAminoAcid > getHashMapBySingleCharCode ( ) { IAminoAcid [ ] monomers = createAAs ( ) ; HashMap < String , IAminoAcid > map = new HashMap < String , IAminoAcid > ( ) ; for ( int i = 0 ; i < monomers . length ; i ++ ) { map . put ( ( String ) monomers [ i ] . getProperty ( RESIDUE_NAME_SHORT ) , monomers [ i ] ) ; } return map ; } | Returns a HashMap where the key is one of G A V L I S T C M D N E Q R K H F Y W and P . |
28,401 | public static Map < String , IAminoAcid > getHashMapByThreeLetterCode ( ) { AminoAcid [ ] monomers = createAAs ( ) ; Map < String , IAminoAcid > map = new HashMap < String , IAminoAcid > ( ) ; for ( int i = 0 ; i < monomers . length ; i ++ ) { map . put ( ( String ) monomers [ i ] . getProperty ( RESIDUE_NAME ) , monomers [ i ] ) ; } return map ; } | Returns a HashMap where the key is one of GLY ALA VAL LEU ILE SER THR CYS MET ASP ASN GLU GLN ARG LYS HIS PHE TYR TRP AND PRO . |
28,402 | public static String convertThreeLetterCodeToOneLetterCode ( String threeLetterCode ) { AminoAcid [ ] monomers = createAAs ( ) ; for ( int i = 0 ; i < monomers . length ; i ++ ) { if ( monomers [ i ] . getProperty ( RESIDUE_NAME ) . equals ( threeLetterCode ) ) { return ( String ) monomers [ i ] . getProperty ( RESIDUE_NAME_SHORT ) ; } } return null ; } | Returns the one letter code of an amino acid given a three letter code . For example it will return V when Val was passed . |
28,403 | public static String convertOneLetterCodeToThreeLetterCode ( String oneLetterCode ) { AminoAcid [ ] monomers = createAAs ( ) ; for ( int i = 0 ; i < monomers . length ; i ++ ) { if ( monomers [ i ] . getProperty ( RESIDUE_NAME_SHORT ) . equals ( oneLetterCode ) ) { return ( String ) monomers [ i ] . getProperty ( RESIDUE_NAME ) ; } } return null ; } | Returns the three letter code of an amino acid given a one letter code . For example it will return Val when V was passed . |
28,404 | public static void rotate ( IAtomContainer atomCon , Point2d center , double angle ) { Point2d point ; double costheta = Math . cos ( angle ) ; double sintheta = Math . sin ( angle ) ; IAtom atom ; for ( int i = 0 ; i < atomCon . getAtomCount ( ) ; i ++ ) { atom = atomCon . getAtom ( i ) ; point = atom . getPoint2d ( ) ; double relativex = point . x - center . x ; double relativey = point . y - center . y ; point . x = relativex * costheta - relativey * sintheta + center . x ; point . y = relativex * sintheta + relativey * costheta + center . y ; } } | Rotates a molecule around a given center by a given angle . |
28,405 | public static void rotate ( IAtom atom , Point3d p1 , Point3d p2 , double angle ) { double costheta , sintheta ; Point3d r = new Point3d ( ) ; r . x = p2 . x - p1 . x ; r . y = p2 . y - p1 . y ; r . z = p2 . z - p1 . z ; normalize ( r ) ; angle = angle * Math . PI / 180.0 ; costheta = Math . cos ( angle ) ; sintheta = Math . sin ( angle ) ; Point3d p = atom . getPoint3d ( ) ; p . x -= p1 . x ; p . y -= p1 . y ; p . z -= p1 . z ; Point3d q = new Point3d ( 0 , 0 , 0 ) ; q . x += ( costheta + ( 1 - costheta ) * r . x * r . x ) * p . x ; q . x += ( ( 1 - costheta ) * r . x * r . y - r . z * sintheta ) * p . y ; q . x += ( ( 1 - costheta ) * r . x * r . z + r . y * sintheta ) * p . z ; q . y += ( ( 1 - costheta ) * r . x * r . y + r . z * sintheta ) * p . x ; q . y += ( costheta + ( 1 - costheta ) * r . y * r . y ) * p . y ; q . y += ( ( 1 - costheta ) * r . y * r . z - r . x * sintheta ) * p . z ; q . z += ( ( 1 - costheta ) * r . x * r . z - r . y * sintheta ) * p . x ; q . z += ( ( 1 - costheta ) * r . y * r . z + r . x * sintheta ) * p . y ; q . z += ( costheta + ( 1 - costheta ) * r . z * r . z ) * p . z ; q . x += p1 . x ; q . y += p1 . y ; q . z += p1 . z ; atom . setPoint3d ( q ) ; } | Rotates a 3D point about a specified line segment by a specified angle . |
28,406 | public static void normalize ( Point3d point ) { double sum = Math . sqrt ( point . x * point . x + point . y * point . y + point . z * point . z ) ; point . x = point . x / sum ; point . y = point . y / sum ; point . z = point . z / sum ; } | Normalizes a point . |
28,407 | public static Rectangle2D getRectangle2D ( IAtomContainer container ) { double [ ] minmax = getMinMax ( container ) ; return new Rectangle2D . Double ( minmax [ 0 ] , minmax [ 1 ] , minmax [ 2 ] - minmax [ 0 ] , minmax [ 3 ] - minmax [ 1 ] ) ; } | Returns the 2D rectangle spanning the space occupied by the atom container . |
28,408 | public static double getAngle ( double xDiff , double yDiff ) { double angle = 0 ; if ( xDiff >= 0 && yDiff >= 0 ) { angle = Math . atan ( yDiff / xDiff ) ; } else if ( xDiff < 0 && yDiff >= 0 ) { angle = Math . PI + Math . atan ( yDiff / xDiff ) ; } else if ( xDiff < 0 && yDiff < 0 ) { angle = Math . PI + Math . atan ( yDiff / xDiff ) ; } else if ( xDiff >= 0 && yDiff < 0 ) { angle = 2 * Math . PI + Math . atan ( yDiff / xDiff ) ; } return angle ; } | Gets the angle attribute of the GeometryTools class . |
28,409 | public static Vector2d calculatePerpendicularUnitVector ( Point2d point1 , Point2d point2 ) { Vector2d vector = new Vector2d ( ) ; vector . sub ( point2 , point1 ) ; vector . normalize ( ) ; return new Vector2d ( - 1.0 * vector . y , vector . x ) ; } | Determines the normalized vector orthogonal on the vector p1 - > ; p2 . |
28,410 | public static List < IAtom > findClosestInSpace ( IAtomContainer container , IAtom startAtom , int max ) throws CDKException { Point3d originalPoint = startAtom . getPoint3d ( ) ; if ( originalPoint == null ) { throw new CDKException ( "No point3d, but findClosestInSpace is working on point3ds" ) ; } Map < Double , IAtom > atomsByDistance = new TreeMap < Double , IAtom > ( ) ; for ( IAtom atom : container . atoms ( ) ) { if ( ! atom . equals ( startAtom ) ) { if ( atom . getPoint3d ( ) == null ) { throw new CDKException ( "No point3d, but findClosestInSpace is working on point3ds" ) ; } double distance = atom . getPoint3d ( ) . distance ( originalPoint ) ; atomsByDistance . put ( distance , atom ) ; } } Set < Double > keySet = atomsByDistance . keySet ( ) ; Iterator < Double > keyIter = keySet . iterator ( ) ; List < IAtom > returnValue = new ArrayList < IAtom > ( ) ; int i = 0 ; while ( keyIter . hasNext ( ) && i < max ) { returnValue . add ( atomsByDistance . get ( keyIter . next ( ) ) ) ; i ++ ; } return ( returnValue ) ; } | Returns the atoms which are closes to an atom in an AtomContainer by distance in 3d . |
28,411 | public static double getAllAtomRMSD ( IAtomContainer firstAtomContainer , IAtomContainer secondAtomContainer , Map < Integer , Integer > mappedAtoms , boolean Coords3d ) throws CDKException { double sum = 0 ; double RMSD ; Iterator < Integer > firstAtoms = mappedAtoms . keySet ( ) . iterator ( ) ; int firstAtomNumber ; int secondAtomNumber ; int n = 0 ; while ( firstAtoms . hasNext ( ) ) { firstAtomNumber = firstAtoms . next ( ) ; try { secondAtomNumber = mappedAtoms . get ( firstAtomNumber ) ; IAtom firstAtom = firstAtomContainer . getAtom ( firstAtomNumber ) ; if ( Coords3d ) { sum = sum + Math . pow ( firstAtom . getPoint3d ( ) . distance ( secondAtomContainer . getAtom ( secondAtomNumber ) . getPoint3d ( ) ) , 2 ) ; n ++ ; } else { sum = sum + Math . pow ( firstAtom . getPoint2d ( ) . distance ( secondAtomContainer . getAtom ( secondAtomNumber ) . getPoint2d ( ) ) , 2 ) ; n ++ ; } } catch ( Exception ex ) { throw new CDKException ( ex . getMessage ( ) , ex ) ; } } RMSD = Math . sqrt ( sum / n ) ; return RMSD ; } | Return the RMSD between the 2 aligned molecules . |
28,412 | public static double getHeavyAtomRMSD ( IAtomContainer firstAtomContainer , IAtomContainer secondAtomContainer , Map < Integer , Integer > mappedAtoms , boolean hetAtomOnly , boolean Coords3d ) { double sum = 0 ; double RMSD = 0 ; Iterator < Integer > firstAtoms = mappedAtoms . keySet ( ) . iterator ( ) ; int firstAtomNumber = 0 ; int secondAtomNumber = 0 ; int n = 0 ; while ( firstAtoms . hasNext ( ) ) { firstAtomNumber = firstAtoms . next ( ) ; secondAtomNumber = mappedAtoms . get ( firstAtomNumber ) ; IAtom firstAtom = firstAtomContainer . getAtom ( firstAtomNumber ) ; if ( hetAtomOnly ) { if ( ! firstAtom . getSymbol ( ) . equals ( "H" ) && ! firstAtom . getSymbol ( ) . equals ( "C" ) ) { if ( Coords3d ) { sum = sum + Math . pow ( ( ( Point3d ) firstAtom . getPoint3d ( ) ) . distance ( secondAtomContainer . getAtom ( secondAtomNumber ) . getPoint3d ( ) ) , 2 ) ; n ++ ; } else { sum = sum + Math . pow ( ( ( Point2d ) firstAtom . getPoint2d ( ) ) . distance ( secondAtomContainer . getAtom ( secondAtomNumber ) . getPoint2d ( ) ) , 2 ) ; n ++ ; } } } else { if ( ! firstAtom . getSymbol ( ) . equals ( "H" ) ) { if ( Coords3d ) { sum = sum + Math . pow ( ( ( Point3d ) firstAtom . getPoint3d ( ) ) . distance ( secondAtomContainer . getAtom ( secondAtomNumber ) . getPoint3d ( ) ) , 2 ) ; n ++ ; } else { sum = sum + Math . pow ( ( ( Point2d ) firstAtom . getPoint2d ( ) ) . distance ( secondAtomContainer . getAtom ( secondAtomNumber ) . getPoint2d ( ) ) , 2 ) ; n ++ ; } } } } RMSD = Math . sqrt ( sum / n ) ; return RMSD ; } | Return the RMSD of the heavy atoms between the 2 aligned molecules . |
28,413 | public static double getBondLengthAverage3D ( IAtomContainer container ) { double bondLengthSum = 0 ; int bondCounter = 0 ; for ( IBond bond : container . bonds ( ) ) { IAtom atom1 = bond . getBegin ( ) ; IAtom atom2 = bond . getEnd ( ) ; if ( atom1 . getPoint3d ( ) != null && atom2 . getPoint3d ( ) != null ) { bondCounter ++ ; bondLengthSum += atom1 . getPoint3d ( ) . distance ( atom2 . getPoint3d ( ) ) ; } } return bondLengthSum / bondCounter ; } | An average of all 3D bond length values is produced using point3ds in atoms . Atom s with no coordinates are disregarded . |
28,414 | public static Rectangle2D shiftContainer ( IAtomContainer container , Rectangle2D bounds , Rectangle2D last , double gap ) { if ( last . getMaxX ( ) + gap >= bounds . getMinX ( ) ) { double xShift = last . getMaxX ( ) + gap - bounds . getMinX ( ) ; Vector2d shift = new Vector2d ( xShift , 0.0 ) ; GeometryTools . translate2D ( container , shift ) ; return new Rectangle2D . Double ( bounds . getX ( ) + xShift , bounds . getY ( ) , bounds . getWidth ( ) , bounds . getHeight ( ) ) ; } else { return bounds ; } } | Shift the container horizontally to the right to make its bounds not overlap with the other bounds . |
28,415 | public static Rectangle2D shiftReactionVertical ( IReaction reaction , Rectangle2D bounds , Rectangle2D last , double gap ) { if ( last . getMaxY ( ) + gap >= bounds . getMinY ( ) ) { double yShift = bounds . getHeight ( ) + last . getHeight ( ) + gap ; Vector2d shift = new Vector2d ( 0 , yShift ) ; List < IAtomContainer > containers = ReactionManipulator . getAllAtomContainers ( reaction ) ; for ( IAtomContainer container : containers ) { translate2D ( container , shift ) ; } return new Rectangle2D . Double ( bounds . getX ( ) , bounds . getY ( ) + yShift , bounds . getWidth ( ) , bounds . getHeight ( ) ) ; } else { return bounds ; } } | Shift the containers in a reaction vertically upwards to not overlap with the reference Rectangle2D . The shift is such that the given gap is realized but only if the reactions are actually overlapping . |
28,416 | public String [ ] getNames ( ) { if ( descriptorNames == null || descriptorNames . length == 0 ) { String title = specification . getImplementationTitle ( ) ; if ( value instanceof BooleanResult || value instanceof DoubleResult || value instanceof IntegerResult ) { descriptorNames = new String [ 1 ] ; descriptorNames [ 0 ] = title ; } else { int ndesc = 0 ; if ( value instanceof DoubleArrayResult ) { ndesc = value . length ( ) ; } else if ( value instanceof IntegerArrayResult ) { ndesc = value . length ( ) ; } descriptorNames = new String [ ndesc ] ; for ( int i = 0 ; i < ndesc ; i ++ ) descriptorNames [ i ] = title + i ; } } return descriptorNames ; } | Returns an array of names for each descriptor value calculated . |
28,417 | public Expr and ( Expr expr ) { if ( type == Type . TRUE ) { set ( expr ) ; } else if ( expr . type != Type . TRUE ) { if ( type . isLogical ( ) && ! expr . type . isLogical ( ) ) { if ( type == AND ) right . and ( expr ) ; else if ( type != NOT ) setLogical ( Type . AND , expr , new Expr ( this ) ) ; else setLogical ( Type . AND , expr , new Expr ( this ) ) ; } else { setLogical ( Type . AND , new Expr ( this ) , expr ) ; } } return this ; } | Utility combine this expression with another using conjunction . The expression will only match if both conditions are met . |
28,418 | public Expr or ( Expr expr ) { if ( type == Type . TRUE || type == Type . FALSE || type == NONE ) { set ( expr ) ; } else if ( expr . type != Type . TRUE && expr . type != Type . FALSE && expr . type != Type . NONE ) { if ( type . isLogical ( ) && ! expr . type . isLogical ( ) ) { if ( type == OR ) right . or ( expr ) ; else if ( type != NOT ) setLogical ( Type . OR , expr , new Expr ( this ) ) ; else setLogical ( Type . OR , new Expr ( this ) , expr ) ; } else setLogical ( Type . OR , new Expr ( this ) , expr ) ; } return this ; } | Utility combine this expression with another using disjunction . The expression will match if either conditions is met . |
28,419 | public void setPrimitive ( Type type , int val ) { if ( type . hasValue ( ) ) { this . type = type ; this . value = val ; this . left = null ; this . right = null ; this . query = null ; } else { throw new IllegalArgumentException ( "Value provided for non-value " + "expression type!" ) ; } } | Set the primitive value of this atom expression . |
28,420 | public void setLogical ( Type type , Expr left , Expr right ) { switch ( type ) { case AND : case OR : this . type = type ; this . value = 0 ; this . left = left ; this . right = right ; this . query = null ; break ; case NOT : this . type = type ; if ( left != null && right == null ) this . left = left ; else if ( left == null && right != null ) this . left = right ; else if ( left != null ) throw new IllegalArgumentException ( "Only one sub-expression" + " should be provided" + " for NOT expressions!" ) ; this . query = null ; this . value = 0 ; break ; default : throw new IllegalArgumentException ( "Left/Right sub expressions " + "supplied for " + " non-logical operator!" ) ; } } | Set the logical value of this atom expression . |
28,421 | private void setRecursive ( Type type , IAtomContainer mol ) { switch ( type ) { case RECURSIVE : this . type = type ; this . value = 0 ; this . left = null ; this . right = null ; this . query = mol ; this . ptrn = null ; break ; default : throw new IllegalArgumentException ( ) ; } } | Set the recursive value of this atom expression . |
28,422 | public static IAtomContainerSet getAllMolecules ( IReactionSet set ) { IAtomContainerSet moleculeSet = set . getBuilder ( ) . newInstance ( IAtomContainerSet . class ) ; for ( IReaction reaction : set . reactions ( ) ) { IAtomContainerSet molecules = ReactionManipulator . getAllMolecules ( reaction ) ; for ( IAtomContainer ac : molecules . atomContainers ( ) ) { boolean contain = false ; for ( IAtomContainer atomContainer : moleculeSet . atomContainers ( ) ) { if ( atomContainer . equals ( ac ) ) { contain = true ; break ; } } if ( ! contain ) moleculeSet . addAtomContainer ( ac ) ; } } return moleculeSet ; } | get all Molecules object from a set of Reactions . |
28,423 | public static IReactionSet getRelevantReactions ( IReactionSet reactSet , IAtomContainer molecule ) { IReactionSet newReactSet = reactSet . getBuilder ( ) . newInstance ( IReactionSet . class ) ; IReactionSet reactSetProd = getRelevantReactionsAsProduct ( reactSet , molecule ) ; for ( IReaction reaction : reactSetProd . reactions ( ) ) newReactSet . addReaction ( reaction ) ; IReactionSet reactSetReact = getRelevantReactionsAsReactant ( reactSet , molecule ) ; for ( IReaction reaction : reactSetReact . reactions ( ) ) newReactSet . addReaction ( reaction ) ; return newReactSet ; } | Get all Reactions object containing a Molecule from a set of Reactions . |
28,424 | public static IReactionSet getRelevantReactionsAsReactant ( IReactionSet reactSet , IAtomContainer molecule ) { IReactionSet newReactSet = reactSet . getBuilder ( ) . newInstance ( IReactionSet . class ) ; for ( IReaction reaction : reactSet . reactions ( ) ) { for ( IAtomContainer atomContainer : reaction . getReactants ( ) . atomContainers ( ) ) if ( atomContainer . equals ( molecule ) ) newReactSet . addReaction ( reaction ) ; } return newReactSet ; } | Get all Reactions object containing a Molecule as a Reactant from a set of Reactions . |
28,425 | public static IReactionSet getRelevantReactionsAsProduct ( IReactionSet reactSet , IAtomContainer molecule ) { IReactionSet newReactSet = reactSet . getBuilder ( ) . newInstance ( IReactionSet . class ) ; for ( IReaction reaction : reactSet . reactions ( ) ) { for ( IAtomContainer atomContainer : reaction . getProducts ( ) . atomContainers ( ) ) if ( atomContainer . equals ( molecule ) ) newReactSet . addReaction ( reaction ) ; } return newReactSet ; } | Get all Reactions object containing a Molecule as a Product from a set of Reactions . |
28,426 | public static IReaction getReactionByAtomContainerID ( IReactionSet reactionSet , String id ) { for ( IReaction reaction : reactionSet . reactions ( ) ) { if ( AtomContainerSetManipulator . containsByID ( reaction . getProducts ( ) , id ) ) return reaction ; } for ( IReaction reaction : reactionSet . reactions ( ) ) { if ( AtomContainerSetManipulator . containsByID ( reaction . getReactants ( ) , id ) ) return reaction ; } return null ; } | Gets a reaction from a ReactionSet by ID of any product or reactant . If several exist only the first one will be returned . |
28,427 | public static IReaction getReactionByReactionID ( IReactionSet reactionSet , String id ) { Iterable < IReaction > reactionIter = reactionSet . reactions ( ) ; for ( IReaction reaction : reactionIter ) { if ( reaction . getID ( ) != null && reaction . getID ( ) . equals ( id ) ) { return reaction ; } } return null ; } | Gets a reaction from a ReactionSet by ID . If several exist only the first one will be returned . |
28,428 | public static int getAtomCount ( IChemSequence sequence ) { int count = 0 ; for ( int i = 0 ; i < sequence . getChemModelCount ( ) ; i ++ ) { count += ChemModelManipulator . getAtomCount ( sequence . getChemModel ( i ) ) ; } return count ; } | Get the total number of atoms inside an IChemSequence . |
28,429 | public static int getBondCount ( IChemSequence sequence ) { int count = 0 ; for ( int i = 0 ; i < sequence . getChemModelCount ( ) ; i ++ ) { count += ChemModelManipulator . getBondCount ( sequence . getChemModel ( i ) ) ; } return count ; } | Get the total number of bonds inside an IChemSequence . |
28,430 | public static List < IAtomContainer > getAllAtomContainers ( IChemSequence sequence ) { List < IAtomContainer > acList = new ArrayList < IAtomContainer > ( ) ; for ( IChemModel model : sequence . chemModels ( ) ) { acList . addAll ( ChemModelManipulator . getAllAtomContainers ( model ) ) ; } return acList ; } | Returns all the AtomContainer s of a ChemSequence . |
28,431 | public static List < IChemObject > getAllChemObjects ( IChemSequence sequence ) { List < IChemObject > list = new ArrayList < IChemObject > ( ) ; for ( int i = 0 ; i < sequence . getChemModelCount ( ) ; i ++ ) { list . add ( sequence . getChemModel ( i ) ) ; List < IChemObject > current = ChemModelManipulator . getAllChemObjects ( sequence . getChemModel ( i ) ) ; for ( IChemObject chemObject : current ) { if ( ! list . contains ( chemObject ) ) list . add ( chemObject ) ; } } return list ; } | Returns a List of all IChemObject inside a ChemSequence . |
28,432 | public IRingSet getRings ( IBond bond ) { IRingSet rings = bond . getBuilder ( ) . newInstance ( IRingSet . class ) ; Ring ring ; for ( int i = 0 ; i < getAtomContainerCount ( ) ; i ++ ) { ring = ( Ring ) getAtomContainer ( i ) ; if ( ring . contains ( bond ) ) { rings . addAtomContainer ( ring ) ; } } return rings ; } | Returns a vector of all rings that this bond is part of . |
28,433 | public IRingSet getRings ( IAtom atom ) { IRingSet rings = new RingSet ( ) ; IRing ring ; for ( int i = 0 ; i < getAtomContainerCount ( ) ; i ++ ) { ring = ( Ring ) getAtomContainer ( i ) ; if ( ring . contains ( atom ) ) { rings . addAtomContainer ( ring ) ; } } return rings ; } | Returns a vector of all rings that this atom is part of . |
28,434 | public IRingSet getConnectedRings ( IRing ring ) { IRingSet connectedRings = ring . getBuilder ( ) . newInstance ( IRingSet . class ) ; IRing tempRing ; IAtom atom ; for ( int i = 0 ; i < ring . getAtomCount ( ) ; i ++ ) { atom = ring . getAtom ( i ) ; for ( int j = 0 ; j < getAtomContainerCount ( ) ; j ++ ) { tempRing = ( IRing ) getAtomContainer ( j ) ; if ( tempRing != ring && ! connectedRings . contains ( tempRing ) && tempRing . contains ( atom ) ) { connectedRings . addAtomContainer ( tempRing ) ; } } } return connectedRings ; } | Returns all the rings in the RingSet that share one or more atoms with a given ring . |
28,435 | public void add ( IRingSet ringSet ) { for ( int f = 0 ; f < ringSet . getAtomContainerCount ( ) ; f ++ ) { if ( ! contains ( ringSet . getAtomContainer ( f ) ) ) { addAtomContainer ( ringSet . getAtomContainer ( f ) ) ; } } } | Adds all rings of another RingSet if they are not already part of this ring set . |
28,436 | public boolean contains ( IAtom atom ) { for ( int i = 0 ; i < getAtomContainerCount ( ) ; i ++ ) { if ( getAtomContainer ( i ) . contains ( atom ) ) { return true ; } } return false ; } | True if at least one of the rings in the ringset contains the given atom . |
28,437 | public boolean contains ( IAtomContainer ring ) { for ( int i = 0 ; i < getAtomContainerCount ( ) ; i ++ ) { if ( ring == getAtomContainer ( i ) ) { return true ; } } return false ; } | Checks for presence of a ring in this RingSet . |
28,438 | private boolean verify ( int n , int m ) { for ( int n_prime : g1 [ n ] ) { boolean found = false ; for ( int m_prime : g2 [ m ] ) { if ( matrix . get ( n_prime , m_prime ) && bondMatcher . matches ( bond1 . get ( n , n_prime ) , bonds2 . get ( m , m_prime ) ) ) { found = true ; break ; } } if ( ! found ) return false ; } return true ; } | Verify that for every vertex adjacent to n there should be at least one feasible candidate adjacent which can be mapped . If no such candidate exists the mapping of n - > m is not longer valid . |
28,439 | private boolean hasCandidate ( int n ) { for ( int j = ( n * matrix . mCols ) , end = ( j + matrix . mCols ) ; j < end ; j ++ ) if ( matrix . get ( j ) ) return true ; return false ; } | Check if there are any feasible mappings left for the query vertex n . We scan the compatibility matrix to see if any value is > 0 . |
28,440 | public static AtomTypeFactory getInstance ( InputStream ins , String format , IChemObjectBuilder builder ) { return new AtomTypeFactory ( ins , format , builder ) ; } | Method to create a default AtomTypeFactory using the given InputStream . An AtomType of this kind is not cached . |
28,441 | private void readConfiguration ( String fileName , IChemObjectBuilder builder ) { logger . info ( "Reading config file from " , fileName ) ; InputStream ins ; { ins = this . getClass ( ) . getClassLoader ( ) . getResourceAsStream ( fileName ) ; if ( ins == null ) { File file = new File ( fileName ) ; if ( file . exists ( ) ) { logger . debug ( "configFile is a File" ) ; try { ins = new FileInputStream ( file ) ; } catch ( Exception exception ) { logger . error ( exception . getMessage ( ) ) ; logger . debug ( exception ) ; } } else { logger . error ( "no stream and no file" ) ; } } } String format = XML_EXTENSION ; if ( fileName . endsWith ( TXT_EXTENSION ) ) { format = TXT_EXTENSION ; } else if ( fileName . endsWith ( XML_EXTENSION ) ) { format = XML_EXTENSION ; } else if ( fileName . endsWith ( OWL_EXTENSION ) ) { format = OWL_EXTENSION ; } readConfiguration ( ins , format , builder ) ; } | Read the configuration from a text file . |
28,442 | public IAtomType getAtomType ( String identifier ) throws NoSuchAtomTypeException { IAtomType type = atomTypes . get ( identifier ) ; if ( type != null ) return type ; throw new NoSuchAtomTypeException ( "The AtomType " + identifier + " could not be found" ) ; } | Get an AtomType with the given ID . |
28,443 | public IAtomType [ ] getAtomTypes ( String symbol ) { logger . debug ( "Request for atomtype for symbol " , symbol ) ; List < IAtomType > atomList = new ArrayList < IAtomType > ( ) ; for ( IAtomType atomType : atomTypes . values ( ) ) { if ( Objects . equals ( atomType . getSymbol ( ) , symbol ) ) { atomList . add ( atomType ) ; } } IAtomType [ ] atomTypes = ( IAtomType [ ] ) atomList . toArray ( new IAtomType [ atomList . size ( ) ] ) ; if ( atomTypes . length > 0 ) logger . debug ( "Atomtype for symbol " , symbol , " has this number of types: " + atomTypes . length ) ; else logger . debug ( "No atomtype for symbol " , symbol ) ; return atomTypes ; } | Get an array of all atomTypes known to the AtomTypeFactory for the given element symbol and atomtype class . |
28,444 | public IAtomType [ ] getAllAtomTypes ( ) { logger . debug ( "Returning list of size: " , getSize ( ) ) ; return ( IAtomType [ ] ) atomTypes . values ( ) . toArray ( new IAtomType [ atomTypes . size ( ) ] ) ; } | Gets the allAtomTypes attribute of the AtomTypeFactory object . |
28,445 | public IAtom configure ( IAtom atom ) throws CDKException { if ( atom instanceof IPseudoAtom ) { return atom ; } try { IAtomType atomType ; String atomTypeName = atom . getAtomTypeName ( ) ; if ( atomTypeName == null || atomTypeName . length ( ) == 0 ) { logger . debug ( "Using atom symbol because atom type name is empty..." ) ; IAtomType [ ] types = getAtomTypes ( atom . getSymbol ( ) ) ; if ( types . length > 0 ) { logger . warn ( "Taking first atom type, but other may exist" ) ; atomType = types [ 0 ] ; } else { String message = "Could not configure atom with unknown ID: " + atom . toString ( ) + " + (id=" + atom . getAtomTypeName ( ) + ")" ; logger . warn ( message ) ; throw new CDKException ( message ) ; } } else { atomType = getAtomType ( atom . getAtomTypeName ( ) ) ; } logger . debug ( "Configuring with atomtype: " , atomType ) ; atom . setSymbol ( atomType . getSymbol ( ) ) ; atom . setMaxBondOrder ( atomType . getMaxBondOrder ( ) ) ; atom . setBondOrderSum ( atomType . getBondOrderSum ( ) ) ; atom . setCovalentRadius ( atomType . getCovalentRadius ( ) ) ; atom . setHybridization ( atomType . getHybridization ( ) ) ; Object color = atomType . getProperty ( "org.openscience.cdk.renderer.color" ) ; if ( color != null ) { atom . setProperty ( "org.openscience.cdk.renderer.color" , color ) ; } atom . setAtomicNumber ( atomType . getAtomicNumber ( ) ) ; atom . setExactMass ( atomType . getExactMass ( ) ) ; } catch ( Exception exception ) { logger . warn ( "Could not configure atom with unknown ID: " , atom , " + (id=" , atom . getAtomTypeName ( ) , ")" ) ; logger . debug ( exception ) ; throw new CDKException ( exception . toString ( ) , exception ) ; } logger . debug ( "Configured: " , atom ) ; return atom ; } | Configures an atom . Finds the correct element type by looking at the Atom s atom type name and if that fails picks the first atom type matching the Atom s element symbol .. |
28,446 | public Color getAtomColor ( IAtom atom , Color defaultColor ) { Color color = defaultColor ; if ( atom . getCharge ( ) == null ) return defaultColor ; double charge = atom . getCharge ( ) ; if ( charge > 0.0 ) { if ( charge < 1.0 ) { int index = 255 - ( int ) ( charge * 255.0 ) ; color = new Color ( index , index , 255 ) ; } else { color = Color . blue ; } } else if ( charge < 0.0 ) { if ( charge > - 1.0 ) { int index = 255 + ( int ) ( charge * 255.0 ) ; color = new Color ( 255 , index , index ) ; } else { color = Color . red ; } } return color ; } | Returns the a color reflecting the given atom s partial charge or defaults to the given color if no color is defined . |
28,447 | public IBitFingerprint getBitFingerprint ( IAtomContainer atomContainer ) throws CDKException { generateFp ( atomContainer ) ; BitSet fp = new BitSet ( FP_SIZE ) ; for ( int i = 0 ; i < FP_SIZE ; i ++ ) { if ( isBitOn ( i ) ) fp . set ( i ) ; } return new BitSetFingerprint ( fp ) ; } | Calculate 881 bit Pubchem fingerprint for a molecule . |
28,448 | public static BitSet decode ( String enc ) { byte [ ] fp = base64Decode ( enc ) ; if ( fp . length < 4 ) { throw new IllegalArgumentException ( "Input is not a proper PubChem base64 encoded fingerprint" ) ; } int len = ( fp [ 0 ] << 24 ) | ( fp [ 1 ] << 16 ) | ( fp [ 2 ] << 8 ) | ( fp [ 3 ] & 0xff ) ; if ( len != FP_SIZE ) { throw new IllegalArgumentException ( "Input is not a proper PubChem base64 encoded fingerprint" ) ; } PubchemFingerprinter pc = new PubchemFingerprinter ( null ) ; for ( int i = 0 ; i < pc . m_bits . length ; ++ i ) { pc . m_bits [ i ] = fp [ i + 4 ] ; } BitSet ret = new BitSet ( FP_SIZE ) ; for ( int i = 0 ; i < FP_SIZE ; i ++ ) { if ( pc . isBitOn ( i ) ) ret . set ( i ) ; } return ret ; } | Returns a fingerprint from a Base64 encoded Pubchem fingerprint . |
28,449 | private String encode ( ) { byte [ ] pack = new byte [ 4 + m_bits . length ] ; pack [ 0 ] = ( byte ) ( ( FP_SIZE & 0xffffffff ) >> 24 ) ; pack [ 1 ] = ( byte ) ( ( FP_SIZE & 0x00ffffff ) >> 16 ) ; pack [ 2 ] = ( byte ) ( ( FP_SIZE & 0x0000ffff ) >> 8 ) ; pack [ 3 ] = ( byte ) ( FP_SIZE & 0x000000ff ) ; for ( int i = 0 ; i < m_bits . length ; ++ i ) { pack [ i + 4 ] = m_bits [ i ] ; } return base64Encode ( pack ) ; } | the first four bytes contains the length of the fingerprint |
28,450 | public IReaction parseReactionSmiles ( String smiles ) throws InvalidSmilesException { if ( ! smiles . contains ( ">" ) ) throw new InvalidSmilesException ( "Not a reaction SMILES: " + smiles ) ; final int first = smiles . indexOf ( '>' ) ; final int second = smiles . indexOf ( '>' , first + 1 ) ; if ( second < 0 ) throw new InvalidSmilesException ( "Invalid reaction SMILES:" + smiles ) ; final String reactants = smiles . substring ( 0 , first ) ; final String agents = smiles . substring ( first + 1 , second ) ; final String products = smiles . substring ( second + 1 , smiles . length ( ) ) ; IReaction reaction = builder . newInstance ( IReaction . class ) ; if ( ! reactants . isEmpty ( ) ) { IAtomContainer reactantContainer = parseSmiles ( reactants , true ) ; IAtomContainerSet reactantSet = ConnectivityChecker . partitionIntoMolecules ( reactantContainer ) ; for ( int i = 0 ; i < reactantSet . getAtomContainerCount ( ) ; i ++ ) { reaction . addReactant ( reactantSet . getAtomContainer ( i ) ) ; } } if ( ! agents . isEmpty ( ) ) { IAtomContainer agentContainer = parseSmiles ( agents , true ) ; IAtomContainerSet agentSet = ConnectivityChecker . partitionIntoMolecules ( agentContainer ) ; for ( int i = 0 ; i < agentSet . getAtomContainerCount ( ) ; i ++ ) { reaction . addAgent ( agentSet . getAtomContainer ( i ) ) ; } } String title = null ; if ( ! products . isEmpty ( ) ) { IAtomContainer productContainer = parseSmiles ( products , true ) ; IAtomContainerSet productSet = ConnectivityChecker . partitionIntoMolecules ( productContainer ) ; for ( int i = 0 ; i < productSet . getAtomContainerCount ( ) ; i ++ ) { reaction . addProduct ( productSet . getAtomContainer ( i ) ) ; } reaction . setProperty ( CDKConstants . TITLE , title = productContainer . getProperty ( CDKConstants . TITLE ) ) ; } try { parseRxnCXSMILES ( title , reaction ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; throw new InvalidSmilesException ( "Error parsing CXSMILES:" + e . getMessage ( ) ) ; } return reaction ; } | Parse a reaction SMILES . |
28,451 | private void parseMolCXSMILES ( String title , IAtomContainer mol ) { CxSmilesState cxstate ; int pos ; if ( title != null && title . startsWith ( "|" ) ) { if ( ( pos = CxSmilesParser . processCx ( title , cxstate = new CxSmilesState ( ) ) ) >= 0 ) { mol . setTitle ( title . substring ( pos ) ) ; final Map < IAtom , IAtomContainer > atomToMol = Maps . newHashMapWithExpectedSize ( mol . getAtomCount ( ) ) ; final List < IAtom > atoms = new ArrayList < > ( mol . getAtomCount ( ) ) ; for ( IAtom atom : mol . atoms ( ) ) { atoms . add ( atom ) ; atomToMol . put ( atom , mol ) ; } assignCxSmilesInfo ( mol . getBuilder ( ) , mol , atoms , atomToMol , cxstate ) ; } } } | Parses CXSMILES layer and set attributes for atoms and bonds on the provided molecule . |
28,452 | private void parseRxnCXSMILES ( String title , IReaction rxn ) { CxSmilesState cxstate ; int pos ; if ( title != null && title . startsWith ( "|" ) ) { if ( ( pos = CxSmilesParser . processCx ( title , cxstate = new CxSmilesState ( ) ) ) >= 0 ) { rxn . setProperty ( CDKConstants . TITLE , title . substring ( pos ) ) ; final Map < IAtom , IAtomContainer > atomToMol = new HashMap < > ( 100 ) ; final List < IAtom > atoms = new ArrayList < > ( ) ; handleFragmentGrouping ( rxn , cxstate ) ; for ( IAtomContainer mol : rxn . getReactants ( ) . atomContainers ( ) ) { for ( IAtom atom : mol . atoms ( ) ) { atoms . add ( atom ) ; atomToMol . put ( atom , mol ) ; } } for ( IAtomContainer mol : rxn . getAgents ( ) . atomContainers ( ) ) { for ( IAtom atom : mol . atoms ( ) ) { atoms . add ( atom ) ; atomToMol . put ( atom , mol ) ; } } for ( IAtomContainer mol : rxn . getProducts ( ) . atomContainers ( ) ) { for ( IAtom atom : mol . atoms ( ) ) { atoms . add ( atom ) ; atomToMol . put ( atom , mol ) ; } } assignCxSmilesInfo ( rxn . getBuilder ( ) , rxn , atoms , atomToMol , cxstate ) ; } } } | Parses CXSMILES layer and set attributes for atoms and bonds on the provided reaction . |
28,453 | public void setParameters ( Object [ ] params ) throws CDKException { if ( params . length != 1 ) { throw new CDKException ( "AromaticBondsCountDescriptor expects one parameter" ) ; } if ( ! ( params [ 0 ] instanceof Boolean ) ) { throw new CDKException ( "The first parameter must be of type Boolean" ) ; } checkAromaticity = ( Boolean ) params [ 0 ] ; } | Sets the parameters attribute of the AromaticBondsCountDescriptor object . |
28,454 | private void checkBond ( IAtomContainer atomContainer , int index ) throws CDKException { IBond bond = atomContainer . getBond ( index ) ; if ( bond != null && bond . getFlag ( CDKConstants . SINGLE_OR_DOUBLE ) ) { try { oldBondOrder = bond . getOrder ( ) ; bond . setOrder ( IBond . Order . SINGLE ) ; setMaxBondOrder ( bond , atomContainer ) ; } catch ( CDKException e ) { bond . setOrder ( oldBondOrder ) ; logger . debug ( e ) ; } } } | This method tries to set the bond order on the current bond . |
28,455 | private void setMaxBondOrder ( IBond bond , IAtomContainer atomContainer ) throws CDKException { if ( bondOrderCanBeIncreased ( bond , atomContainer ) ) { if ( bond . getOrder ( ) != IBond . Order . QUADRUPLE ) bond . setOrder ( BondManipulator . increaseBondOrder ( bond . getOrder ( ) ) ) ; else throw new CDKException ( "Can't increase a quadruple bond!" ) ; } } | This method decides the highest bond order that the bond can have and set it to that . |
28,456 | public boolean bondOrderCanBeIncreased ( IBond bond , IAtomContainer atomContainer ) throws CDKException { boolean atom0isUnsaturated = false , atom1isUnsaturated = false ; double sum ; if ( bond . getBegin ( ) . getBondOrderSum ( ) == null ) { sum = getAtomBondordersum ( bond . getEnd ( ) , atomContainer ) ; } else sum = bond . getBegin ( ) . getBondOrderSum ( ) ; if ( bondsUsed ( bond . getBegin ( ) , atomContainer ) < sum ) atom0isUnsaturated = true ; if ( bond . getEnd ( ) . getBondOrderSum ( ) == null ) { sum = getAtomBondordersum ( bond . getEnd ( ) , atomContainer ) ; } else sum = bond . getEnd ( ) . getBondOrderSum ( ) ; if ( bondsUsed ( bond . getEnd ( ) , atomContainer ) < sum ) atom1isUnsaturated = true ; if ( atom0isUnsaturated == atom1isUnsaturated ) return atom0isUnsaturated ; else { int myIndex = atomContainer . indexOf ( bond ) ; if ( myIndex == 0 ) return false ; if ( atomContainer . getBond ( myIndex - 1 ) . getOrder ( ) == IBond . Order . DOUBLE ) return false ; if ( isConnected ( atomContainer . getBond ( myIndex ) , atomContainer . getBond ( 0 ) ) ) throw new CantDecideBondOrderException ( "Can't decide bond order of this bond" ) ; else { return false ; } } } | Check if the bond order can be increased . This method assumes that the bond is between only two atoms . |
28,457 | private double getAtomBondordersum ( IAtom atom , IAtomContainer mol ) throws CDKException { double sum = 0 ; for ( IBond bond : mol . bonds ( ) ) if ( bond . contains ( atom ) ) sum += BondManipulator . destroyBondOrder ( bond . getOrder ( ) ) ; return sum ; } | This method is used if by some reason the bond order sum is not set for an atom . |
28,458 | private double bondsUsed ( IAtom atom , IAtomContainer atomContainer ) throws CDKException { int bondsToAtom = 0 ; for ( IBond bond : atomContainer . bonds ( ) ) if ( bond . contains ( atom ) ) bondsToAtom += BondManipulator . destroyBondOrder ( bond . getOrder ( ) ) ; int implicitHydrogens ; if ( atom . getImplicitHydrogenCount ( ) == CDKConstants . UNSET || atom . getImplicitHydrogenCount ( ) == null ) { if ( atom . getValency ( ) == CDKConstants . UNSET || atom . getValency ( ) == null ) throw new CDKException ( "Atom " + atom . getAtomTypeName ( ) + " has not got the valency set." ) ; if ( atom . getFormalNeighbourCount ( ) == CDKConstants . UNSET || atom . getFormalNeighbourCount ( ) == null ) throw new CDKException ( "Atom " + atom . getAtomTypeName ( ) + " has not got the formal neighbour count set." ) ; implicitHydrogens = ( 8 - atom . getValency ( ) ) - atom . getFormalNeighbourCount ( ) ; String warningMessage = "Number of implicite hydrogens not set for atom " + atom . getAtomTypeName ( ) + ". Estimated it to: " + implicitHydrogens ; logger . warn ( warningMessage ) ; } else implicitHydrogens = atom . getImplicitHydrogenCount ( ) ; double charge ; if ( atom . getCharge ( ) == CDKConstants . UNSET ) if ( atom . getFormalCharge ( ) == CDKConstants . UNSET ) { charge = 0 ; String warningMessage = "Neither charge nor formal charge is set for atom " + atom . getAtomTypeName ( ) + ". Estimate it to: 0" ; logger . warn ( warningMessage ) ; } else charge = atom . getFormalCharge ( ) ; else charge = atom . getCharge ( ) ; return bondsToAtom - charge + implicitHydrogens ; } | A small help method that count how many bonds an atom has regarding bonds due to its charge and to implicit hydrogens . |
28,459 | private static BufferedWriter ensureBuffered ( Writer wtr ) { if ( wtr == null ) throw new NullPointerException ( "Provided writer was null" ) ; return wtr instanceof BufferedWriter ? ( BufferedWriter ) wtr : new BufferedWriter ( wtr ) ; } | Ensures a writer is buffered . |
28,460 | public void setParameters ( Object [ ] params ) throws CDKException { if ( params . length > 1 ) { throw new CDKException ( "weight only expects one parameter" ) ; } if ( ! ( params [ 0 ] instanceof String ) ) { throw new CDKException ( "The parameter must be of type String" ) ; } elementName = ( String ) params [ 0 ] ; } | Sets the parameters attribute of the WeightDescriptor object . |
28,461 | private IAtomContainer setInitialCharges ( IAtomContainer ac ) throws CDKException { Matcher matOC = null ; Matcher matOP = null ; Matcher matOS = null ; Matcher mat_p = null ; Matcher mat_n = null ; String hoseCode = "" ; for ( int i = 0 ; i < ac . getAtomCount ( ) ; i ++ ) { try { hoseCode = hcg . getHOSECode ( ac , ac . getAtom ( i ) , 3 ) ; } catch ( CDKException ex1 ) { throw new CDKException ( "Could not build HOSECode from atom " + i + " due to " + ex1 . toString ( ) , ex1 ) ; } hoseCode = removeAromaticityFlagsFromHoseCode ( hoseCode ) ; matOC = pOC . matcher ( hoseCode ) ; matOP = pOP . matcher ( hoseCode ) ; matOS = pOS . matcher ( hoseCode ) ; mat_p = p_p . matcher ( hoseCode ) ; mat_n = p_n . matcher ( hoseCode ) ; if ( matOC . matches ( ) ) { ac . getAtom ( i ) . setCharge ( - 0.500 ) ; } else if ( matOP . matches ( ) ) { ac . getAtom ( i ) . setCharge ( - 0.666 ) ; } else if ( matOS . matches ( ) ) { ac . getAtom ( i ) . setCharge ( - 0.500 ) ; } else if ( mat_p . matches ( ) ) { ac . getAtom ( i ) . setCharge ( + 1.000 ) ; } else if ( mat_n . matches ( ) ) { ac . getAtom ( i ) . setCharge ( - 1.000 ) ; } else { ac . getAtom ( i ) . setCharge ( new Double ( ac . getAtom ( i ) . getFormalCharge ( ) ) ) ; } } return ac ; } | Sets the initialCharges attribute of the AtomTypeCharges object . |
28,462 | public DescriptorValue calculate ( IAtom atom , IAtomContainer container ) { int atomDegree = 0 ; List < IAtom > neighboors = container . getConnectedAtomsList ( atom ) ; for ( IAtom neighboor : neighboors ) { if ( ! neighboor . getSymbol ( ) . equals ( "H" ) ) atomDegree += 1 ; } return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new IntegerResult ( atomDegree ) , getDescriptorNames ( ) ) ; } | This method calculates the number of not - H substituents of an atom . |
28,463 | public void paint ( IAtomContainerSet molecules , IDrawVisitor drawVisitor , Rectangle2D bounds , boolean resetCenter ) { Rectangle2D totalBounds = BoundsCalculator . calculateBounds ( molecules ) ; this . setupTransformToFit ( bounds , totalBounds , AverageBondLengthCalculator . calculateAverageBondLength ( molecules ) , resetCenter ) ; IRenderingElement diagram = this . generateDiagram ( molecules ) ; this . paint ( drawVisitor , diagram ) ; } | Paint a set of molecules . |
28,464 | private boolean augment ( ) { Arrays . fill ( even , NIL ) ; Arrays . fill ( odd , NIL ) ; dsf = new DisjointSetForest ( graph . length ) ; bridges . clear ( ) ; queue . clear ( ) ; for ( int v = 0 ; v < graph . length ; v ++ ) { if ( subset . get ( v ) && matching . unmatched ( v ) ) { even [ v ] = v ; queue . add ( v ) ; } } while ( ! queue . isEmpty ( ) ) { int v = queue . remove ( 0 ) ; for ( int w : graph [ v ] ) { if ( ! subset . get ( w ) ) continue ; if ( even [ dsf . getRoot ( w ) ] != NIL ) { if ( check ( v , w ) ) return true ; } else if ( odd [ w ] == NIL ) { odd [ w ] = v ; int u = matching . other ( w ) ; if ( even [ dsf . getRoot ( u ) ] == NIL ) { even [ u ] = w ; queue . add ( u ) ; } } } } return false ; } | Find an augmenting path an alternate it s matching . If an augmenting path was found then the search must be restarted . If a blossom was detected the blossom is contracted and the search continues . |
28,465 | private boolean check ( int v , int w ) { if ( dsf . getRoot ( v ) == dsf . getRoot ( w ) ) return false ; vAncestors . clear ( ) ; wAncestors . clear ( ) ; int vCurr = v ; int wCurr = w ; while ( true ) { vCurr = parent ( vAncestors , vCurr ) ; wCurr = parent ( wAncestors , wCurr ) ; if ( vCurr == wCurr ) { blossom ( v , w , vCurr ) ; return false ; } if ( dsf . getRoot ( even [ vCurr ] ) == vCurr && dsf . getRoot ( even [ wCurr ] ) == wCurr ) { augment ( v ) ; augment ( w ) ; matching . match ( v , w ) ; return true ; } if ( wAncestors . get ( vCurr ) ) { blossom ( v , w , vCurr ) ; return false ; } if ( vAncestors . get ( wCurr ) ) { blossom ( v , w , wCurr ) ; return false ; } } } | An edge was found which connects two even vertices in the forest . If the vertices have the same root we have a blossom otherwise we have identified an augmenting path . This method checks for these cases and responds accordingly . |
28,466 | private int parent ( BitSet ancestors , int curr ) { curr = dsf . getRoot ( curr ) ; ancestors . set ( curr ) ; int parent = dsf . getRoot ( even [ curr ] ) ; if ( parent == curr ) return curr ; ancestors . set ( parent ) ; return dsf . getRoot ( odd [ parent ] ) ; } | Access the next ancestor in a tree of the forest . Note we go back two places at once as we only need check even vertices . |
28,467 | private void blossom ( int v , int w , int base ) { base = dsf . getRoot ( base ) ; int [ ] supports1 = blossomSupports ( v , w , base ) ; int [ ] supports2 = blossomSupports ( w , v , base ) ; for ( int i = 0 ; i < supports1 . length ; i ++ ) dsf . makeUnion ( supports1 [ i ] , supports1 [ 0 ] ) ; for ( int i = 0 ; i < supports2 . length ; i ++ ) dsf . makeUnion ( supports2 [ i ] , supports2 [ 0 ] ) ; even [ dsf . getRoot ( base ) ] = even [ base ] ; } | Create a new blossom for the specified bridge edge . |
28,468 | private void augment ( int v ) { int n = buildPath ( path , 0 , v , NIL ) ; for ( int i = 2 ; i < n ; i += 2 ) { matching . match ( path [ i ] , path [ i - 1 ] ) ; } } | Augment all ancestors in the tree of vertex v . |
28,469 | private int buildPath ( int [ ] path , int i , int start , int goal ) { while ( true ) { while ( odd [ start ] != NIL ) { Tuple bridge = bridges . get ( start ) ; int j = buildPath ( path , i , bridge . first , start ) ; reverse ( path , i , j - 1 ) ; i = j ; start = bridge . second ; } path [ i ++ ] = start ; if ( matching . unmatched ( start ) ) return i ; path [ i ++ ] = matching . other ( start ) ; if ( path [ i - 1 ] == goal ) return i ; start = odd [ path [ i - 1 ] ] ; } } | Builds the path backwards from the specified start vertex until the goal . If the path reaches a blossom then the path through the blossom is lifted to the original graph . |
28,470 | private static void reverse ( int [ ] path , int i , int j ) { while ( i < j ) { int tmp = path [ i ] ; path [ i ] = path [ j ] ; path [ j ] = tmp ; i ++ ; j -- ; } } | Reverse a section of a fixed size array . |
28,471 | static Matching maxamise ( Matching matching , int [ ] [ ] graph , BitSet subset ) { new EdmondsMaximumMatching ( graph , matching , subset ) ; return matching ; } | Attempt to maximise the provided matching over a subset of vertices in a graph . |
28,472 | private void writeAtomContainer ( IAtomContainerSet som ) throws IOException { String sym ; double chrg ; for ( int molnum = 0 ; molnum < som . getAtomContainerCount ( ) ; molnum ++ ) { IAtomContainer mol = som . getAtomContainer ( molnum ) ; try { String molname = "mol " + ( molnum + 1 ) + " " + mol . getTitle ( ) ; writer . write ( molname , 0 , molname . length ( ) ) ; writer . write ( '\n' ) ; Iterator < IAtom > atoms = mol . atoms ( ) . iterator ( ) ; int i = 0 ; while ( atoms . hasNext ( ) ) { IAtom atom = atoms . next ( ) ; String line = "atom " ; sym = atom . getSymbol ( ) ; chrg = atom . getCharge ( ) ; Point3d point = atom . getPoint3d ( ) ; line = line + Integer . toString ( i + 1 ) + " - " + sym + " ** - " + Double . toString ( chrg ) + " " + Double . toString ( point . x ) + " " + Double . toString ( point . y ) + " " + Double . toString ( point . z ) + " " ; String buf = "" ; int ncon = 0 ; Iterator < IBond > bonds = mol . bonds ( ) . iterator ( ) ; while ( bonds . hasNext ( ) ) { IBond bond = bonds . next ( ) ; if ( bond . contains ( atom ) ) { IAtom connectedAtom = bond . getOther ( atom ) ; IBond . Order bondOrder = bond . getOrder ( ) ; int serial ; String bondType = "" ; serial = mol . indexOf ( connectedAtom ) ; if ( bondOrder == IBond . Order . SINGLE ) bondType = "s" ; else if ( bondOrder == IBond . Order . DOUBLE ) bondType = "d" ; else if ( bondOrder == IBond . Order . TRIPLE ) bondType = "t" ; else if ( bond . getFlag ( CDKConstants . ISAROMATIC ) ) bondType = "a" ; buf = buf + Integer . toString ( serial + 1 ) + " " + bondType + " " ; ncon ++ ; } } line = line + " " + Integer . toString ( ncon ) + " " + buf ; writer . write ( line , 0 , line . length ( ) ) ; writer . write ( '\n' ) ; i ++ ; } String buf = "endmol " + ( molnum + 1 ) ; writer . write ( buf , 0 , buf . length ( ) ) ; writer . write ( '\n' ) ; } catch ( IOException e ) { throw e ; } } } | writes all the molecules supplied in a MoleculeSet class to a single HIN file . You can also supply a single Molecule object as well |
28,473 | public static IAtomContainer makePyrroleAnion ( ) { IAtomContainer mol = new AtomContainer ( ) ; IAtom nitrogenAnion = new Atom ( "N" ) ; nitrogenAnion . setFormalCharge ( - 1 ) ; mol . addAtom ( new Atom ( "C" ) ) ; mol . addAtom ( nitrogenAnion ) ; mol . addAtom ( new Atom ( "C" ) ) ; mol . addAtom ( new Atom ( "C" ) ) ; mol . addAtom ( new Atom ( "C" ) ) ; mol . addBond ( 0 , 1 , IBond . Order . SINGLE ) ; mol . addBond ( 1 , 2 , IBond . Order . SINGLE ) ; mol . addBond ( 2 , 3 , IBond . Order . DOUBLE ) ; mol . addBond ( 3 , 4 , IBond . Order . SINGLE ) ; mol . addBond ( 4 , 0 , IBond . Order . DOUBLE ) ; return mol ; } | Returns pyrrole anion without explicit hydrogens . |
28,474 | public static IAtomContainer makePyridineOxide ( ) { IAtomContainer mol = new AtomContainer ( ) ; mol . addAtom ( new Atom ( "C" ) ) ; mol . addAtom ( new Atom ( "N" ) ) ; mol . getAtom ( 1 ) . setFormalCharge ( 1 ) ; mol . addAtom ( new Atom ( "C" ) ) ; mol . addAtom ( new Atom ( "C" ) ) ; mol . addAtom ( new Atom ( "C" ) ) ; mol . addAtom ( new Atom ( "C" ) ) ; mol . addAtom ( new Atom ( "O" ) ) ; mol . getAtom ( 6 ) . setFormalCharge ( - 1 ) ; mol . addBond ( 0 , 1 , IBond . Order . DOUBLE ) ; mol . addBond ( 1 , 2 , IBond . Order . SINGLE ) ; mol . addBond ( 2 , 3 , IBond . Order . DOUBLE ) ; mol . addBond ( 3 , 4 , IBond . Order . SINGLE ) ; mol . addBond ( 4 , 5 , IBond . Order . DOUBLE ) ; mol . addBond ( 5 , 0 , IBond . Order . SINGLE ) ; mol . addBond ( 1 , 6 , IBond . Order . SINGLE ) ; return mol ; } | Returns pyridine oxide without explicit hydrogens . |
28,475 | public Collection < List < IAtom > > findRings ( IAtomContainer molecule ) { if ( molecule == null ) return null ; rings . clear ( ) ; PathGraph graph = new PathGraph ( molecule ) ; for ( int i = 0 ; i < molecule . getAtomCount ( ) ; i ++ ) { List < PathEdge > edges = graph . remove ( molecule . getAtom ( i ) ) ; for ( PathEdge edge : edges ) { List < IAtom > ring = edge . getAtoms ( ) ; rings . add ( ring ) ; } } return rings ; } | Returns a collection of rings . |
28,476 | public IRingSet getRingSet ( IAtomContainer molecule ) throws CDKException { Collection < List < IAtom > > cycles = findRings ( molecule ) ; IRingSet ringSet = molecule . getBuilder ( ) . newInstance ( IRingSet . class ) ; for ( List < IAtom > ringAtoms : cycles ) { IRing ring = molecule . getBuilder ( ) . newInstance ( IRing . class ) ; for ( IAtom atom : ringAtoms ) { atom . setFlag ( CDKConstants . ISINRING , true ) ; ring . addAtom ( atom ) ; for ( IAtom atomNext : ringAtoms ) { if ( ! atom . equals ( atomNext ) ) { IBond bond = molecule . getBond ( atom , atomNext ) ; if ( bond != null ) { bond . setFlag ( CDKConstants . ISINRING , true ) ; ring . addElectronContainer ( bond ) ; } } } } ringSet . addAtomContainer ( ring ) ; } return ringSet ; } | Returns Ring set based on Hanser Ring Finding method |
28,477 | public DescriptorValue calculate ( IAtomContainer container ) { IRingSet rs ; try { AllRingsFinder arf = new AllRingsFinder ( ) ; rs = arf . findAllRings ( container ) ; } catch ( Exception e ) { return getDummyDescriptorValue ( new CDKException ( "Could not find all rings: " + e . getMessage ( ) ) ) ; } String [ ] fragment = new String [ container . getAtomCount ( ) ] ; EStateAtomTypeMatcher eStateMatcher = new EStateAtomTypeMatcher ( ) ; eStateMatcher . setRingSet ( rs ) ; for ( IAtomContainer ring : rs . atomContainers ( ) ) { boolean arom = true ; for ( IBond bond : ring . bonds ( ) ) { if ( ! bond . isAromatic ( ) ) { arom = false ; break ; } } ring . setFlag ( CDKConstants . ISAROMATIC , arom ) ; } for ( int i = 0 ; i < container . getAtomCount ( ) ; i ++ ) { IAtomType atomType = eStateMatcher . findMatchingAtomType ( container , container . getAtom ( i ) ) ; if ( atomType == null ) { fragment [ i ] = null ; } else { fragment [ i ] = atomType . getAtomTypeName ( ) ; } } double [ ] ret = new double [ 0 ] ; try { ret = calculate ( container , fragment , rs ) ; } catch ( CDKException e ) { e . printStackTrace ( ) ; return getDummyDescriptorValue ( new CDKException ( e . getMessage ( ) ) ) ; } DoubleArrayResult results = new DoubleArrayResult ( ) ; results . add ( ret [ 0 ] ) ; results . add ( ret [ 1 ] ) ; results . add ( ret [ 2 ] ) ; return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , results , getDescriptorNames ( ) ) ; } | The AlogP descriptor . |
28,478 | private static boolean processAtomLabels ( final CharIter iter , final Map < Integer , String > dest ) { int atomIdx = 0 ; while ( iter . hasNext ( ) ) { while ( iter . nextIf ( ';' ) ) atomIdx ++ ; char c = iter . next ( ) ; if ( c == '$' ) { iter . nextIf ( ',' ) ; return true ; } else { iter . pos -- ; int beg = iter . pos ; int rollback = beg ; while ( iter . hasNext ( ) ) { if ( iter . pos == beg && iter . curr ( ) == '_' && iter . peek ( ) == 'R' ) { ++ beg ; } if ( iter . curr ( ) == '&' ) { rollback = iter . pos ; if ( iter . nextIf ( '&' ) && iter . nextIf ( '#' ) && iter . nextIfDigit ( ) ) { while ( iter . nextIfDigit ( ) ) { } if ( ! iter . nextIf ( ';' ) ) { iter . pos = rollback ; } else { } } else { iter . pos = rollback ; } } else if ( iter . curr ( ) == ';' ) break ; else if ( iter . curr ( ) == '$' ) break ; else iter . next ( ) ; } dest . put ( atomIdx , unescape ( iter . substr ( beg , iter . pos ) ) ) ; atomIdx ++ ; if ( iter . nextIf ( '$' ) ) { iter . nextIf ( ',' ) ; return true ; } if ( ! iter . nextIf ( ';' ) ) return false ; } } return false ; } | Process atom labels from extended SMILES in a char iter . |
28,479 | private static boolean processPolymerSgroups ( CharIter iter , CxSmilesState state ) { if ( state . sgroups == null ) state . sgroups = new ArrayList < > ( ) ; int beg = iter . pos ; while ( iter . hasNext ( ) && ! isSgroupDelim ( iter . curr ( ) ) ) iter . next ( ) ; final String keyword = iter . substr ( beg , iter . pos ) ; if ( ! iter . nextIf ( ':' ) ) return false ; final List < Integer > atomset = new ArrayList < > ( ) ; if ( ! processIntList ( iter , COMMA_SEPARATOR , atomset ) ) return false ; String subscript ; String supscript ; if ( ! iter . nextIf ( ':' ) ) return false ; beg = iter . pos ; while ( iter . hasNext ( ) && ! isSgroupDelim ( iter . curr ( ) ) ) iter . next ( ) ; subscript = unescape ( iter . substr ( beg , iter . pos ) ) ; if ( subscript . isEmpty ( ) ) subscript = keyword ; if ( ! iter . nextIf ( ':' ) ) return false ; beg = iter . pos ; while ( iter . hasNext ( ) && ! isSgroupDelim ( iter . curr ( ) ) ) iter . next ( ) ; supscript = unescape ( iter . substr ( beg , iter . pos ) ) ; if ( supscript . isEmpty ( ) ) supscript = "eu" ; if ( iter . nextIf ( ',' ) || iter . curr ( ) == '|' ) { state . sgroups . add ( new CxSmilesState . PolymerSgroup ( keyword , atomset , subscript , supscript ) ) ; return true ; } return false ; } | Polymer Sgroups describe variations of repeating units . Only the atoms and not crossing bonds are written . |
28,480 | private static boolean processRadicals ( CharIter iter , CxSmilesState state ) { if ( state . atomRads == null ) state . atomRads = new TreeMap < > ( ) ; CxSmilesState . Radical rad ; switch ( iter . next ( ) ) { case '1' : rad = CxSmilesState . Radical . Monovalent ; break ; case '2' : rad = CxSmilesState . Radical . Divalent ; break ; case '3' : rad = CxSmilesState . Radical . DivalentSinglet ; break ; case '4' : rad = CxSmilesState . Radical . DivalentTriplet ; break ; case '5' : rad = CxSmilesState . Radical . Trivalent ; break ; case '6' : rad = CxSmilesState . Radical . TrivalentDoublet ; break ; case '7' : rad = CxSmilesState . Radical . TrivalentQuartet ; break ; default : return false ; } if ( ! iter . nextIf ( ':' ) ) return false ; List < Integer > dest = new ArrayList < > ( 4 ) ; if ( ! processIntList ( iter , COMMA_SEPARATOR , dest ) ) return false ; for ( Integer atomidx : dest ) state . atomRads . put ( atomidx , rad ) ; return true ; } | CXSMILES radicals . |
28,481 | private static boolean processIntList ( CharIter iter , char sep , List < Integer > dest ) { while ( iter . hasNext ( ) ) { char c = iter . curr ( ) ; if ( isDigit ( c ) ) { int r = processUnsignedInt ( iter ) ; if ( r < 0 ) return false ; iter . nextIf ( sep ) ; dest . add ( r ) ; } else { return true ; } } return false ; } | Process a list of unsigned integers . |
28,482 | public IDescriptorResult getCachedDescriptorValue ( IBond bond ) { if ( cachedDescriptorValues == null ) return null ; return ( IDescriptorResult ) cachedDescriptorValues . get ( bond ) ; } | Returns the cached DescriptorValue for the given IBond . |
28,483 | public void setup ( IReactionSet reactionSet , Rectangle screen ) { this . setScale ( reactionSet ) ; Rectangle2D bounds = BoundsCalculator . calculateBounds ( reactionSet ) ; this . modelCenter = new Point2d ( bounds . getCenterX ( ) , bounds . getCenterY ( ) ) ; this . drawCenter = new Point2d ( screen . getCenterX ( ) , screen . getCenterY ( ) ) ; this . setup ( ) ; } | Setup the transformations necessary to draw this Reaction Set . |
28,484 | public void setScale ( IReactionSet reactionSet ) { double bondLength = AverageBondLengthCalculator . calculateAverageBondLength ( reactionSet ) ; double scale = this . calculateScaleForBondLength ( bondLength ) ; this . rendererModel . getParameter ( Scale . class ) . setValue ( scale ) ; } | Set the scale for an IReactionSet . It calculates the average bond length of the model and calculates the multiplication factor to transform this to the bond length that is set in the RendererModel . |
28,485 | public void paint ( IReactionSet reactionSet , IDrawVisitor drawVisitor , Rectangle2D bounds , boolean resetCenter ) { Rectangle2D totalBounds = BoundsCalculator . calculateBounds ( reactionSet ) ; this . setupTransformToFit ( bounds , totalBounds , AverageBondLengthCalculator . calculateAverageBondLength ( reactionSet ) , resetCenter ) ; ElementGroup diagram = new ElementGroup ( ) ; for ( IReaction reaction : reactionSet . reactions ( ) ) { diagram . add ( reactionRenderer . generateDiagram ( reaction ) ) ; } this . paint ( drawVisitor , diagram ) ; } | Paint a set of reactions . |
28,486 | public static void translate2DCenterTo ( IAtomContainer container , Point2d p ) { Point2d com = get2DCenter ( container ) ; Vector2d translation = new Vector2d ( p . x - com . x , p . y - com . y ) ; for ( IAtom atom : container . atoms ( ) ) { if ( atom . getPoint2d ( ) != null ) { atom . getPoint2d ( ) . add ( translation ) ; } } } | Translates the geometric 2DCenter of the given AtomContainer container to the specified Point2d p . |
28,487 | public static boolean has2DCoordinates ( IReaction reaction ) { for ( IAtomContainer mol : reaction . getReactants ( ) . atomContainers ( ) ) if ( ! has2DCoordinates ( mol ) ) return false ; for ( IAtomContainer mol : reaction . getProducts ( ) . atomContainers ( ) ) if ( ! has2DCoordinates ( mol ) ) return false ; for ( IAtomContainer mol : reaction . getAgents ( ) . atomContainers ( ) ) if ( ! has2DCoordinates ( mol ) ) return false ; return true ; } | Determine if all parts of a reaction have coodinates |
28,488 | public static double getBondLengthRMSD ( IAtomContainer firstAtomContainer , IAtomContainer secondAtomContainer , Map < Integer , Integer > mappedAtoms , boolean Coords3d ) { Iterator < Integer > firstAtoms = mappedAtoms . keySet ( ) . iterator ( ) ; IAtom centerAtomFirstMolecule ; IAtom centerAtomSecondMolecule ; List < IAtom > connectedAtoms ; double sum = 0 ; double n = 0 ; double distance1 = 0 ; double distance2 = 0 ; setVisitedFlagsToFalse ( firstAtomContainer ) ; setVisitedFlagsToFalse ( secondAtomContainer ) ; while ( firstAtoms . hasNext ( ) ) { centerAtomFirstMolecule = firstAtomContainer . getAtom ( firstAtoms . next ( ) ) ; centerAtomFirstMolecule . setFlag ( CDKConstants . VISITED , true ) ; centerAtomSecondMolecule = secondAtomContainer . getAtom ( mappedAtoms . get ( firstAtomContainer . indexOf ( centerAtomFirstMolecule ) ) ) ; connectedAtoms = firstAtomContainer . getConnectedAtomsList ( centerAtomFirstMolecule ) ; for ( int i = 0 ; i < connectedAtoms . size ( ) ; i ++ ) { IAtom conAtom = connectedAtoms . get ( i ) ; if ( ! conAtom . getFlag ( CDKConstants . VISITED ) ) { if ( Coords3d ) { distance1 = centerAtomFirstMolecule . getPoint3d ( ) . distance ( conAtom . getPoint3d ( ) ) ; distance2 = centerAtomSecondMolecule . getPoint3d ( ) . distance ( secondAtomContainer . getAtom ( mappedAtoms . get ( firstAtomContainer . indexOf ( conAtom ) ) ) . getPoint3d ( ) ) ; sum = sum + Math . pow ( ( distance1 - distance2 ) , 2 ) ; n ++ ; } else { distance1 = centerAtomFirstMolecule . getPoint2d ( ) . distance ( conAtom . getPoint2d ( ) ) ; distance2 = centerAtomSecondMolecule . getPoint2d ( ) . distance ( secondAtomContainer . getAtom ( ( mappedAtoms . get ( firstAtomContainer . indexOf ( conAtom ) ) ) ) . getPoint2d ( ) ) ; sum = sum + Math . pow ( ( distance1 - distance2 ) , 2 ) ; n ++ ; } } } } setVisitedFlagsToFalse ( firstAtomContainer ) ; setVisitedFlagsToFalse ( secondAtomContainer ) ; return Math . sqrt ( sum / n ) ; } | Return the RMSD of bonds length between the 2 aligned molecules . |
28,489 | public static double getAngleRMSD ( IAtomContainer firstAtomContainer , IAtomContainer secondAtomContainer , Map < Integer , Integer > mappedAtoms ) { Iterator < Integer > firstAtoms = mappedAtoms . keySet ( ) . iterator ( ) ; IAtom firstAtomfirstAC ; IAtom centerAtomfirstAC ; IAtom firstAtomsecondAC ; IAtom secondAtomsecondAC ; IAtom centerAtomsecondAC ; double angleFirstMolecule ; double angleSecondMolecule ; double sum = 0 ; double n = 0 ; while ( firstAtoms . hasNext ( ) ) { int firstAtomNumber = firstAtoms . next ( ) ; centerAtomfirstAC = firstAtomContainer . getAtom ( firstAtomNumber ) ; List < IAtom > connectedAtoms = firstAtomContainer . getConnectedAtomsList ( centerAtomfirstAC ) ; if ( connectedAtoms . size ( ) > 1 ) { for ( int i = 0 ; i < connectedAtoms . size ( ) - 1 ; i ++ ) { firstAtomfirstAC = connectedAtoms . get ( i ) ; for ( int j = i + 1 ; j < connectedAtoms . size ( ) ; j ++ ) { angleFirstMolecule = getAngle ( centerAtomfirstAC , firstAtomfirstAC , connectedAtoms . get ( j ) ) ; centerAtomsecondAC = secondAtomContainer . getAtom ( mappedAtoms . get ( firstAtomContainer . indexOf ( centerAtomfirstAC ) ) ) ; firstAtomsecondAC = secondAtomContainer . getAtom ( mappedAtoms . get ( firstAtomContainer . indexOf ( firstAtomfirstAC ) ) ) ; secondAtomsecondAC = secondAtomContainer . getAtom ( mappedAtoms . get ( firstAtomContainer . indexOf ( connectedAtoms . get ( j ) ) ) ) ; angleSecondMolecule = getAngle ( centerAtomsecondAC , firstAtomsecondAC , secondAtomsecondAC ) ; sum = sum + Math . pow ( angleFirstMolecule - angleSecondMolecule , 2 ) ; n ++ ; } } } } return Math . sqrt ( sum / n ) ; } | Return the variation of each angle value between the 2 aligned molecules . |
28,490 | public void calculateOverlapsAndReduce ( IAtomContainer molecule1 , IAtomContainer molecule2 , boolean shouldMatchBonds ) throws CDKException { setSource ( molecule1 ) ; setTarget ( molecule2 ) ; setMappings ( new ArrayList < Map < Integer , Integer > > ( ) ) ; if ( ( getSource ( ) . getAtomCount ( ) == 1 ) || ( getTarget ( ) . getAtomCount ( ) == 1 ) ) { List < CDKRMap > overlaps = CDKMCS . checkSingleAtomCases ( getSource ( ) , getTarget ( ) ) ; int nAtomsMatched = overlaps . size ( ) ; nAtomsMatched = ( nAtomsMatched > 0 ) ? 1 : 0 ; if ( nAtomsMatched > 0 ) { identifySingleAtomsMatchedParts ( overlaps , getSource ( ) , getTarget ( ) ) ; } } else { List < List < CDKRMap > > overlaps = CDKMCS . search ( getSource ( ) , getTarget ( ) , new BitSet ( ) , new BitSet ( ) , true , true , shouldMatchBonds ) ; List < List < CDKRMap > > reducedList = removeSubGraph ( overlaps ) ; Stack < List < CDKRMap > > allMaxOverlaps = getAllMaximum ( reducedList ) ; while ( ! allMaxOverlaps . empty ( ) ) { List < List < CDKRMap > > maxOverlapsAtoms = makeAtomsMapOfBondsMap ( allMaxOverlaps . peek ( ) , getSource ( ) , getTarget ( ) ) ; identifyMatchedParts ( maxOverlapsAtoms , getSource ( ) , getTarget ( ) ) ; allMaxOverlaps . pop ( ) ; } } FinalMappings . getInstance ( ) . set ( getMappings ( ) ) ; } | This function calculates all the possible combinations of MCS |
28,491 | public < S extends T > S get ( String name , Class < S > c ) { return ( S ) get ( name ) ; } | Convenience method that allows specification of return ISetting type so that you can nest the call to access the setting value . |
28,492 | public IMatrix getIy ( ) { return ( new IMatrix ( getIplus ( ) . sub ( getIminus ( ) ) ) ) . mul ( new Complex ( 0d , 1d ) ) . mul ( new Complex ( 0.5 , 0d ) ) ; } | Calculates the Iy operator |
28,493 | public IMatrix getIz ( ) { IMatrix Iz = new IMatrix ( size , size ) ; int i , j ; for ( i = 0 ; i < size ; i ++ ) for ( j = 0 ; j < size ; j ++ ) { Iz . realmatrix [ i ] [ j ] = 0d ; Iz . imagmatrix [ i ] [ j ] = 0d ; } for ( i = 0 ; i < size ; i ++ ) { Iz . realmatrix [ i ] [ i ] = J - i ; Iz . imagmatrix [ i ] [ i ] = J - i ; } return Iz ; } | Calculates the Iz operator |
28,494 | public Matrix getIplus ( ) { Matrix Iplus = new Matrix ( size , size ) ; int i , j ; for ( i = 0 ; i < size ; i ++ ) for ( j = 0 ; j < size ; j ++ ) Iplus . matrix [ i ] [ j ] = 0d ; for ( i = 1 ; i < size ; i ++ ) Iplus . matrix [ i - 1 ] [ i ] = Math . sqrt ( J * J + J - ( J - i + 1 ) * ( J - i + 1 ) + ( J - i + 1 ) ) ; return Iplus ; } | Calculates the I + operator |
28,495 | public Matrix getIminus ( ) { Matrix Iminus = new Matrix ( size , size ) ; int i , j ; for ( i = 0 ; i < size ; i ++ ) for ( j = 0 ; j < size ; j ++ ) Iminus . matrix [ i ] [ j ] = 0d ; for ( i = 1 ; i < size ; i ++ ) Iminus . matrix [ i ] [ i - 1 ] = Math . sqrt ( J * J + J - ( J - i ) * ( J - i ) - ( J - i ) ) ; return Iminus ; } | Calculates the I - operator |
28,496 | public Vector getSpinVector ( double theta , double phi ) { Vector spinvector = new Vector ( 3 ) ; spinvector . vector [ 0 ] = Math . sin ( theta ) * Math . cos ( phi ) ; spinvector . vector [ 1 ] = Math . sin ( theta ) * Math . sin ( phi ) ; spinvector . vector [ 2 ] = Math . cos ( phi ) ; return spinvector ; } | Calculates a spin vector by a direction specified by theta and phi |
28,497 | public static void markAromaticRings ( IRing ring ) { for ( IAtom atom : ring . atoms ( ) ) if ( ! atom . getFlag ( CDKConstants . ISAROMATIC ) ) return ; for ( IBond bond : ring . bonds ( ) ) if ( ! bond . getFlag ( CDKConstants . ISAROMATIC ) ) return ; ring . setFlag ( CDKConstants . ISAROMATIC , true ) ; } | Marks the ring aromatic if all atoms and all bonds are aromatic . |
28,498 | public DescriptorValue calculate ( IAtomContainer atomContainer ) { int n = 0 ; for ( IBond bond : atomContainer . bonds ( ) ) { if ( bond . getBegin ( ) . getAtomicNumber ( ) != 1 && bond . getEnd ( ) . getAtomicNumber ( ) != 1 ) { n ++ ; } } double vadjMa = 0 ; if ( n > 0 ) { vadjMa += ( Math . log ( n ) / Math . log ( 2 ) ) + 1 ; } return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( vadjMa ) , getDescriptorNames ( ) ) ; } | calculates the VAdjMa descriptor for an atom container |
28,499 | public List < IAtomType > readAtomTypes ( IChemObjectBuilder builder ) { List < IAtomType > isotopes = new ArrayList < IAtomType > ( ) ; try { parser . setFeature ( "http://xml.org/sax/features/validation" , false ) ; logger . info ( "Deactivated validation" ) ; } catch ( SAXException exception ) { logger . warn ( "Cannot deactivate validation: " , exception . getMessage ( ) ) ; logger . debug ( exception ) ; } AtomTypeHandler handler = new AtomTypeHandler ( builder ) ; parser . setContentHandler ( handler ) ; try { parser . parse ( new InputSource ( input ) ) ; isotopes = handler . getAtomTypes ( ) ; } catch ( IOException exception ) { logger . error ( "IOException: " , exception . getMessage ( ) ) ; logger . debug ( exception ) ; } catch ( SAXException saxe ) { logger . error ( "SAXException: " , saxe . getMessage ( ) ) ; logger . debug ( saxe ) ; } return isotopes ; } | Reads the atom types from the data file . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.