idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
27,900 | private Edge findDirectionalEdge ( Graph g , int u ) { List < Edge > edges = g . edges ( u ) ; if ( edges . size ( ) == 1 ) return null ; Edge first = null ; for ( Edge e : edges ) { Bond b = e . bond ( ) ; if ( b == Bond . UP || b == Bond . DOWN ) { if ( first == null ) first = e ; else if ( ( ( first . either ( ) == e . either ( ) ) == ( first . bond ( ) == b ) ) ) return null ; } } return first ; } | Utility for find the first directional edge incident to a vertex . If there are no directional labels then null is returned . |
27,901 | private IStereoElement newTetrahedral ( int u , int [ ] vs , IAtom [ ] atoms , Configuration c ) { if ( vs . length != 4 ) { if ( vs . length != 3 ) return null ; vs = insert ( u , vs ) ; } Stereo stereo = c == Configuration . TH1 ? Stereo . ANTI_CLOCKWISE : Stereo . CLOCKWISE ; return new TetrahedralChirality ( atoms [ u ] , new IAtom [ ] { atoms [ vs [ 0 ] ] , atoms [ vs [ 1 ] ] , atoms [ vs [ 2 ] ] , atoms [ vs [ 3 ] ] } , stereo ) ; } | Creates a tetrahedral element for the given configuration . Currently only tetrahedral centres with 4 explicit atoms are handled . |
27,902 | private static int [ ] insert ( int v , int [ ] vs ) { final int n = vs . length ; final int [ ] ws = Arrays . copyOf ( vs , n + 1 ) ; ws [ n ] = v ; for ( int i = n ; i > 0 && ws [ i ] < ws [ i - 1 ] ; i -- ) { int tmp = ws [ i ] ; ws [ i ] = ws [ i - 1 ] ; ws [ i - 1 ] = tmp ; } return ws ; } | Insert the vertex v into sorted position in the array vs . |
27,903 | private IAtom createAtom ( Element element ) { IAtom atom = builder . newAtom ( ) ; atom . setSymbol ( element . symbol ( ) ) ; atom . setAtomicNumber ( element . atomicNumber ( ) ) ; return atom ; } | Create a new atom for the provided symbol . The atom is created by cloning an existing template . Unfortunately IChemObjectBuilders really show a slow down when SMILES processing . |
27,904 | public void saturate ( IAtomContainer atomContainer ) throws CDKException { logger . info ( "Saturating atomContainer by adjusting bond orders..." ) ; boolean allSaturated = allSaturated ( atomContainer ) ; if ( ! allSaturated ) { logger . info ( "Saturating bond orders is needed..." ) ; IBond [ ] bonds = new IBond [ atomContainer . getBondCount ( ) ] ; for ( int i = 0 ; i < bonds . length ; i ++ ) bonds [ i ] = atomContainer . getBond ( i ) ; boolean succeeded = saturate ( bonds , atomContainer ) ; if ( ! succeeded ) { throw new CDKException ( "Could not saturate this atomContainer!" ) ; } } } | Saturates a molecule by setting appropriate bond orders . |
27,905 | public boolean saturate ( IBond [ ] bonds , IAtomContainer atomContainer ) throws CDKException { logger . debug ( "Saturating bond set of size: " , bonds . length ) ; boolean bondsAreFullySaturated = false ; if ( bonds . length > 0 ) { IBond bond = bonds [ 0 ] ; int leftBondCount = bonds . length - 1 ; IBond [ ] leftBonds = new IBond [ leftBondCount ] ; System . arraycopy ( bonds , 1 , leftBonds , 0 , leftBondCount ) ; logger . debug ( "Examining this bond: " , bond ) ; if ( isSaturated ( bond , atomContainer ) ) { logger . debug ( "OK, bond is saturated, now try to saturate remaining bonds (if needed)" ) ; bondsAreFullySaturated = saturate ( leftBonds , atomContainer ) ; } else if ( isUnsaturated ( bond , atomContainer ) ) { logger . debug ( "Ok, this bond is unsaturated, and can be saturated" ) ; logger . debug ( "Option 1: Saturating this bond directly, then trying to saturate rest" ) ; boolean bondOrderIncreased = saturateByIncreasingBondOrder ( bond , atomContainer ) ; bondsAreFullySaturated = bondOrderIncreased && saturate ( bonds , atomContainer ) ; if ( bondsAreFullySaturated ) { logger . debug ( "Option 1: worked" ) ; } else { logger . debug ( "Option 1: failed. Trying option 2." ) ; logger . debug ( "Option 2: Saturing this bond by saturating the rest" ) ; if ( bondOrderIncreased ) unsaturateByDecreasingBondOrder ( bond ) ; bondsAreFullySaturated = saturate ( leftBonds , atomContainer ) && isSaturated ( bond , atomContainer ) ; if ( ! bondsAreFullySaturated ) logger . debug ( "Option 2: failed" ) ; } } else { logger . debug ( "Ok, this bond is unsaturated, but cannot be saturated" ) ; bondsAreFullySaturated = saturate ( leftBonds , atomContainer ) && isSaturated ( bond , atomContainer ) ; } } else { bondsAreFullySaturated = true ; } return bondsAreFullySaturated ; } | Saturates a set of Bonds in an AtomContainer . |
27,906 | public boolean saturateByIncreasingBondOrder ( IBond bond , IAtomContainer atomContainer ) throws CDKException { IAtom [ ] atoms = BondManipulator . getAtomArray ( bond ) ; IAtom atom = atoms [ 0 ] ; IAtom partner = atoms [ 1 ] ; logger . debug ( " saturating bond: " , atom . getSymbol ( ) , "-" , partner . getSymbol ( ) ) ; IAtomType [ ] atomTypes1 = getAtomTypeFactory ( bond . getBuilder ( ) ) . getAtomTypes ( atom . getSymbol ( ) ) ; IAtomType [ ] atomTypes2 = getAtomTypeFactory ( bond . getBuilder ( ) ) . getAtomTypes ( partner . getSymbol ( ) ) ; for ( int atCounter1 = 0 ; atCounter1 < atomTypes1 . length ; atCounter1 ++ ) { IAtomType aType1 = atomTypes1 [ atCounter1 ] ; logger . debug ( " condidering atom type: " , aType1 ) ; if ( couldMatchAtomType ( atomContainer , atom , aType1 ) ) { logger . debug ( " trying atom type: " , aType1 ) ; for ( int atCounter2 = 0 ; atCounter2 < atomTypes2 . length ; atCounter2 ++ ) { IAtomType aType2 = atomTypes2 [ atCounter2 ] ; logger . debug ( " condidering partner type: " , aType1 ) ; if ( couldMatchAtomType ( atomContainer , partner , atomTypes2 [ atCounter2 ] ) ) { logger . debug ( " with atom type: " , aType2 ) ; if ( BondManipulator . isLowerOrder ( bond . getOrder ( ) , aType2 . getMaxBondOrder ( ) ) && BondManipulator . isLowerOrder ( bond . getOrder ( ) , aType1 . getMaxBondOrder ( ) ) ) { bond . setOrder ( BondManipulator . increaseBondOrder ( bond . getOrder ( ) ) ) ; logger . debug ( "Bond order now " , bond . getOrder ( ) ) ; return true ; } } } } } return false ; } | Tries to saturate a bond by increasing its bond orders by 1 . 0 . |
27,907 | public boolean couldMatchAtomType ( IAtom atom , double bondOrderSum , IBond . Order maxBondOrder , IAtomType type ) { logger . debug ( "couldMatchAtomType: ... matching atom " , atom , " vs " , type ) ; int hcount = atom . getImplicitHydrogenCount ( ) ; int charge = atom . getFormalCharge ( ) ; if ( charge == type . getFormalCharge ( ) ) { logger . debug ( "couldMatchAtomType: formal charge matches..." ) ; if ( bondOrderSum + hcount <= type . getBondOrderSum ( ) ) { logger . debug ( "couldMatchAtomType: bond order sum is OK..." ) ; if ( ! BondManipulator . isHigherOrder ( maxBondOrder , type . getMaxBondOrder ( ) ) ) { logger . debug ( "couldMatchAtomType: max bond order is OK... We have a match!" ) ; return true ; } } else { logger . debug ( "couldMatchAtomType: no match" , "" + ( bondOrderSum + hcount ) , " > " , "" + type . getBondOrderSum ( ) ) ; } } else { logger . debug ( "couldMatchAtomType: formal charge does NOT match..." ) ; } logger . debug ( "couldMatchAtomType: No Match" ) ; return false ; } | Determines if the atom can be of type AtomType . That is it sees if this AtomType only differs in bond orders or implicit hydrogen count . |
27,908 | public int calculateNumberOfImplicitHydrogens ( IAtom atom , double bondOrderSum , IBond . Order maxBondOrder , int neighbourCount ) throws CDKException { int missingHydrogens = 0 ; if ( atom instanceof IPseudoAtom ) { logger . debug ( "don't figure it out... it simply does not lack H's" ) ; return 0 ; } logger . debug ( "Calculating number of missing hydrogen atoms" ) ; IAtomType [ ] atomTypes = getAtomTypeFactory ( atom . getBuilder ( ) ) . getAtomTypes ( atom . getSymbol ( ) ) ; if ( atomTypes . length == 0 ) { logger . warn ( "Element not found in configuration file: " , atom ) ; return 0 ; } logger . debug ( "Found atomtypes: " , atomTypes . length ) ; for ( int f = 0 ; f < atomTypes . length ; f ++ ) { IAtomType type = atomTypes [ f ] ; if ( couldMatchAtomType ( atom , bondOrderSum , maxBondOrder , type ) ) { logger . debug ( "This type matches: " , type ) ; int formalNeighbourCount = type . getFormalNeighbourCount ( ) ; if ( type . getHybridization ( ) == CDKConstants . UNSET ) { missingHydrogens = ( int ) ( type . getBondOrderSum ( ) - bondOrderSum ) ; } else if ( type . getHybridization ( ) == Hybridization . SP3 ) { missingHydrogens = formalNeighbourCount - neighbourCount ; } else if ( type . getHybridization ( ) == Hybridization . SP2 ) { missingHydrogens = formalNeighbourCount - neighbourCount ; } else if ( type . getHybridization ( ) == Hybridization . SP1 ) { missingHydrogens = formalNeighbourCount - neighbourCount ; } else { missingHydrogens = ( int ) ( type . getBondOrderSum ( ) - bondOrderSum ) ; } break ; } } logger . debug ( "missing hydrogens: " , missingHydrogens ) ; return missingHydrogens ; } | Calculates the number of hydrogens that can be added to the given atom to fullfil the atom s valency . It will return 0 for PseudoAtoms and for atoms for which it does not have an entry in the configuration file . |
27,909 | public boolean isSaturated ( IAtom atom , IAtomContainer container ) throws CDKException { if ( atom instanceof IPseudoAtom ) { logger . debug ( "don't figure it out... it simply does not lack H's" ) ; return true ; } IAtomType [ ] atomTypes = getAtomTypeFactory ( atom . getBuilder ( ) ) . getAtomTypes ( atom . getSymbol ( ) ) ; if ( atomTypes . length == 0 ) { logger . warn ( "Missing entry in atom type list for " , atom . getSymbol ( ) ) ; return true ; } double bondOrderSum = container . getBondOrderSum ( atom ) ; IBond . Order maxBondOrder = container . getMaximumBondOrder ( atom ) ; int hcount = atom . getImplicitHydrogenCount ( ) ; int charge = atom . getFormalCharge ( ) ; logger . debug ( "Checking saturation of atom " , atom . getSymbol ( ) ) ; logger . debug ( "bondOrderSum: " , bondOrderSum ) ; logger . debug ( "maxBondOrder: " , maxBondOrder ) ; logger . debug ( "hcount: " , hcount ) ; logger . debug ( "charge: " , charge ) ; boolean elementPlusChargeMatches = false ; for ( int f = 0 ; f < atomTypes . length ; f ++ ) { IAtomType type = atomTypes [ f ] ; if ( couldMatchAtomType ( atom , bondOrderSum , maxBondOrder , type ) ) { if ( bondOrderSum + hcount == type . getBondOrderSum ( ) && ! BondManipulator . isHigherOrder ( maxBondOrder , type . getMaxBondOrder ( ) ) ) { logger . debug ( "We have a match: " , type ) ; logger . debug ( "Atom is saturated: " , atom . getSymbol ( ) ) ; return true ; } else { elementPlusChargeMatches = true ; } } } if ( elementPlusChargeMatches ) { logger . debug ( "No, atom is not saturated." ) ; return false ; } logger . error ( "Could not find atom type!" ) ; throw new CDKException ( "The atom with element " + atom . getSymbol ( ) + " and charge " + charge + " is not found." ) ; } | Checks whether an Atom is saturated by comparing it with known AtomTypes . It returns true if the atom is an PseudoAtom and when the element is not in the list . |
27,910 | private static boolean familyHalogen ( IAtom atom ) { String symbol = atom . getSymbol ( ) ; if ( symbol . equals ( "F" ) || symbol . equals ( "Cl" ) || symbol . equals ( "Br" ) || symbol . equals ( "I" ) ) return true ; else return false ; } | Looking if the IAtom belongs to the halogen family . The IAtoms are F Cl Br I . |
27,911 | private static boolean familyBond ( IAtomContainer container , IBond bond ) { List < String > normalAt = new ArrayList < String > ( ) ; normalAt . add ( "C" ) ; normalAt . add ( "H" ) ; if ( getDoubleBondNumber ( container ) > 30 ) return false ; StructureResonanceGenerator gRN = new StructureResonanceGenerator ( ) ; IAtomContainer ac = gRN . getContainer ( container , bond ) ; if ( ac == null ) return true ; if ( getDoubleBondNumber ( ac ) > 15 ) return false ; for ( IAtom atom : container . atoms ( ) ) { if ( ! normalAt . contains ( atom . getSymbol ( ) ) ) if ( ac . contains ( atom ) ) return false ; } return true ; } | Looking if the Bond belongs to the bond family . Not in resosance with other heteroatoms . |
27,912 | private static int getDoubleBondNumber ( IAtomContainer container ) { int doubleNumber = 0 ; for ( IBond bond : container . bonds ( ) ) { if ( bond . getOrder ( ) . equals ( IBond . Order . DOUBLE ) || bond . getOrder ( ) . equals ( IBond . Order . TRIPLE ) ) doubleNumber ++ ; } return doubleNumber ; } | Extract the number of bond with superior ordre . |
27,913 | private static double getDTBondF ( double [ ] resultsH ) { double result = 0.0 ; double SE = resultsH [ 0 ] ; double PE = resultsH [ 1 ] ; double PSC = resultsH [ 2 ] ; double PIC = resultsH [ 3 ] ; double ETP = resultsH [ 4 ] ; double COUNTR = resultsH [ 6 ] ; result = 0.1691 * SE + 1.1536 * PE + - 6.3049 * PSC + - 15.2638 * PIC + - 0.2456 * ETP + - 0.0139 * COUNTR + 2.114 ; return result ; } | Get the desicion - tree result for the Halogen family given a series of values . It is based in 6 qsar descriptors . |
27,914 | private static IAtomContainer initiateIonization ( IAtomContainer container , IAtom atom ) throws CDKException { IReactionProcess reactionNBE = new ElectronImpactNBEReaction ( ) ; IAtomContainerSet setOfReactants = container . getBuilder ( ) . newInstance ( IAtomContainerSet . class ) ; setOfReactants . addAtomContainer ( container ) ; atom . setFlag ( CDKConstants . REACTIVE_CENTER , true ) ; List < IParameterReact > paramList = new ArrayList < IParameterReact > ( ) ; IParameterReact param = new SetReactionCenter ( ) ; param . setParameter ( Boolean . TRUE ) ; paramList . add ( param ) ; reactionNBE . setParameterList ( paramList ) ; IReactionSet setOfReactions = reactionNBE . initiate ( setOfReactants , null ) ; atom . setFlag ( CDKConstants . REACTIVE_CENTER , false ) ; if ( setOfReactions != null && setOfReactions . getReactionCount ( ) == 1 && setOfReactions . getReaction ( 0 ) . getProducts ( ) . getAtomContainerCount ( ) == 1 ) return setOfReactions . getReaction ( 0 ) . getProducts ( ) . getAtomContainer ( 0 ) ; else return null ; } | Initiate the reaction ElectronImpactNBE . |
27,915 | public Iterable < IReaction > reactions ( ) { return new Iterable < IReaction > ( ) { public Iterator < IReaction > iterator ( ) { return new ReactionIterator ( ) ; } } ; } | Get an iterator for this reaction set . |
27,916 | private void growReactionArray ( ) { growArraySize = reactions . length ; IReaction [ ] newreactions = new IReaction [ reactions . length + growArraySize ] ; System . arraycopy ( reactions , 0 , newreactions , 0 , reactions . length ) ; reactions = newreactions ; } | Grows the reaction array by a given size . |
27,917 | public static IAtom [ ] findTerminalAtoms ( IAtomContainer container , IAtom focus ) { List < IBond > focusBonds = container . getConnectedBondsList ( focus ) ; if ( focusBonds . size ( ) != 2 ) throw new IllegalArgumentException ( "focus must have exactly 2 neighbors" ) ; IAtom leftPrev = focus ; IAtom rightPrev = focus ; IAtom left = focusBonds . get ( 0 ) . getOther ( focus ) ; IAtom right = focusBonds . get ( 1 ) . getOther ( focus ) ; IAtom tmp ; while ( left != null && right != null ) { tmp = getOtherNbr ( container , left , leftPrev ) ; leftPrev = left ; left = tmp ; tmp = getOtherNbr ( container , right , rightPrev ) ; rightPrev = right ; right = tmp ; } return new IAtom [ ] { leftPrev , rightPrev } ; } | Helper method to locate two terminal atoms in a container for a given focus . |
27,918 | public IAtom [ ] findTerminalAtoms ( IAtomContainer container ) { IAtom [ ] atoms = findTerminalAtoms ( container , getFocus ( ) ) ; List < IAtom > carriers = getCarriers ( ) ; if ( container . getBond ( atoms [ 0 ] , carriers . get ( 2 ) ) != null || container . getBond ( atoms [ 0 ] , carriers . get ( 3 ) ) != null ) { IAtom tmp = atoms [ 0 ] ; atoms [ 0 ] = atoms [ 1 ] ; atoms [ 1 ] = tmp ; } return atoms ; } | Helper method to locate two terminal atoms in a container for this extended tetrahedral element . The atoms are ordered such that the first index is attached to the first two peripheral atoms and the second index is attached to the second two peripheral atoms . |
27,919 | public void setParameters ( Object [ ] params ) throws CDKException { if ( params . length != 1 ) throw new CDKException ( "One parameter expected" ) ; if ( ! ( params [ 0 ] instanceof Boolean ) ) throw new CDKException ( "Boolean parameter expected" ) ; addlp = ( Boolean ) params [ 0 ] ; } | Sets the parameters attribute of the IPMolecularLearningDescriptor object |
27,920 | public DescriptorValue calculate ( IAtomContainer atomContainer ) { IAtomContainer local ; if ( addlp ) { try { local = ( IAtomContainer ) atomContainer . clone ( ) ; LonePairElectronChecker lpcheck = new LonePairElectronChecker ( ) ; lpcheck . saturate ( local ) ; } catch ( CloneNotSupportedException e ) { return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( Double . NaN ) , getDescriptorNames ( ) , e ) ; } catch ( CDKException e ) { return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( Double . NaN ) , getDescriptorNames ( ) , e ) ; } } else local = atomContainer ; DoubleResult value ; try { value = new DoubleResult ( ( ( DoubleArrayResult ) calculatePlus ( local ) . getValue ( ) ) . get ( 0 ) ) ; } catch ( CDKException e ) { return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( Double . NaN ) , getDescriptorNames ( ) , e ) ; } return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , value , getDescriptorNames ( ) ) ; } | It calculates the first ionization energy of a molecule . |
27,921 | public DescriptorValue calculatePlus ( IAtomContainer container ) throws CDKException { ArrayList < Double > dar = new ArrayList < Double > ( ) ; for ( Iterator < IAtom > itA = container . atoms ( ) . iterator ( ) ; itA . hasNext ( ) ; ) { IAtom atom = itA . next ( ) ; double value = IonizationPotentialTool . predictIP ( container , atom ) ; if ( value != 0 ) dar . add ( value ) ; } for ( Iterator < IBond > itB = container . bonds ( ) . iterator ( ) ; itB . hasNext ( ) ; ) { IBond bond = itB . next ( ) ; if ( bond . getOrder ( ) == IBond . Order . DOUBLE & bond . getBegin ( ) . getSymbol ( ) . equals ( "C" ) & bond . getEnd ( ) . getSymbol ( ) . equals ( "C" ) ) { double value = IonizationPotentialTool . predictIP ( container , bond ) ; if ( value != 0 ) dar . add ( value ) ; } } DoubleArrayResult results = arrangingEnergy ( dar ) ; return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , results , getDescriptorNames ( ) , null ) ; } | It calculates the 1 2 .. ionization energies of a molecule . |
27,922 | private DoubleArrayResult arrangingEnergy ( ArrayList < Double > array ) { DoubleArrayResult results = new DoubleArrayResult ( ) ; int count = array . size ( ) ; for ( int i = 0 ; i < count ; i ++ ) { double min = array . get ( 0 ) ; int pos = 0 ; for ( int j = 0 ; j < array . size ( ) ; j ++ ) { double value = array . get ( j ) ; if ( value < min ) { min = value ; pos = j ; } } array . remove ( pos ) ; results . add ( min ) ; } return results ; } | put in increasing order the ArrayList |
27,923 | public boolean compare ( Object object ) { if ( ! ( object instanceof Isotope ) ) { return false ; } if ( ! super . compare ( object ) ) { return false ; } Isotope isotope = ( Isotope ) object ; if ( isotope . getMassNumber ( ) != null && massNumber != null && isotope . getMassNumber ( ) . intValue ( ) != this . getMassNumber ( ) . intValue ( ) ) return false ; if ( isotope . getMassNumber ( ) == null && massNumber != null ) return false ; if ( isotope . getExactMass ( ) != null && exactMass != null ) { double diff = Math . abs ( isotope . getExactMass ( ) . doubleValue ( ) - this . getExactMass ( ) . doubleValue ( ) ) ; if ( diff > 0.0000001 ) return false ; } if ( isotope . getExactMass ( ) == null && exactMass != null ) return false ; if ( isotope . getNaturalAbundance ( ) != null && naturalAbundance != null ) { double diff = Math . abs ( isotope . getNaturalAbundance ( ) . doubleValue ( ) - this . getNaturalAbundance ( ) . doubleValue ( ) ) ; if ( diff > 0.0000001 ) return false ; } if ( isotope . getNaturalAbundance ( ) == null && naturalAbundance != null ) return false ; return true ; } | Compares an isotope with this isotope . |
27,924 | public DescriptorValue calculate ( IAtomContainer container ) { IAtomContainer local = AtomContainerManipulator . removeHydrogens ( container ) ; int natom = local . getAtomCount ( ) ; int [ ] [ ] admat = AdjacencyMatrix . getMatrix ( local ) ; int [ ] [ ] distmat = PathTools . computeFloydAPSP ( admat ) ; int eccenindex = 0 ; for ( int i = 0 ; i < natom ; i ++ ) { int max = - 1 ; for ( int j = 0 ; j < natom ; j ++ ) { if ( distmat [ i ] [ j ] > max ) max = distmat [ i ] [ j ] ; } int degree = local . getConnectedBondsCount ( i ) ; eccenindex += max * degree ; } IntegerResult retval = new IntegerResult ( eccenindex ) ; return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , retval , getDescriptorNames ( ) , null ) ; } | Calculates the eccentric connectivity |
27,925 | public static int randomInt ( int lo , int hi ) { return ( Math . abs ( random . nextInt ( ) ) % ( hi - lo + 1 ) ) + lo ; } | Generates a random integer between the specified values . |
27,926 | private static long nextLong ( Random rng , long n ) { if ( n <= 0 ) throw new IllegalArgumentException ( "n must be greater than 0" ) ; long bits , val ; do { bits = ( rng . nextLong ( ) << 1 ) >>> 1 ; val = bits % n ; } while ( bits - val + ( n - 1 ) < 0L ) ; return val ; } | Access the next long random number between 0 and n . |
27,927 | public static int markRingAtomsAndBonds ( IAtomContainer mol ) { EdgeToBondMap bonds = EdgeToBondMap . withSpaceFor ( mol ) ; return markRingAtomsAndBonds ( mol , GraphUtil . toAdjList ( mol , bonds ) , bonds ) ; } | Find and mark all cyclic atoms and bonds in the provided molecule . |
27,928 | public static int markRingAtomsAndBonds ( IAtomContainer mol , int [ ] [ ] adjList , EdgeToBondMap bondMap ) { RingSearch ringSearch = new RingSearch ( mol , adjList ) ; for ( int v = 0 ; v < mol . getAtomCount ( ) ; v ++ ) { mol . getAtom ( v ) . setIsInRing ( false ) ; for ( int w : adjList [ v ] ) { if ( v > w && ringSearch . cyclic ( v , w ) ) { bondMap . get ( v , w ) . setIsInRing ( true ) ; mol . getAtom ( v ) . setIsInRing ( true ) ; mol . getAtom ( w ) . setIsInRing ( true ) ; } else { bondMap . get ( v , w ) . setIsInRing ( false ) ; } } } return ringSearch . numRings ( ) ; } | Find and mark all cyclic atoms and bonds in the provided molecule . This optimised version allows the caller to optionally provided indexed fast access structure which would otherwise be created . |
27,929 | public static Cycles all ( IAtomContainer container , int length ) throws Intractable { return all ( ) . find ( container , length ) ; } | All cycles of smaller than or equal to the specified length . |
27,930 | private static int [ ] lift ( int [ ] path , int [ ] mapping ) { for ( int i = 0 ; i < path . length ; i ++ ) { path [ i ] = mapping [ path [ i ] ] ; } return path ; } | Internal - lifts a path in a subgraph back to the original graph . |
27,931 | private static IRingSet toRingSet ( IAtomContainer container , int [ ] [ ] cycles , EdgeToBondMap bondMap ) { IChemObjectBuilder builder = container . getBuilder ( ) ; IRingSet rings = builder . newInstance ( IRingSet . class ) ; for ( int [ ] cycle : cycles ) { rings . addAtomContainer ( toRing ( container , cycle , bondMap ) ) ; } return rings ; } | Internal - convert a set of cycles to an ring set . |
27,932 | private static IRing toRing ( IAtomContainer container , int [ ] cycle , EdgeToBondMap bondMap ) { IAtom [ ] atoms = new IAtom [ cycle . length - 1 ] ; IBond [ ] bonds = new IBond [ cycle . length - 1 ] ; for ( int i = 1 ; i < cycle . length ; i ++ ) { int v = cycle [ i ] ; int u = cycle [ i - 1 ] ; atoms [ i - 1 ] = container . getAtom ( u ) ; bonds [ i - 1 ] = getBond ( container , bondMap , u , v ) ; } IChemObjectBuilder builder = container . getBuilder ( ) ; IAtomContainer ring = builder . newInstance ( IAtomContainer . class , 0 , 0 , 0 , 0 ) ; ring . setAtoms ( atoms ) ; ring . setBonds ( bonds ) ; return builder . newInstance ( IRing . class , ring ) ; } | Internal - convert a set of cycles to a ring . |
27,933 | private static IBond getBond ( IAtomContainer container , EdgeToBondMap bondMap , int u , int v ) { if ( bondMap != null ) return bondMap . get ( u , v ) ; return container . getBond ( container . getAtom ( u ) , container . getAtom ( v ) ) ; } | Obtain the bond between the atoms at index u and v . If the bondMap is non - null it is used for direct lookup otherwise the slower linear lookup in container is used . |
27,934 | public List < IAtomType > readAtomTypes ( IChemObjectBuilder builder ) throws IOException { List < IAtomType > atomTypes = new ArrayList < IAtomType > ( ) ; if ( ins == null ) { ins = this . getClass ( ) . getClassLoader ( ) . getResourceAsStream ( configFile ) ; } if ( ins == null ) throw new IOException ( "There was a problem getting the default stream: " + configFile ) ; BufferedReader reader = new BufferedReader ( new InputStreamReader ( ins ) , 1024 ) ; StringTokenizer tokenizer ; String string ; while ( true ) { string = reader . readLine ( ) ; if ( string == null ) { break ; } if ( ! string . startsWith ( "#" ) ) { String name ; String rootType ; int atomicNumber , colorR , colorG , colorB ; double mass , covalent ; tokenizer = new StringTokenizer ( string , "\t ,;" ) ; int tokenCount = tokenizer . countTokens ( ) ; if ( tokenCount == 9 ) { name = tokenizer . nextToken ( ) ; rootType = tokenizer . nextToken ( ) ; String san = tokenizer . nextToken ( ) ; String sam = tokenizer . nextToken ( ) ; tokenizer . nextToken ( ) ; String scovalent = tokenizer . nextToken ( ) ; String sColorR = tokenizer . nextToken ( ) ; String sColorG = tokenizer . nextToken ( ) ; String sColorB = tokenizer . nextToken ( ) ; try { mass = new Double ( sam ) ; covalent = new Double ( scovalent ) ; atomicNumber = Integer . parseInt ( san ) ; colorR = Integer . parseInt ( sColorR ) ; colorG = Integer . parseInt ( sColorG ) ; colorB = Integer . parseInt ( sColorB ) ; } catch ( NumberFormatException nfe ) { throw new IOException ( "AtomTypeTable.ReadAtypes: " + "Malformed Number" ) ; } IAtomType atomType = builder . newInstance ( IAtomType . class , name , rootType ) ; atomType . setAtomicNumber ( atomicNumber ) ; atomType . setExactMass ( mass ) ; atomType . setCovalentRadius ( covalent ) ; atomType . setProperty ( "org.openscience.cdk.renderer.color" , ( ( colorR << 16 ) & 0xff0000 ) | ( ( colorG << 8 ) & 0x00ff00 ) | ( colorB & 0x0000ff ) ) ; atomTypes . add ( atomType ) ; } else { throw new IOException ( "AtomTypeTable.ReadAtypes: " + "Wrong Number of fields" ) ; } } } ins . close ( ) ; return atomTypes ; } | Reads a text based configuration file . |
27,935 | public static List < IChemObject > getAllChemObjects ( IAtomContainerSet set ) { ArrayList < IChemObject > list = new ArrayList < IChemObject > ( ) ; list . add ( set ) ; for ( IAtomContainer atomContainer : set . atomContainers ( ) ) { list . add ( atomContainer ) ; } return list ; } | Does not recursively return the contents of the AtomContainer . |
27,936 | public DescriptorValue calculate ( IAtom first , IAtom second , IAtomContainer atomContainer ) { IAtomContainer ac ; try { ac = ( IAtomContainer ) atomContainer . clone ( ) ; } catch ( CloneNotSupportedException e ) { return getDummyDescriptorValue ( e ) ; } IAtom clonedFirst = ac . getAtom ( atomContainer . indexOf ( first ) ) ; IAtom clonedSecond = ac . getAtom ( atomContainer . indexOf ( first ) ) ; IAtomContainer mol = ac . getBuilder ( ) . newInstance ( IAtomContainer . class , ac ) ; if ( checkAromaticity ) { try { AtomContainerManipulator . percieveAtomTypesAndConfigureAtoms ( mol ) ; Aromaticity . cdkLegacy ( ) . apply ( mol ) ; } catch ( CDKException e ) { return getDummyDescriptorValue ( e ) ; } } boolean piContact = false ; int counter = 0 ; if ( acold != ac ) { acold = ac ; acSet = ConjugatedPiSystemsDetector . detect ( mol ) ; } java . util . Iterator < IAtomContainer > detected = acSet . atomContainers ( ) . iterator ( ) ; List < IAtom > neighboorsFirst = mol . getConnectedAtomsList ( clonedFirst ) ; List < IAtom > neighboorsSecond = mol . getConnectedAtomsList ( clonedSecond ) ; while ( detected . hasNext ( ) ) { IAtomContainer detectedAC = detected . next ( ) ; if ( detectedAC . contains ( clonedFirst ) && detectedAC . contains ( clonedSecond ) ) { counter += 1 ; break ; } if ( isANeighboorsInAnAtomContainer ( neighboorsFirst , detectedAC ) && isANeighboorsInAnAtomContainer ( neighboorsSecond , detectedAC ) ) { counter += 1 ; break ; } } if ( counter > 0 ) { piContact = true ; } return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new BooleanResult ( piContact ) , getDescriptorNames ( ) ) ; } | The method returns if two atoms have pi - contact . |
27,937 | private boolean isANeighboorsInAnAtomContainer ( List < IAtom > neighs , IAtomContainer ac ) { boolean isIn = false ; int count = 0 ; for ( IAtom neigh : neighs ) { if ( ac . contains ( neigh ) ) { count += 1 ; } } if ( count > 0 ) { isIn = true ; } return isIn ; } | Gets if neighbours of an atom are in an atom container . |
27,938 | public void initializeGrid ( double value ) { for ( int i = 0 ; i < grid . length ; i ++ ) { for ( int j = 0 ; j < grid [ 0 ] . length ; j ++ ) { for ( int k = 0 ; k < grid [ 0 ] [ 0 ] . length ; k ++ ) { grid [ k ] [ j ] [ i ] = value ; } } } } | Method initialise the given grid points with a value . |
27,939 | public double [ ] gridToGridArray ( double [ ] [ ] [ ] grid ) { if ( grid == null ) { grid = this . grid ; } gridArray = new double [ dim [ 0 ] * dim [ 1 ] * dim [ 2 ] + 3 ] ; int dimCounter = 0 ; for ( int z = 0 ; z < grid [ 0 ] [ 0 ] . length ; z ++ ) { for ( int y = 0 ; y < grid [ 0 ] . length ; y ++ ) { for ( int x = 0 ; x < grid . length ; x ++ ) { gridArray [ dimCounter ] = grid [ x ] [ y ] [ z ] ; dimCounter ++ ; } } } return gridArray ; } | Method transforms the grid to an array . |
27,940 | public Point3d getCoordinatesFromGridPoint ( Point3d gridPoint ) { double dx = minx + latticeConstant * gridPoint . x ; double dy = miny + latticeConstant * gridPoint . y ; double dz = minz + latticeConstant * gridPoint . z ; return new Point3d ( dx , dy , dz ) ; } | Method calculates coordinates from a given grid point . |
27,941 | public Point3d getCoordinatesFromGridPoint ( int gridPoint ) { int dimCounter = 0 ; Point3d point = new Point3d ( 0 , 0 , 0 ) ; for ( int z = 0 ; z < grid [ 0 ] [ 0 ] . length ; z ++ ) { for ( int y = 0 ; y < grid [ 0 ] . length ; y ++ ) { for ( int x = 0 ; x < grid . length ; x ++ ) { if ( dimCounter == gridPoint ) { point . x = minx + latticeConstant * x ; point . y = miny + latticeConstant * y ; point . z = minz + latticeConstant * z ; return point ; } dimCounter ++ ; } } } return point ; } | Method calculates coordinates from a given grid array position . |
27,942 | public Point3d getGridPointFrom3dCoordinates ( Point3d coord ) throws Exception { Point3d gridPoint = new Point3d ( ) ; if ( coord . x >= minx & coord . x <= maxx ) { gridPoint . x = ( int ) Math . round ( Math . abs ( minx - coord . x ) / latticeConstant ) ; } else { throw new Exception ( "CDKGridError: Given coordinates are not in grid" ) ; } if ( coord . y >= miny & coord . y <= maxy ) { gridPoint . y = ( int ) Math . round ( Math . abs ( miny - coord . y ) / latticeConstant ) ; } else { throw new Exception ( "CDKGridError: Given coordinates are not in grid" ) ; } if ( coord . z >= minz & coord . z <= maxz ) { gridPoint . z = ( int ) Math . round ( Math . abs ( minz - coord . z ) / latticeConstant ) ; } else { throw new Exception ( "CDKGridError: Given coordinates are not in grid" ) ; } return gridPoint ; } | Method calculates the nearest grid point from given coordinates . |
27,943 | public void writeGridInPmeshFormat ( String outPutFileName ) throws IOException { BufferedWriter writer = new BufferedWriter ( new FileWriter ( outPutFileName + ".pmesh" ) ) ; int numberOfGridPoints = grid . length * grid [ 0 ] . length * grid [ 0 ] [ 0 ] . length ; writer . write ( numberOfGridPoints + "\n" ) ; for ( int z = 0 ; z < grid [ 0 ] [ 0 ] . length ; z ++ ) { for ( int y = 0 ; y < grid [ 0 ] . length ; y ++ ) { for ( int x = 0 ; x < grid . length ; x ++ ) { Point3d coords = getCoordinatesFromGridPoint ( new Point3d ( x , y , z ) ) ; writer . write ( coords . x + "\t" + coords . y + "\t" + coords . z + "\n" ) ; } } } writer . close ( ) ; } | Method transforms the grid into pmesh format . |
27,944 | public StereoEncoder create ( IAtomContainer container , int [ ] [ ] graph ) { int n = container . getAtomCount ( ) ; List < StereoEncoder > encoders = new ArrayList < StereoEncoder > ( ) ; Map < IAtom , Integer > elevation = new HashMap < IAtom , Integer > ( 10 ) ; ATOMS : for ( int i = 0 ; i < n ; i ++ ) { int degree = graph [ i ] . length ; if ( degree < 3 || degree > 4 ) continue ; IAtom atom = container . getAtom ( i ) ; if ( ! sp3 ( atom ) ) continue ; if ( Integer . valueOf ( 7 ) . equals ( atom . getAtomicNumber ( ) ) && degree == 3 ) continue ; List < IBond > bonds = container . getConnectedBondsList ( atom ) ; GeometricParity geometric = geometric ( elevation , bonds , i , graph [ i ] , container ) ; if ( geometric != null ) { encoders . add ( new GeometryEncoder ( i , new BasicPermutationParity ( graph [ i ] ) , geometric ) ) ; } } return encoders . isEmpty ( ) ? StereoEncoder . EMPTY : new MultiStereoEncoder ( encoders ) ; } | Create a stereo encoder for all potential 2D and 3D tetrahedral elements . |
27,945 | private static GeometricParity geometric ( Map < IAtom , Integer > elevationMap , List < IBond > bonds , int i , int [ ] adjacent , IAtomContainer container ) { int nStereoBonds = nStereoBonds ( bonds ) ; if ( nStereoBonds > 0 ) return geometric2D ( elevationMap , bonds , i , adjacent , container ) ; else if ( nStereoBonds == 0 ) return geometric3D ( i , adjacent , container ) ; return null ; } | Create the geometric part of an encoder |
27,946 | private static GeometricParity geometric2D ( Map < IAtom , Integer > elevationMap , List < IBond > bonds , int i , int [ ] adjacent , IAtomContainer container ) { IAtom atom = container . getAtom ( i ) ; makeElevationMap ( atom , bonds , elevationMap ) ; Point2d [ ] coordinates = new Point2d [ 4 ] ; int [ ] elevations = new int [ 4 ] ; if ( atom . getPoint2d ( ) != null ) coordinates [ 3 ] = atom . getPoint2d ( ) ; else return null ; for ( int j = 0 ; j < adjacent . length ; j ++ ) { IAtom neighbor = container . getAtom ( adjacent [ j ] ) ; elevations [ j ] = elevationMap . get ( neighbor ) ; if ( neighbor . getPoint2d ( ) != null ) coordinates [ j ] = neighbor . getPoint2d ( ) ; else return null ; } return new Tetrahedral2DParity ( coordinates , elevations ) ; } | Create the geometric part of an encoder of 2D configurations |
27,947 | private static GeometricParity geometric3D ( int i , int [ ] adjacent , IAtomContainer container ) { IAtom atom = container . getAtom ( i ) ; Point3d [ ] coordinates = new Point3d [ 4 ] ; if ( atom . getPoint3d ( ) != null ) coordinates [ 3 ] = atom . getPoint3d ( ) ; else return null ; for ( int j = 0 ; j < adjacent . length ; j ++ ) { IAtom neighbor = container . getAtom ( adjacent [ j ] ) ; if ( neighbor . getPoint3d ( ) != null ) coordinates [ j ] = neighbor . getPoint3d ( ) ; else return null ; } return new Tetrahedral3DParity ( coordinates ) ; } | Create the geometric part of an encoder of 3D configurations |
27,948 | private static int nStereoBonds ( List < IBond > bonds ) { int count = 0 ; for ( IBond bond : bonds ) { IBond . Stereo stereo = bond . getStereo ( ) ; switch ( stereo ) { case E_OR_Z : case UP_OR_DOWN : case UP_OR_DOWN_INVERTED : return - 1 ; case UP : case DOWN : case UP_INVERTED : case DOWN_INVERTED : count ++ ; break ; } } return count ; } | access the number of stereo bonds in the provided bond list . |
27,949 | private static void makeElevationMap ( IAtom atom , List < IBond > bonds , Map < IAtom , Integer > map ) { map . clear ( ) ; for ( IBond bond : bonds ) { int elevation = 0 ; switch ( bond . getStereo ( ) ) { case UP : case DOWN_INVERTED : elevation = + 1 ; break ; case DOWN : case UP_INVERTED : elevation = - 1 ; break ; } if ( bond . getBegin ( ) . equals ( atom ) ) { map . put ( bond . getEnd ( ) , elevation ) ; } else { map . put ( bond . getBegin ( ) , - 1 * elevation ) ; } } } | Maps the input bonds to a map of Atom - > Elevation where the elevation is whether the bond is off the plane with respect to the central atom . |
27,950 | private static String [ ] readSMARTSPattern ( String filename ) throws Exception { InputStream ins = StandardSubstructureSets . class . getClassLoader ( ) . getResourceAsStream ( filename ) ; BufferedReader reader = new BufferedReader ( new InputStreamReader ( ins ) ) ; List < String > tmp = new ArrayList < String > ( ) ; String line ; while ( ( line = reader . readLine ( ) ) != null ) { if ( line . startsWith ( "#" ) || line . trim ( ) . length ( ) == 0 ) continue ; String [ ] toks = line . split ( ":" ) ; StringBuffer s = new StringBuffer ( ) ; for ( int i = 1 ; i < toks . length - 1 ; i ++ ) s . append ( toks [ i ] + ":" ) ; s . append ( toks [ toks . length - 1 ] ) ; tmp . add ( s . toString ( ) . trim ( ) ) ; } return tmp . toArray ( new String [ ] { } ) ; } | Load a list of SMARTS patterns from the specified file . |
27,951 | protected String getBondSymbol ( IBond bond ) { String bondSymbol = "" ; if ( bond . getOrder ( ) == IBond . Order . SINGLE ) { if ( isSP2Bond ( bond ) ) { bondSymbol = ":" ; } else { bondSymbol = "-" ; } } else if ( bond . getOrder ( ) == IBond . Order . DOUBLE ) { if ( isSP2Bond ( bond ) ) { bondSymbol = ":" ; } else { bondSymbol = "=" ; } } else if ( bond . getOrder ( ) == IBond . Order . TRIPLE ) { bondSymbol = "#" ; } else if ( bond . getOrder ( ) == IBond . Order . QUADRUPLE ) { bondSymbol = "*" ; } return bondSymbol ; } | Gets the bond Symbol attribute of the Fingerprinter class . |
27,952 | private boolean isSP2Bond ( IBond bond ) { return bond . getAtomCount ( ) == 2 && bond . getBegin ( ) . getHybridization ( ) == Hybridization . SP2 && bond . getEnd ( ) . getHybridization ( ) == Hybridization . SP2 ; } | Returns true if the bond binds two atoms and both atoms are SP2 . |
27,953 | public Iterable < IMapping > mappings ( ) { return new Iterable < IMapping > ( ) { public Iterator < IMapping > iterator ( ) { return new MappingIterator ( ) ; } } ; } | Returns the mappings between the reactant and the product side . |
27,954 | public void addProduct ( IAtomContainer product , Double coefficient ) { products . addAtomContainer ( product , coefficient ) ; } | Adds a product to this reaction . |
27,955 | public boolean setReactantCoefficient ( IAtomContainer reactant , Double coefficient ) { boolean result = reactants . setMultiplier ( reactant , coefficient ) ; return result ; } | Sets the coefficient of a a reactant to a given value . |
27,956 | public boolean setProductCoefficient ( IAtomContainer product , Double coefficient ) { boolean result = products . setMultiplier ( product , coefficient ) ; return result ; } | Sets the coefficient of a a product to a given value . |
27,957 | private void bondAtom ( IAtomContainer container , IAtom atom ) { double myCovalentRadius = atom . getCovalentRadius ( ) ; double searchRadius = myCovalentRadius + maxCovalentRadius + bondTolerance ; Point tupleAtom = new Point ( atom . getPoint3d ( ) . x , atom . getPoint3d ( ) . y , atom . getPoint3d ( ) . z ) ; for ( Bspt . EnumerateSphere e = bspt . enumHemiSphere ( tupleAtom , searchRadius ) ; e . hasMoreElements ( ) ; ) { IAtom atomNear = ( ( TupleAtom ) e . nextElement ( ) ) . getAtom ( ) ; if ( ! atomNear . equals ( atom ) && container . getBond ( atom , atomNear ) == null ) { boolean bonded = isBonded ( myCovalentRadius , atomNear . getCovalentRadius ( ) , e . foundDistance2 ( ) ) ; if ( bonded ) { IBond bond = atom . getBuilder ( ) . newInstance ( IBond . class , atom , atomNear , IBond . Order . SINGLE ) ; container . addBond ( bond ) ; } } } } | Rebonds one atom by looking up nearby atom using the binary space partition tree . |
27,958 | private boolean isBonded ( double covalentRadiusA , double covalentRadiusB , double distance2 ) { double maxAcceptable = covalentRadiusA + covalentRadiusB + bondTolerance ; double maxAcceptable2 = maxAcceptable * maxAcceptable ; double minBondDistance2 = this . minBondDistance * this . minBondDistance ; if ( distance2 < minBondDistance2 ) return false ; return distance2 <= maxAcceptable2 ; } | Returns the bond order for the bond . At this moment it only returns 0 or 1 but not 2 or 3 or aromatic bond order . |
27,959 | private static boolean isHueckelValid ( IAtomContainer singleRing ) throws CDKException { int electronCount = 0 ; for ( IAtom ringAtom : singleRing . atoms ( ) ) { if ( ringAtom . getHybridization ( ) != CDKConstants . UNSET && ( ringAtom . getHybridization ( ) == Hybridization . SP2 ) || ringAtom . getHybridization ( ) == Hybridization . PLANAR3 ) { if ( "N.planar3" . equals ( ringAtom . getAtomTypeName ( ) ) ) { electronCount += 2 ; } else if ( "N.minus.planar3" . equals ( ringAtom . getAtomTypeName ( ) ) ) { electronCount += 2 ; } else if ( "N.amide" . equals ( ringAtom . getAtomTypeName ( ) ) ) { electronCount += 2 ; } else if ( "S.2" . equals ( ringAtom . getAtomTypeName ( ) ) ) { electronCount += 2 ; } else if ( "S.planar3" . equals ( ringAtom . getAtomTypeName ( ) ) ) { electronCount += 2 ; } else if ( "C.minus.planar" . equals ( ringAtom . getAtomTypeName ( ) ) ) { electronCount += 2 ; } else if ( "O.planar3" . equals ( ringAtom . getAtomTypeName ( ) ) ) { electronCount += 2 ; } else if ( "N.sp2.3" . equals ( ringAtom . getAtomTypeName ( ) ) ) { electronCount += 1 ; } else { if ( factory == null ) { factory = AtomTypeFactory . getInstance ( "org/openscience/cdk/dict/data/cdk-atom-types.owl" , ringAtom . getBuilder ( ) ) ; } IAtomType type = factory . getAtomType ( ringAtom . getAtomTypeName ( ) ) ; Object property = type . getProperty ( CDKConstants . PI_BOND_COUNT ) ; if ( property != null && property instanceof Integer ) { electronCount += ( ( Integer ) property ) . intValue ( ) ; } } } else if ( ringAtom . getHybridization ( ) != null && ringAtom . getHybridization ( ) == Hybridization . SP3 && getLonePairCount ( ringAtom ) > 0 ) { electronCount += 2 ; } } return ( electronCount % 4 == 2 ) && ( electronCount > 2 ) ; } | Tests if the electron count matches the Hü ; ckel 4n + 2 rule . |
27,960 | public void setHighlightedAtom ( IAtom highlightedAtom ) { if ( ( this . highlightedAtom != null ) || ( highlightedAtom != null ) ) { this . highlightedAtom = highlightedAtom ; fireChange ( ) ; } } | Sets the atom currently highlighted . |
27,961 | public void setHighlightedBond ( IBond highlightedBond ) { if ( ( this . highlightedBond != null ) || ( highlightedBond != null ) ) { this . highlightedBond = highlightedBond ; fireChange ( ) ; } } | Sets the Bond currently highlighted . |
27,962 | public void addCDKChangeListener ( ICDKChangeListener listener ) { if ( listeners == null ) { listeners = new ArrayList < ICDKChangeListener > ( ) ; } if ( ! listeners . contains ( listener ) ) { listeners . add ( listener ) ; } } | Adds a change listener to the list of listeners . |
27,963 | public void fireChange ( ) { if ( getNotification ( ) && listeners != null ) { EventObject event = new EventObject ( this ) ; for ( int i = 0 ; i < listeners . size ( ) ; i ++ ) { listeners . get ( i ) . stateChanged ( event ) ; } } } | Notifies registered listeners of certain changes that have occurred in this model . |
27,964 | public String getToolTipText ( IAtom atom ) { if ( toolTipTextMap . get ( atom ) != null ) { return toolTipTextMap . get ( atom ) ; } else { return null ; } } | Gets the toolTipText for atom certain atom . |
27,965 | public List getAngleData ( String angleType , String id1 , String id2 , String id3 ) throws Exception { String akey = "" ; if ( pSet . containsKey ( ( "angle" + angleType + ";" + id1 + ";" + id2 + ";" + id3 ) ) ) { akey = "angle" + angleType + ";" + id1 + ";" + id2 + ";" + id3 ; } else if ( pSet . containsKey ( ( "angle" + angleType + ";" + id3 + ";" + id2 + ";" + id1 ) ) ) { akey = "angle" + angleType + ";" + id3 + ";" + id2 + ";" + id1 ; } return ( List ) pSet . get ( akey ) ; } | Gets the angle parameter set . |
27,966 | private int getNearestBondtoAGivenAtom ( IAtomContainer mol , IAtom atom , IBond bond ) { int nearestBond = 0 ; double [ ] values ; double distance = 0 ; IAtom atom0 = bond . getBegin ( ) ; List < IBond > bondsAtLeft = mol . getConnectedBondsList ( atom0 ) ; int partial ; for ( int i = 0 ; i < bondsAtLeft . size ( ) ; i ++ ) { IBond curBond = bondsAtLeft . get ( i ) ; values = calculateDistanceBetweenAtomAndBond ( atom , curBond ) ; partial = mol . indexOf ( curBond ) ; if ( i == 0 ) { nearestBond = mol . indexOf ( curBond ) ; distance = values [ 0 ] ; } else { if ( values [ 0 ] < distance ) { nearestBond = partial ; } } } return nearestBond ; } | this method returns a bond bonded to this double bond |
27,967 | private static IAtom getOtherAtom ( IAtomContainer mol , IAtom atom , IAtom other ) { List < IBond > bonds = mol . getConnectedBondsList ( atom ) ; if ( bonds . size ( ) != 2 ) return null ; if ( bonds . get ( 0 ) . contains ( other ) ) return bonds . get ( 1 ) . getOrder ( ) == IBond . Order . DOUBLE ? bonds . get ( 1 ) . getOther ( atom ) : null ; return bonds . get ( 0 ) . getOrder ( ) == IBond . Order . DOUBLE ? bonds . get ( 0 ) . getOther ( atom ) : null ; } | internal find a neighbor connected to atom that is not other |
27,968 | public boolean effectiveCharges ( IAtomContainer mol ) { int [ ] [ ] adjList = mol . getProperty ( MMFF_ADJLIST_CACHE ) ; GraphUtil . EdgeToBondMap edgeMap = mol . getProperty ( MMFF_EDGEMAP_CACHE ) ; if ( adjList == null || edgeMap == null ) throw new IllegalArgumentException ( "Invoke assignAtomTypes first." ) ; primaryCharges ( mol , adjList , edgeMap ) ; effectiveCharges ( mol , adjList ) ; return true ; } | Assign the effective formal charges used by MMFF in calculating the final partial charge values . Atom types must be assigned first . All existing charges are cleared . |
27,969 | public boolean partialCharges ( IAtomContainer mol ) { int [ ] [ ] adjList = mol . getProperty ( MMFF_ADJLIST_CACHE ) ; GraphUtil . EdgeToBondMap edgeMap = mol . getProperty ( MMFF_EDGEMAP_CACHE ) ; if ( adjList == null || edgeMap == null ) throw new IllegalArgumentException ( "Invoke assignAtomTypes first." ) ; effectiveCharges ( mol ) ; for ( int v = 0 ; v < mol . getAtomCount ( ) ; v ++ ) { IAtom atom = mol . getAtom ( v ) ; String symbType = atom . getAtomTypeName ( ) ; final int thisType = mmffParamSet . intType ( symbType ) ; if ( thisType == 0 ) continue ; double pbci = mmffParamSet . getPartialBondChargeIncrement ( thisType ) . doubleValue ( ) ; for ( int w : adjList [ v ] ) { int otherType = mmffParamSet . intType ( mol . getAtom ( w ) . getAtomTypeName ( ) ) ; if ( otherType == 0 ) continue ; IBond bond = edgeMap . get ( v , w ) ; int bondCls = mmffParamSet . getBondCls ( thisType , otherType , bond . getOrder ( ) . numeric ( ) , bond . getProperty ( MMFF_AROM ) != null ) ; BigDecimal bci = mmffParamSet . getBondChargeIncrement ( bondCls , thisType , otherType ) ; if ( bci != null ) { atom . setCharge ( atom . getCharge ( ) - bci . doubleValue ( ) ) ; } else { atom . setCharge ( atom . getCharge ( ) + ( pbci - mmffParamSet . getPartialBondChargeIncrement ( otherType ) . doubleValue ( ) ) ) ; } } } return true ; } | Assign the partial charges all existing charges are cleared . Atom types must be assigned first . |
27,970 | public void clearProps ( IAtomContainer mol ) { mol . removeProperty ( MMFF_EDGEMAP_CACHE ) ; mol . removeProperty ( MMFF_ADJLIST_CACHE ) ; for ( IBond bond : mol . bonds ( ) ) bond . removeProperty ( MMFF_AROM ) ; } | Clear all transient properties assigned by this class . Assigned charges and atom type names remain set . |
27,971 | void effectiveCharges ( IAtomContainer mol , int [ ] [ ] adjList ) { double [ ] tmp = new double [ mol . getAtomCount ( ) ] ; for ( int v = 0 ; v < tmp . length ; v ++ ) { IAtom atom = mol . getAtom ( v ) ; int intType = mmffParamSet . intType ( atom . getAtomTypeName ( ) ) ; if ( intType == 0 ) { continue ; } int crd = mmffParamSet . getCrd ( intType ) ; BigDecimal fcAdj = mmffParamSet . getFormalChargeAdjustment ( intType ) ; double adjust = fcAdj . doubleValue ( ) ; tmp [ v ] = atom . getCharge ( ) ; if ( adjust == 0 ) { for ( int w : adjList [ v ] ) { if ( mol . getAtom ( w ) . getCharge ( ) < 0 ) { tmp [ v ] += mol . getAtom ( w ) . getCharge ( ) / ( 2.0 * adjList [ w ] . length ) ; } } } if ( atom . getAtomTypeName ( ) . equals ( "NM" ) ) { for ( int w : adjList [ v ] ) { if ( mol . getAtom ( w ) . getCharge ( ) > 0 ) { tmp [ v ] -= mol . getAtom ( w ) . getCharge ( ) / 2 ; } } } if ( adjust != 0 ) { double q = 0 ; for ( int w : adjList [ v ] ) { q += mol . getAtom ( w ) . getCharge ( ) ; } tmp [ v ] = ( ( 1 - ( crd * adjust ) ) * tmp [ v ] ) + ( adjust * q ) ; } } for ( int v = 0 ; v < tmp . length ; v ++ ) { mol . getAtom ( v ) . setCharge ( tmp [ v ] ) ; } } | Internal effective charges method . |
27,972 | private Set < IChemObject > getAromatics ( IAtomContainer mol ) { Set < IChemObject > oldArom = new HashSet < > ( ) ; for ( IAtom atom : mol . atoms ( ) ) if ( atom . getFlag ( CDKConstants . ISAROMATIC ) ) oldArom . add ( atom ) ; for ( IBond bond : mol . bonds ( ) ) if ( bond . getFlag ( CDKConstants . ISAROMATIC ) ) oldArom . add ( bond ) ; return oldArom ; } | Helper method to find all existing aromatic chem objects . |
27,973 | private void setAtomTypes ( IChemObjectBuilder builder ) throws Exception { String name = "" ; String rootType = "" ; int an = 0 ; int rl = 255 ; int gl = 20 ; int bl = 147 ; int maxbond = 0 ; double mass = 0.0 ; st . nextToken ( ) ; String sid = st . nextToken ( ) ; rootType = st . nextToken ( ) ; name = st . nextToken ( ) ; String san = st . nextToken ( ) ; String sam = st . nextToken ( ) ; String smaxbond = st . nextToken ( ) ; try { mass = new Double ( sam ) . doubleValue ( ) ; an = Integer . parseInt ( san ) ; maxbond = Integer . parseInt ( smaxbond ) ; } catch ( NumberFormatException nfe ) { throw new IOException ( "AtomTypeTable.ReadAtypes: " + "Malformed Number" ) ; } IAtomType atomType = builder . newInstance ( IAtomType . class , name , rootType ) ; atomType . setAtomicNumber ( an ) ; atomType . setExactMass ( mass ) ; atomType . setMassNumber ( massNumber ( an , mass ) ) ; atomType . setFormalNeighbourCount ( maxbond ) ; atomType . setSymbol ( rootType ) ; Color co = new Color ( rl , gl , bl ) ; atomType . setProperty ( "org.openscience.cdk.renderer.color" , co ) ; atomType . setAtomTypeName ( sid ) ; atomTypes . add ( atomType ) ; } | Read and stores the atom types in a vector |
27,974 | private void setvdWaals ( ) throws Exception { List data = new Vector ( ) ; st . nextToken ( ) ; String sid = st . nextToken ( ) ; String sradius = st . nextToken ( ) ; String sepsi = st . nextToken ( ) ; try { double epsi = new Double ( sepsi ) . doubleValue ( ) ; double radius = new Double ( sradius ) . doubleValue ( ) ; data . add ( new Double ( radius ) ) ; data . add ( new Double ( epsi ) ) ; } catch ( NumberFormatException nfe ) { throw new IOException ( "VdWaalsTable.ReadvdWaals: " + "Malformed Number" ) ; } key = "vdw" + sid ; parameterSet . put ( key , data ) ; } | Read vdw radius stored into the parameter set |
27,975 | private void setOpBend ( ) throws Exception { List data = new Vector ( ) ; st . nextToken ( ) ; String sid1 = st . nextToken ( ) ; String sid2 = st . nextToken ( ) ; String value1 = st . nextToken ( ) ; try { double va1 = new Double ( value1 ) . doubleValue ( ) ; data . add ( new Double ( va1 ) ) ; key = "opbend" + sid1 + ";" + sid2 ; if ( parameterSet . containsKey ( key ) ) { data = ( Vector ) parameterSet . get ( key ) ; data . add ( new Double ( va1 ) ) ; } parameterSet . put ( key , data ) ; } catch ( NumberFormatException nfe ) { throw new IOException ( "setOpBend: Malformed Number" ) ; } } | Sets the opBend attribute stored into the parameter set |
27,976 | private void setDipole ( ) throws Exception { List data = new Vector ( ) ; st . nextToken ( ) ; String sid1 = st . nextToken ( ) ; String sid2 = st . nextToken ( ) ; String value1 = st . nextToken ( ) ; String value2 = st . nextToken ( ) ; try { double va1 = new Double ( value1 ) . doubleValue ( ) ; double va2 = new Double ( value2 ) . doubleValue ( ) ; data . add ( new Double ( va1 ) ) ; data . add ( new Double ( va2 ) ) ; } catch ( NumberFormatException nfe ) { throw new IOException ( "setDipole: " + "Malformed Number" ) ; } key = "dipole" + sid1 + ";" + sid2 ; parameterSet . put ( key , data ) ; } | Sets the dipole attribute stored into the parameter set |
27,977 | private Integer massNumber ( int atomicNumber , double exactMass ) throws IOException { String symbol = PeriodicTable . getSymbol ( atomicNumber ) ; IIsotope isotope = Isotopes . getInstance ( ) . getIsotope ( symbol , exactMass , 0.001 ) ; return isotope != null ? isotope . getMassNumber ( ) : null ; } | Mass number for a atom with a given atomic number and exact mass . |
27,978 | public static MarkedElement markup ( IRenderingElement elem , String ... classes ) { assert elem != null ; MarkedElement tagElem = new MarkedElement ( elem ) ; for ( String cls : classes ) tagElem . aggClass ( cls ) ; return tagElem ; } | Markup a rendering element with the specified classes . |
27,979 | private void setForceField ( String ffname , IChemObjectBuilder builder ) throws CDKException { if ( ffname == null ) { ffname = "mm2" ; } try { forceFieldName = ffname ; ffc . setForceFieldConfigurator ( ffname , builder ) ; parameterSet = ffc . getParameterSet ( ) ; } catch ( CDKException ex1 ) { logger . error ( "Problem with ForceField configuration due to>" + ex1 . getMessage ( ) ) ; logger . debug ( ex1 ) ; throw new CDKException ( "Problem with ForceField configuration due to>" + ex1 . getMessage ( ) , ex1 ) ; } } | Sets the forceField attribute of the ModelBuilder3D object . |
27,980 | private IRingSet getRingSetOfAtom ( List ringSystems , IAtom atom ) { IRingSet ringSetOfAtom = null ; for ( int i = 0 ; i < ringSystems . size ( ) ; i ++ ) { if ( ( ( IRingSet ) ringSystems . get ( i ) ) . contains ( atom ) ) { return ( IRingSet ) ringSystems . get ( i ) ; } } return ringSetOfAtom ; } | Gets the ringSetOfAtom attribute of the ModelBuilder3D object . |
27,981 | private void layoutMolecule ( List ringSetMolecule , IAtomContainer molecule , AtomPlacer3D ap3d , AtomTetrahedralLigandPlacer3D atlp3d , AtomPlacer atomPlacer ) throws CDKException , IOException , CloneNotSupportedException { IAtomContainer ac = null ; int safetyCounter = 0 ; IAtom atom = null ; do { safetyCounter ++ ; atom = ap3d . getNextPlacedHeavyAtomWithUnplacedRingNeighbour ( molecule ) ; if ( atom != null ) { IAtom unplacedAtom = ap3d . getUnplacedRingHeavyAtom ( molecule , atom ) ; IRingSet ringSetA = getRingSetOfAtom ( ringSetMolecule , unplacedAtom ) ; IAtomContainer ringSetAContainer = RingSetManipulator . getAllInOneContainer ( ringSetA ) ; templateHandler . mapTemplates ( ringSetAContainer , ringSetAContainer . getAtomCount ( ) ) ; if ( checkAllRingAtomsHasCoordinates ( ringSetAContainer ) ) { } else { throw new IOException ( "RingAtomLayoutError: Not every ring atom is placed! Molecule cannot be layout.Sorry" ) ; } Point3d firstAtomOriginalCoord = unplacedAtom . getPoint3d ( ) ; Point3d centerPlacedMolecule = ap3d . geometricCenterAllPlacedAtoms ( molecule ) ; setBranchAtom ( molecule , unplacedAtom , atom , ap3d . getPlacedHeavyAtoms ( molecule , atom ) , ap3d , atlp3d ) ; layoutRingSystem ( firstAtomOriginalCoord , unplacedAtom , ringSetA , centerPlacedMolecule , atom , ap3d ) ; searchAndPlaceBranches ( molecule , ringSetAContainer , ap3d , atlp3d , atomPlacer ) ; ringSetA = null ; unplacedAtom = null ; firstAtomOriginalCoord = null ; centerPlacedMolecule = null ; } else { setAtomsToUnVisited ( molecule ) ; atom = ap3d . getNextPlacedHeavyAtomWithUnplacedAliphaticNeighbour ( molecule ) ; if ( atom != null ) { ac = atom . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; ac . addAtom ( atom ) ; searchAndPlaceBranches ( molecule , ac , ap3d , atlp3d , atomPlacer ) ; ac = null ; } } } while ( ! ap3d . allHeavyAtomsPlaced ( molecule ) || safetyCounter > molecule . getAtomCount ( ) ) ; } | Layout the molecule starts with ring systems and than aliphatic chains . |
27,982 | private void setBranchAtom ( IAtomContainer molecule , IAtom unplacedAtom , IAtom atomA , IAtomContainer atomNeighbours , AtomPlacer3D ap3d , AtomTetrahedralLigandPlacer3D atlp3d ) throws CDKException { IAtomContainer noCoords = molecule . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; noCoords . addAtom ( unplacedAtom ) ; Point3d centerPlacedMolecule = ap3d . geometricCenterAllPlacedAtoms ( molecule ) ; IAtom atomB = atomNeighbours . getAtom ( 0 ) ; String atypeNameA = atomA . getAtomTypeName ( ) ; String atypeNameB = atomB . getAtomTypeName ( ) ; String atypeNameUnplaced = unplacedAtom . getAtomTypeName ( ) ; double length = ap3d . getBondLengthValue ( atypeNameA , atypeNameUnplaced ) ; double angle = ( ap3d . getAngleValue ( atypeNameB , atypeNameA , atypeNameUnplaced ) ) * Math . PI / 180 ; IAtom atomC = ap3d . getPlacedHeavyAtom ( molecule , atomB , atomA ) ; Point3d [ ] branchPoints = atlp3d . get3DCoordinatesForLigands ( atomA , noCoords , atomNeighbours , atomC , ( atomA . getFormalNeighbourCount ( ) - atomNeighbours . getAtomCount ( ) ) , length , angle ) ; double distance = 0 ; int farthestPoint = 0 ; for ( int i = 0 ; i < branchPoints . length ; i ++ ) { if ( Math . abs ( branchPoints [ i ] . distance ( centerPlacedMolecule ) ) > Math . abs ( distance ) ) { distance = branchPoints [ i ] . distance ( centerPlacedMolecule ) ; farthestPoint = i ; } } int stereo = - 1 ; IBond unplacedBond = molecule . getBond ( atomA , unplacedAtom ) ; if ( atomA . getStereoParity ( ) != CDKConstants . UNSET && atomA . getStereoParity ( ) != 0 || ( unplacedBond . getStereo ( ) == IBond . Stereo . UP || unplacedBond . getStereo ( ) == IBond . Stereo . DOWN ) && molecule . getMaximumBondOrder ( atomA ) == IBond . Order . SINGLE ) { if ( atomNeighbours . getAtomCount ( ) > 1 ) { stereo = atlp3d . makeStereocenter ( atomA . getPoint3d ( ) , molecule . getBond ( atomA , unplacedAtom ) , ( atomNeighbours . getAtom ( 0 ) ) . getPoint3d ( ) , ( atomNeighbours . getAtom ( 1 ) ) . getPoint3d ( ) , branchPoints ) ; } } if ( stereo != - 1 ) { farthestPoint = stereo ; } unplacedAtom . setPoint3d ( branchPoints [ farthestPoint ] ) ; unplacedAtom . setFlag ( CDKConstants . ISPLACED , true ) ; } | Sets a branch atom to a ring or aliphatic chain . |
27,983 | private void searchAndPlaceBranches ( IAtomContainer molecule , IAtomContainer chain , AtomPlacer3D ap3d , AtomTetrahedralLigandPlacer3D atlp3d , AtomPlacer atomPlacer ) throws CDKException { List atoms = null ; IAtomContainer branchAtoms = molecule . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; IAtomContainer connectedAtoms = molecule . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; for ( int i = 0 ; i < chain . getAtomCount ( ) ; i ++ ) { atoms = molecule . getConnectedAtomsList ( chain . getAtom ( i ) ) ; for ( int j = 0 ; j < atoms . size ( ) ; j ++ ) { IAtom atom = ( IAtom ) atoms . get ( j ) ; if ( ! ( atom . getSymbol ( ) ) . equals ( "H" ) & ! ( atom . getFlag ( CDKConstants . ISPLACED ) ) & ! ( atom . getFlag ( CDKConstants . ISINRING ) ) ) { connectedAtoms . add ( ap3d . getPlacedHeavyAtoms ( molecule , chain . getAtom ( i ) ) ) ; try { setBranchAtom ( molecule , atom , chain . getAtom ( i ) , connectedAtoms , ap3d , atlp3d ) ; } catch ( CDKException ex2 ) { logger . error ( "SearchAndPlaceBranchERROR: Cannot find enough neighbour atoms due to" + ex2 . toString ( ) ) ; throw new CDKException ( "SearchAndPlaceBranchERROR: Cannot find enough neighbour atoms: " + ex2 . getMessage ( ) , ex2 ) ; } branchAtoms . addAtom ( atom ) ; connectedAtoms . removeAllElements ( ) ; } } } placeLinearChains3D ( molecule , branchAtoms , ap3d , atlp3d , atomPlacer ) ; } | Search and place branches of a chain or ring . |
27,984 | private void placeLinearChains3D ( IAtomContainer molecule , IAtomContainer startAtoms , AtomPlacer3D ap3d , AtomTetrahedralLigandPlacer3D atlp3d , AtomPlacer atomPlacer ) throws CDKException { IAtom dihPlacedAtom = null ; IAtom thirdPlacedAtom = null ; IAtomContainer longestUnplacedChain = molecule . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; if ( startAtoms . getAtomCount ( ) == 0 ) { } else { for ( int i = 0 ; i < startAtoms . getAtomCount ( ) ; i ++ ) { thirdPlacedAtom = ap3d . getPlacedHeavyAtom ( molecule , startAtoms . getAtom ( i ) ) ; dihPlacedAtom = ap3d . getPlacedHeavyAtom ( molecule , thirdPlacedAtom , startAtoms . getAtom ( i ) ) ; longestUnplacedChain . addAtom ( dihPlacedAtom ) ; longestUnplacedChain . addAtom ( thirdPlacedAtom ) ; longestUnplacedChain . addAtom ( startAtoms . getAtom ( i ) ) ; longestUnplacedChain . add ( atomPlacer . getLongestUnplacedChain ( molecule , startAtoms . getAtom ( i ) ) ) ; setAtomsToUnVisited ( molecule ) ; if ( longestUnplacedChain . getAtomCount ( ) < 4 ) { } else { ap3d . placeAliphaticHeavyChain ( molecule , longestUnplacedChain ) ; ap3d . zmatrixChainToCartesian ( molecule , true ) ; searchAndPlaceBranches ( molecule , longestUnplacedChain , ap3d , atlp3d , atomPlacer ) ; } longestUnplacedChain . removeAllElements ( ) ; } } } | Layout all aliphatic chains with ZMatrix . |
27,985 | private void translateStructure ( Point3d originalCoord , Point3d newCoord , IAtomContainer ac ) { Point3d transVector = new Point3d ( originalCoord ) ; transVector . sub ( newCoord ) ; for ( int i = 0 ; i < ac . getAtomCount ( ) ; i ++ ) { if ( ! ( ac . getAtom ( i ) . getFlag ( CDKConstants . ISPLACED ) ) ) { ac . getAtom ( i ) . getPoint3d ( ) . sub ( transVector ) ; } } } | Translates the template ring system to new coordinates . |
27,986 | private void setAtomsToPlace ( IAtomContainer ac ) { for ( int i = 0 ; i < ac . getAtomCount ( ) ; i ++ ) { ac . getAtom ( i ) . setFlag ( CDKConstants . ISPLACED , true ) ; } } | Sets the atomsToPlace attribute of the ModelBuilder3D object . |
27,987 | private void setAtomsToUnPlaced ( IAtomContainer molecule ) { for ( int i = 0 ; i < molecule . getAtomCount ( ) ; i ++ ) { molecule . getAtom ( i ) . setFlag ( CDKConstants . ISPLACED , false ) ; } } | Sets the atomsToUnPlaced attribute of the ModelBuilder3D object . |
27,988 | private void setAtomsToUnVisited ( IAtomContainer molecule ) { for ( int i = 0 ; i < molecule . getAtomCount ( ) ; i ++ ) { molecule . getAtom ( i ) . setFlag ( CDKConstants . VISITED , false ) ; } } | Sets the atomsToUnVisited attribute of the ModelBuilder3D object . |
27,989 | public static IAtomContainer makeDeepCopy ( IAtomContainer container ) { IAtomContainer newAtomContainer = container . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; IAtom [ ] atoms = copyAtoms ( container , newAtomContainer ) ; copyBonds ( atoms , container , newAtomContainer ) ; for ( int index = 0 ; index < container . getLonePairCount ( ) ; index ++ ) { if ( container . getAtom ( index ) . getSymbol ( ) . equalsIgnoreCase ( "R" ) || container . getAtom ( index ) . getSymbol ( ) . equalsIgnoreCase ( "A" ) ) { newAtomContainer . addLonePair ( container . getBuilder ( ) . newInstance ( ILonePair . class , container . getAtom ( index ) ) ) ; } else { newAtomContainer . addLonePair ( index ) ; } } for ( int index = 0 ; index < container . getSingleElectronCount ( ) ; index ++ ) { newAtomContainer . addSingleElectron ( index ) ; } newAtomContainer . addProperties ( container . getProperties ( ) ) ; newAtomContainer . setFlags ( container . getFlags ( ) ) ; newAtomContainer . setID ( container . getID ( ) ) ; newAtomContainer . notifyChanged ( ) ; return newAtomContainer ; } | Retrurns deep copy of the molecule |
27,990 | public static int getExplicitHydrogenCount ( IAtomContainer atomContainer , IAtom atom ) { int hCount = 0 ; for ( IAtom iAtom : atomContainer . getConnectedAtomsList ( atom ) ) { IAtom connectedAtom = iAtom ; if ( connectedAtom . getSymbol ( ) . equals ( "H" ) ) { hCount ++ ; } } return hCount ; } | Returns The number of explicit hydrogens for a given IAtom . |
27,991 | public static int getHydrogenCount ( IAtomContainer atomContainer , IAtom atom ) { return getExplicitHydrogenCount ( atomContainer , atom ) + getImplicitHydrogenCount ( atom ) ; } | The summed implicit + explicit hydrogens of the given IAtom . |
27,992 | @ SuppressWarnings ( "unchecked" ) public < T > T getValue ( SgroupKey key ) { return ( T ) attributes . get ( key ) ; } | Access an attribute for the Sgroup . |
27,993 | public final void addBracket ( SgroupBracket bracket ) { List < SgroupBracket > brackets = getValue ( SgroupKey . CtabBracket ) ; if ( brackets == null ) { putValue ( SgroupKey . CtabBracket , brackets = new ArrayList < > ( 2 ) ) ; } brackets . add ( bracket ) ; } | Add a bracket for this Sgroup . |
27,994 | public Rectangle calculateScreenBounds ( Rectangle2D modelBounds ) { double scale = rendererModel . getParameter ( Scale . class ) . getValue ( ) ; double zoom = rendererModel . getParameter ( ZoomFactor . class ) . getValue ( ) ; double margin = rendererModel . getParameter ( Margin . class ) . getValue ( ) ; Point2d modelScreenCenter = this . toScreenCoordinates ( modelBounds . getCenterX ( ) , modelBounds . getCenterY ( ) ) ; double width = ( scale * zoom * modelBounds . getWidth ( ) ) + ( 2 * margin ) ; double height = ( scale * zoom * modelBounds . getHeight ( ) ) + ( 2 * margin ) ; return new Rectangle ( ( int ) ( modelScreenCenter . x - width / 2 ) , ( int ) ( modelScreenCenter . y - height / 2 ) , ( int ) width , ( int ) height ) ; } | Converts a bounding rectangle in model space into the equivalent bounds in screen space . Used to determine how much space the model will take up on screen given a particular scale zoom and margin . |
27,995 | public Point2d toModelCoordinates ( double screenX , double screenY ) { try { double [ ] dest = new double [ 2 ] ; double [ ] src = new double [ ] { screenX , screenY } ; transform . inverseTransform ( src , 0 , dest , 0 , 1 ) ; return new Point2d ( dest [ 0 ] , dest [ 1 ] ) ; } catch ( NoninvertibleTransformException n ) { return new Point2d ( 0 , 0 ) ; } } | Convert a point in screen space into a point in model space . |
27,996 | public Point2d toScreenCoordinates ( double modelX , double modelY ) { double [ ] dest = new double [ 2 ] ; transform . transform ( new double [ ] { modelX , modelY } , 0 , dest , 0 , 1 ) ; return new Point2d ( dest [ 0 ] , dest [ 1 ] ) ; } | Convert a point in model space into a point in screen space . |
27,997 | public void shiftDrawCenter ( double shiftX , double shiftY ) { drawCenter . set ( drawCenter . x + shiftX , drawCenter . y + shiftY ) ; setup ( ) ; } | Move the draw center by dx and dy . |
27,998 | public void setZoomToFit ( double drawWidth , double drawHeight , double diagramWidth , double diagramHeight ) { double margin = rendererModel . getParameter ( Margin . class ) . getValue ( ) ; double widthRatio = drawWidth / ( diagramWidth + ( 2 * margin ) ) ; double heightRatio = drawHeight / ( diagramHeight + ( 2 * margin ) ) ; double zoom = Math . min ( widthRatio , heightRatio ) ; this . fontManager . setFontForZoom ( zoom ) ; rendererModel . getParameter ( ZoomFactor . class ) . setValue ( zoom ) ; } | Calculate and set the zoom factor needed to completely fit the diagram onto the screen bounds . |
27,999 | protected void paint ( IDrawVisitor drawVisitor , IRenderingElement diagram ) { if ( diagram == null ) return ; this . cachedDiagram = diagram ; fontManager . setFontName ( rendererModel . getParameter ( FontName . class ) . getValue ( ) ) ; fontManager . setFontStyle ( rendererModel . getParameter ( UsedFontStyle . class ) . getValue ( ) ) ; drawVisitor . setFontManager ( this . fontManager ) ; drawVisitor . setTransform ( this . transform ) ; drawVisitor . setRendererModel ( this . rendererModel ) ; diagram . accept ( drawVisitor ) ; } | The target method for paintChemModel paintReaction and paintMolecule . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.