idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
28,900
private static IAtomContainer roundUpIfNeeded ( IAtomContainer anon ) { IChemObjectBuilder bldr = anon . getBuilder ( ) ; if ( ( anon . getAtomCount ( ) & 0x1 ) != 0 ) { IBond bond = anon . removeBond ( anon . getBondCount ( ) - 1 ) ; IAtom dummy = bldr . newInstance ( IAtom . class , "C" ) ; anon . addAtom ( dummy ) ; anon . addBond ( bldr . newInstance ( IBond . class , bond . getBegin ( ) , dummy , IBond . Order . SINGLE ) ) ; anon . addBond ( bldr . newInstance ( IBond . class , dummy , bond . getEnd ( ) , IBond . Order . SINGLE ) ) ; } return anon ; }
Make a ring one atom bigger if it s of an odd size .
28,901
public IAtomType findMatchingAtomType ( IAtomContainer atomContainer , IAtom atom ) throws CDKException { if ( factory == null ) { try { factory = AtomTypeFactory . getInstance ( "org/openscience/cdk/config/data/structgen_atomtypes.xml" , atom . getBuilder ( ) ) ; } catch ( Exception ex1 ) { logger . error ( ex1 . getMessage ( ) ) ; logger . debug ( ex1 ) ; throw new CDKException ( "Could not instantiate the AtomType list!" , ex1 ) ; } } double bondOrderSum = atomContainer . getBondOrderSum ( atom ) ; IBond . Order maxBondOrder = atomContainer . getMaximumBondOrder ( atom ) ; int charge = atom . getFormalCharge ( ) ; int hcount = atom . getImplicitHydrogenCount ( ) == null ? 0 : atom . getImplicitHydrogenCount ( ) ; IAtomType [ ] types = factory . getAtomTypes ( atom . getSymbol ( ) ) ; for ( IAtomType type : types ) { logger . debug ( " ... matching atom " , atom , " vs " , type ) ; if ( bondOrderSum - charge + hcount == type . getBondOrderSum ( ) && ! BondManipulator . isHigherOrder ( maxBondOrder , type . getMaxBondOrder ( ) ) ) { return type ; } } logger . debug ( " No Match" ) ; return null ; }
Finds the AtomType matching the Atom s element symbol formal charge and hybridization state .
28,902
public DescriptorValue calculate ( IBond bond , IAtomContainer atomContainer ) { double value = 0 ; String originalAtomtypeName1 = bond . getBegin ( ) . getAtomTypeName ( ) ; Integer originalNeighborCount1 = bond . getBegin ( ) . getFormalNeighbourCount ( ) ; IAtomType . Hybridization originalHybridization1 = bond . getBegin ( ) . getHybridization ( ) ; Integer originalValency1 = bond . getBegin ( ) . getValency ( ) ; String originalAtomtypeName2 = bond . getEnd ( ) . getAtomTypeName ( ) ; Integer originalNeighborCount2 = bond . getEnd ( ) . getFormalNeighbourCount ( ) ; IAtomType . Hybridization originalHybridization2 = bond . getEnd ( ) . getHybridization ( ) ; Integer originalValency2 = bond . getEnd ( ) . getValency ( ) ; Double originalBondOrderSum1 = bond . getBegin ( ) . getBondOrderSum ( ) ; Order originalMaxBondOrder1 = bond . getBegin ( ) . getMaxBondOrder ( ) ; Double originalBondOrderSum2 = bond . getEnd ( ) . getBondOrderSum ( ) ; Order originalMaxBondOrder2 = bond . getEnd ( ) . getMaxBondOrder ( ) ; if ( ! isCachedAtomContainer ( atomContainer ) ) { try { AtomContainerManipulator . percieveAtomTypesAndConfigureAtoms ( atomContainer ) ; LonePairElectronChecker lpcheck = new LonePairElectronChecker ( ) ; lpcheck . saturate ( atomContainer ) ; } catch ( CDKException e ) { return getDummyDescriptorValue ( e ) ; } } if ( ! bond . getOrder ( ) . equals ( IBond . Order . SINGLE ) ) { try { value = IonizationPotentialTool . predictIP ( atomContainer , bond ) ; } catch ( CDKException e ) { return getDummyDescriptorValue ( e ) ; } } bond . getBegin ( ) . setAtomTypeName ( originalAtomtypeName1 ) ; bond . getBegin ( ) . setHybridization ( originalHybridization1 ) ; bond . getBegin ( ) . setValency ( originalValency1 ) ; bond . getBegin ( ) . setFormalNeighbourCount ( originalNeighborCount1 ) ; bond . getEnd ( ) . setAtomTypeName ( originalAtomtypeName2 ) ; bond . getEnd ( ) . setHybridization ( originalHybridization2 ) ; bond . getEnd ( ) . setValency ( originalValency2 ) ; bond . getEnd ( ) . setFormalNeighbourCount ( originalNeighborCount2 ) ; bond . getBegin ( ) . setMaxBondOrder ( originalMaxBondOrder1 ) ; bond . getBegin ( ) . setBondOrderSum ( originalBondOrderSum1 ) ; bond . getEnd ( ) . setMaxBondOrder ( originalMaxBondOrder2 ) ; bond . getEnd ( ) . setBondOrderSum ( originalBondOrderSum2 ) ; return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( value ) , DESCRIPTOR_NAMES ) ; }
This method calculates the ionization potential of a bond .
28,903
public Partition getInitialPartition ( ) { int bondCount = atomContainer . getBondCount ( ) ; Map < String , SortedSet < Integer > > cellMap = new HashMap < String , SortedSet < Integer > > ( ) ; for ( int bondIndex = 0 ; bondIndex < bondCount ; bondIndex ++ ) { IBond bond = atomContainer . getBond ( bondIndex ) ; String el0 = bond . getAtom ( 0 ) . getSymbol ( ) ; String el1 = bond . getAtom ( 1 ) . getSymbol ( ) ; String boS ; if ( ignoreBondOrders ) { boS = "1" ; } else { boolean isArom = bond . getFlag ( CDKConstants . ISAROMATIC ) ; int orderNumber = ( isArom ) ? 5 : bond . getOrder ( ) . numeric ( ) ; boS = String . valueOf ( orderNumber ) ; } String bondString ; if ( el0 . compareTo ( el1 ) < 0 ) { bondString = el0 + boS + el1 ; } else { bondString = el1 + boS + el0 ; } SortedSet < Integer > cell ; if ( cellMap . containsKey ( bondString ) ) { cell = cellMap . get ( bondString ) ; } else { cell = new TreeSet < Integer > ( ) ; cellMap . put ( bondString , cell ) ; } cell . add ( bondIndex ) ; } List < String > bondStrings = new ArrayList < String > ( cellMap . keySet ( ) ) ; Collections . sort ( bondStrings ) ; Partition bondPartition = new Partition ( ) ; for ( String key : bondStrings ) { SortedSet < Integer > cell = cellMap . get ( key ) ; bondPartition . addCell ( cell ) ; } bondPartition . order ( ) ; return bondPartition ; }
Get the bond partition based on the element types of the atoms at either end of the bond and the bond order .
28,904
private int ringSystemClassifier ( IRing ring , String smile ) throws CDKException { logger . debug ( "Comparing ring systems: SMILES=" , smile ) ; if ( PYRROLE_SMI == null ) { final SmilesParser smipar = new SmilesParser ( ring . getBuilder ( ) ) ; initCache ( smipar ) ; } if ( smile . equals ( PYRROLE_SMI ) ) return PYROLE_RING ; else if ( smile . equals ( FURAN_SMI ) ) return FURAN_RING ; else if ( smile . equals ( THIOPHENE_SMI ) ) return THIOPHENE_RING ; else if ( smile . equals ( PYRIDINE_SMI ) ) return PYRIDINE_RING ; else if ( smile . equals ( PYRIMIDINE_SMI ) ) return PYRIMIDINE_RING ; else if ( smile . equals ( BENZENE_SMI ) ) return BENZENE_RING ; int ncount = 0 ; for ( int i = 0 ; i < ring . getAtomCount ( ) ; i ++ ) { if ( ring . getAtom ( i ) . getSymbol ( ) . equals ( "N" ) ) { ncount = ncount + 1 ; } } if ( ring . getAtomCount ( ) == 6 & ncount == 1 ) { return 10 ; } else if ( ring . getAtomCount ( ) == 5 & ncount == 1 ) { return 4 ; } if ( ncount == 0 ) { return 3 ; } else { return 0 ; } }
Identifies ringSystem and returns a number which corresponds to CDKChemicalRingConstant
28,905
public void setAtoms ( IAtom [ ] atoms ) { this . atoms = atoms ; for ( IAtom atom : atoms ) { atom . addListener ( this ) ; } this . atomCount = atoms . length ; notifyChanged ( ) ; }
Sets the array of atoms of this AtomContainer .
28,906
public void setBonds ( IBond [ ] bonds ) { this . bonds = bonds ; for ( IBond bond : bonds ) { bond . addListener ( this ) ; } this . bondCount = bonds . length ; }
Sets the array of bonds of this AtomContainer .
28,907
public List < IAtom > getConnectedAtomsList ( IAtom atom ) { List < IAtom > atomsList = new ArrayList < IAtom > ( ) ; for ( int i = 0 ; i < bondCount ; i ++ ) { if ( bonds [ i ] . contains ( atom ) ) atomsList . add ( bonds [ i ] . getOther ( atom ) ) ; } return atomsList ; }
Returns an ArrayList of all atoms connected to the given atom .
28,908
public List < IBond > getConnectedBondsList ( IAtom atom ) { List < IBond > bondsList = new ArrayList < IBond > ( ) ; for ( int i = 0 ; i < bondCount ; i ++ ) { if ( bonds [ i ] . contains ( atom ) ) bondsList . add ( bonds [ i ] ) ; } return bondsList ; }
Returns an ArrayList of all Bonds connected to the given atom .
28,909
public List < ISingleElectron > getConnectedSingleElectronsList ( IAtom atom ) { List < ISingleElectron > lps = new ArrayList < ISingleElectron > ( ) ; for ( int i = 0 ; i < singleElectronCount ; i ++ ) { if ( singleElectrons [ i ] . contains ( atom ) ) lps . add ( singleElectrons [ i ] ) ; } return lps ; }
Returns an array of all SingleElectron connected to the given atom .
28,910
public int getConnectedAtomsCount ( IAtom atom ) { int count = 0 ; for ( int i = 0 ; i < bondCount ; i ++ ) { if ( bonds [ i ] . contains ( atom ) ) ++ count ; } return count ; }
Returns the number of atoms connected to the given atom .
28,911
public int getConnectedLonePairsCount ( IAtom atom ) { int count = 0 ; for ( int i = 0 ; i < lonePairCount ; i ++ ) { if ( lonePairs [ i ] . contains ( atom ) ) ++ count ; } return count ; }
Returns the number of LonePairs for a given Atom .
28,912
public int getConnectedSingleElectronsCount ( IAtom atom ) { int count = 0 ; for ( int i = 0 ; i < singleElectronCount ; i ++ ) { if ( singleElectrons [ i ] . contains ( atom ) ) ++ count ; } return count ; }
Returns the sum of the SingleElectron for a given Atom .
28,913
public double getBondOrderSum ( IAtom atom ) { double count = 0 ; for ( int i = 0 ; i < bondCount ; i ++ ) { if ( bonds [ i ] . contains ( atom ) ) { if ( bonds [ i ] . getOrder ( ) == IBond . Order . SINGLE ) { count += 1 ; } else if ( bonds [ i ] . getOrder ( ) == IBond . Order . DOUBLE ) { count += 2 ; } else if ( bonds [ i ] . getOrder ( ) == IBond . Order . TRIPLE ) { count += 3 ; } else if ( bonds [ i ] . getOrder ( ) == IBond . Order . QUADRUPLE ) { count += 4 ; } } } return count ; }
Returns the sum of the bond orders for a given Atom .
28,914
public Order getMaximumBondOrder ( IAtom atom ) { IBond . Order max = IBond . Order . SINGLE ; for ( int i = 0 ; i < bondCount ; i ++ ) { if ( bonds [ i ] . contains ( atom ) && bonds [ i ] . getOrder ( ) . ordinal ( ) > max . ordinal ( ) ) { max = bonds [ i ] . getOrder ( ) ; } } return max ; }
Returns the maximum bond order that this atom currently has in the context of this AtomContainer .
28,915
public Order getMinimumBondOrder ( IAtom atom ) { IBond . Order min = IBond . Order . QUADRUPLE ; for ( int i = 0 ; i < bondCount ; i ++ ) { if ( bonds [ i ] . contains ( atom ) && bonds [ i ] . getOrder ( ) . ordinal ( ) < min . ordinal ( ) ) { min = bonds [ i ] . getOrder ( ) ; } } return min ; }
Returns the minimum bond order that this atom currently has in the context of this AtomContainer .
28,916
public void add ( IAtomContainer atomContainer ) { if ( atomContainer instanceof QueryAtomContainer ) { for ( int f = 0 ; f < atomContainer . getAtomCount ( ) ; f ++ ) { if ( ! contains ( atomContainer . getAtom ( f ) ) ) { addAtom ( atomContainer . getAtom ( f ) ) ; } } for ( int f = 0 ; f < atomContainer . getBondCount ( ) ; f ++ ) { if ( ! contains ( atomContainer . getBond ( f ) ) ) { addBond ( atomContainer . getBond ( f ) ) ; } } for ( int f = 0 ; f < atomContainer . getLonePairCount ( ) ; f ++ ) { if ( ! contains ( atomContainer . getLonePair ( f ) ) ) { addLonePair ( atomContainer . getLonePair ( f ) ) ; } } for ( int f = 0 ; f < atomContainer . getSingleElectronCount ( ) ; f ++ ) { if ( ! contains ( atomContainer . getSingleElectron ( f ) ) ) { addSingleElectron ( atomContainer . getSingleElectron ( f ) ) ; } } notifyChanged ( ) ; } else { throw new IllegalArgumentException ( "AtomContainer is not of type QueryAtomContainer" ) ; } }
Adds all atoms and electronContainers of a given atomcontainer to this container .
28,917
public void addAtom ( IAtom atom ) { if ( contains ( atom ) ) { return ; } if ( atomCount + 1 >= atoms . length ) { growAtomArray ( ) ; } atom . addListener ( this ) ; atoms [ atomCount ] = atom ; atomCount ++ ; notifyChanged ( ) ; }
Adds an atom to this container .
28,918
public void addBond ( IBond bond ) { if ( bondCount >= bonds . length ) growBondArray ( ) ; bonds [ bondCount ] = bond ; ++ bondCount ; notifyChanged ( ) ; }
Adds a Bond to this AtomContainer .
28,919
public void addLonePair ( ILonePair lonePair ) { if ( lonePairCount >= lonePairs . length ) growLonePairArray ( ) ; lonePairs [ lonePairCount ] = lonePair ; ++ lonePairCount ; notifyChanged ( ) ; }
Adds a lone pair to this AtomContainer .
28,920
public void addSingleElectron ( ISingleElectron singleElectron ) { if ( singleElectronCount >= singleElectrons . length ) growSingleElectronArray ( ) ; singleElectrons [ singleElectronCount ] = singleElectron ; ++ singleElectronCount ; notifyChanged ( ) ; }
Adds a single electron to this AtomContainer .
28,921
public void removeAtom ( IAtom atom ) { int position = getAtomNumber ( atom ) ; if ( position != - 1 ) { for ( int i = 0 ; i < bondCount ; i ++ ) { if ( bonds [ i ] . contains ( atom ) ) { removeBond ( i ) ; -- i ; } } for ( int i = 0 ; i < lonePairCount ; i ++ ) { if ( lonePairs [ i ] . contains ( atom ) ) { removeLonePair ( i ) ; -- i ; } } for ( int i = 0 ; i < singleElectronCount ; i ++ ) { if ( singleElectrons [ i ] . contains ( atom ) ) { removeSingleElectron ( i ) ; -- i ; } } removeAtomOnly ( position ) ; } notifyChanged ( ) ; }
Removes the given atom and all connected electronContainers from the AtomContainer .
28,922
public void addBond ( int atom1 , int atom2 , IBond . Order order , IBond . Stereo stereo ) { IBond bond = getBuilder ( ) . newInstance ( IBond . class , getAtom ( atom1 ) , getAtom ( atom2 ) , order , stereo ) ; if ( contains ( bond ) ) { return ; } if ( bondCount >= bonds . length ) { growBondArray ( ) ; } addBond ( bond ) ; }
Adds a bond to this container .
28,923
public boolean contains ( IElectronContainer electronContainer ) { if ( electronContainer instanceof IBond ) return contains ( ( IBond ) electronContainer ) ; if ( electronContainer instanceof ILonePair ) return contains ( ( ILonePair ) electronContainer ) ; if ( electronContainer instanceof ISingleElectron ) return contains ( ( ISingleElectron ) electronContainer ) ; return false ; }
True if the AtomContainer contains the given ElectronContainer object .
28,924
private void growAtomArray ( ) { growArraySize = ( atoms . length < growArraySize ) ? growArraySize : atoms . length ; IAtom [ ] newatoms = new IAtom [ atoms . length + growArraySize ] ; System . arraycopy ( atoms , 0 , newatoms , 0 , atoms . length ) ; atoms = newatoms ; }
Grows the atom array by a given size .
28,925
private void growBondArray ( ) { growArraySize = ( bonds . length < growArraySize ) ? growArraySize : bonds . length ; IBond [ ] newBonds = new IBond [ bonds . length + growArraySize ] ; System . arraycopy ( bonds , 0 , newBonds , 0 , bonds . length ) ; bonds = newBonds ; }
Grows the bond array by a given size .
28,926
private void growLonePairArray ( ) { growArraySize = ( lonePairs . length < growArraySize ) ? growArraySize : lonePairs . length ; ILonePair [ ] newLonePairs = new ILonePair [ lonePairs . length + growArraySize ] ; System . arraycopy ( lonePairs , 0 , newLonePairs , 0 , lonePairs . length ) ; lonePairs = newLonePairs ; }
Grows the lone pair array by a given size .
28,927
private void growSingleElectronArray ( ) { growArraySize = ( singleElectrons . length < growArraySize ) ? growArraySize : singleElectrons . length ; ISingleElectron [ ] newSingleElectrons = new ISingleElectron [ singleElectrons . length + growArraySize ] ; System . arraycopy ( singleElectrons , 0 , newSingleElectrons , 0 , singleElectrons . length ) ; singleElectrons = newSingleElectrons ; }
Grows the single electron array by a given size .
28,928
public static int [ ] [ ] getMatrix ( IAtomContainer container ) { IBond bond ; int indexAtom1 ; int indexAtom2 ; int [ ] [ ] conMat = new int [ container . getAtomCount ( ) ] [ container . getAtomCount ( ) ] ; for ( int f = 0 ; f < container . getBondCount ( ) ; f ++ ) { bond = container . getBond ( f ) ; indexAtom1 = container . indexOf ( bond . getBegin ( ) ) ; indexAtom2 = container . indexOf ( bond . getEnd ( ) ) ; conMat [ indexAtom1 ] [ indexAtom2 ] = 1 ; conMat [ indexAtom2 ] [ indexAtom1 ] = 1 ; } return conMat ; }
Returns the adjacency matrix for the given AtomContainer .
28,929
public DescriptorValue calculate ( IAtom atom , IAtomContainer container ) { if ( factory == null ) try { factory = AtomTypeFactory . getInstance ( "org/openscience/cdk/config/data/jmol_atomtypes.txt" , container . getBuilder ( ) ) ; } catch ( Exception exception ) { return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( Double . NaN ) , getDescriptorNames ( ) , exception ) ; } double covalentradius ; try { String symbol = atom . getSymbol ( ) ; IAtomType type = factory . getAtomType ( symbol ) ; covalentradius = type . getCovalentRadius ( ) ; return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( covalentradius ) , getDescriptorNames ( ) ) ; } catch ( Exception exception ) { logger . debug ( exception ) ; return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( Double . NaN ) , getDescriptorNames ( ) , exception ) ; } }
This method calculates the Covalent radius of an atom .
28,930
public void setMoleculeSet ( IAtomContainerSet setOfMolecules ) { if ( this . setOfMolecules != null ) this . setOfMolecules . removeListener ( this ) ; this . setOfMolecules = setOfMolecules ; if ( this . setOfMolecules != null ) this . setOfMolecules . addListener ( this ) ; notifyChanged ( ) ; }
Sets the MoleculeSet of this ChemModel .
28,931
public void setRingSet ( IRingSet ringSet ) { if ( this . ringSet != null ) this . ringSet . removeListener ( this ) ; this . ringSet = ringSet ; if ( this . ringSet != null ) this . ringSet . addListener ( this ) ; notifyChanged ( ) ; }
Sets the RingSet of this ChemModel .
28,932
public void setCrystal ( ICrystal crystal ) { if ( this . crystal != null ) this . crystal . removeListener ( this ) ; this . crystal = crystal ; if ( this . crystal != null ) this . crystal . addListener ( this ) ; notifyChanged ( ) ; }
Sets the Crystal contained in this ChemModel .
28,933
public void setReactionSet ( IReactionSet sor ) { if ( this . setOfReactions != null ) this . setOfReactions . removeListener ( this ) ; this . setOfReactions = sor ; if ( this . setOfReactions != null ) this . setOfReactions . addListener ( this ) ; notifyChanged ( ) ; }
Sets the ReactionSet contained in this ChemModel .
28,934
public static IAtomContainer makeDeepCopy ( IAtomContainer container ) { IAtomContainer newAtomContainer = DefaultChemObjectBuilder . getInstance ( ) . newInstance ( IAtomContainer . class ) ; int lonePairCount = container . getLonePairCount ( ) ; int singleElectronCount = container . getSingleElectronCount ( ) ; ILonePair [ ] lonePairs = new ILonePair [ lonePairCount ] ; ISingleElectron [ ] singleElectrons = new ISingleElectron [ singleElectronCount ] ; IAtom [ ] atoms = copyAtoms ( container , newAtomContainer ) ; copyBonds ( atoms , container , newAtomContainer ) ; for ( int index = 0 ; index < container . getLonePairCount ( ) ; index ++ ) { if ( container . getAtom ( index ) . getSymbol ( ) . equalsIgnoreCase ( "R" ) ) { lonePairs [ index ] = DefaultChemObjectBuilder . getInstance ( ) . newInstance ( ILonePair . class , container . getAtom ( index ) ) ; } newAtomContainer . addLonePair ( lonePairs [ index ] ) ; } for ( int index = 0 ; index < container . getSingleElectronCount ( ) ; index ++ ) { singleElectrons [ index ] = DefaultChemObjectBuilder . getInstance ( ) . newInstance ( ISingleElectron . class , container . getAtom ( index ) ) ; newAtomContainer . addSingleElectron ( singleElectrons [ index ] ) ; } newAtomContainer . addProperties ( container . getProperties ( ) ) ; newAtomContainer . setFlags ( container . getFlags ( ) ) ; newAtomContainer . setID ( container . getID ( ) ) ; newAtomContainer . notifyChanged ( ) ; return newAtomContainer ; }
Returns deep copy of the molecule
28,935
public static void aromatizeMolecule ( IAtomContainer mol ) { IRingSet ringSet = null ; try { AllRingsFinder arf = new AllRingsFinder ( ) ; ringSet = arf . findAllRings ( mol ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } try { SMSDNormalizer . percieveAtomTypesAndConfigureAtoms ( mol ) ; Aromaticity . cdkLegacy ( ) . apply ( mol ) ; RingSetManipulator . markAromaticRings ( ringSet ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } for ( int i = 0 ; i <= mol . getAtomCount ( ) - 1 ; i ++ ) { mol . getAtom ( i ) . setFlag ( CDKConstants . ISAROMATIC , false ) ; jloop : for ( int j = 0 ; j <= ringSet . getAtomContainerCount ( ) - 1 ; j ++ ) { IRing ring = ( IRing ) ringSet . getAtomContainer ( j ) ; if ( ! ring . getFlag ( CDKConstants . ISAROMATIC ) ) { continue jloop ; } boolean haveatom = ring . contains ( mol . getAtom ( i ) ) ; if ( haveatom && ring . getAtomCount ( ) == 6 ) { mol . getAtom ( i ) . setFlag ( CDKConstants . ISAROMATIC , true ) ; } } } }
This function finds rings and uses aromaticity detection code to aromatize the molecule .
28,936
public static int getImplicitHydrogenCount ( IAtomContainer atomContainer , IAtom atom ) { return atom . getImplicitHydrogenCount ( ) == CDKConstants . UNSET ? 0 : atom . getImplicitHydrogenCount ( ) ; }
Returns The number of Implicit Hydrogen Count for a given IAtom .
28,937
protected void fireFrameRead ( ) { for ( IChemObjectIOListener chemListener : getListeners ( ) ) { IReaderListener listener = ( IReaderListener ) chemListener ; if ( frameReadEvent == null ) { frameReadEvent = new ReaderEvent ( this ) ; } listener . frameRead ( frameReadEvent ) ; } }
Sends a frame read event to the registered ReaderListeners .
28,938
public DescriptorValue calculate ( IAtomContainer container ) { double bpol = 0 ; int atomicNumber0 ; int atomicNumber1 ; double difference ; try { IsotopeFactory ifac = Isotopes . getInstance ( ) ; IElement element0 ; IElement element1 ; String symbol0 ; String symbol1 ; for ( IBond bond : container . bonds ( ) ) { IAtom atom0 = bond . getBegin ( ) ; IAtom atom1 = bond . getEnd ( ) ; symbol0 = atom0 . getSymbol ( ) ; symbol1 = atom1 . getSymbol ( ) ; element0 = ifac . getElement ( symbol0 ) ; element1 = ifac . getElement ( symbol1 ) ; atomicNumber0 = element0 . getAtomicNumber ( ) ; atomicNumber1 = element1 . getAtomicNumber ( ) ; difference = polarizabilities [ atomicNumber0 ] - polarizabilities [ atomicNumber1 ] ; bpol += Math . abs ( difference ) ; } for ( IAtom atom : container . atoms ( ) ) { int impH = atom . getImplicitHydrogenCount ( ) == CDKConstants . UNSET ? 0 : atom . getImplicitHydrogenCount ( ) ; IElement elem = ifac . getElement ( atom . getSymbol ( ) ) ; int atnum = elem . getAtomicNumber ( ) ; difference = Math . abs ( polarizabilities [ atnum ] - polarizabilities [ 1 ] ) * impH ; bpol += difference ; } return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( bpol ) , getDescriptorNames ( ) ) ; } catch ( Exception ex1 ) { logger . debug ( ex1 ) ; return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( Double . NaN ) , getDescriptorNames ( ) , new CDKException ( "Problems with IsotopeFactory due to " + ex1 . toString ( ) , ex1 ) ) ; } }
This method calculate the sum of the absolute value of the difference between atomic polarizabilities of all bonded atoms in the molecule
28,939
public static void displayMatrix ( double [ ] [ ] matrix ) { String line ; for ( int f = 0 ; f < matrix . length ; f ++ ) { line = "" ; for ( int g = 0 ; g < matrix . length ; g ++ ) { line += matrix [ g ] [ f ] + " | " ; } logger . debug ( line ) ; } }
Lists a 2D double matrix to the System console .
28,940
public static void displayArray ( int [ ] array ) { String line = "" ; for ( int f = 0 ; f < array . length ; f ++ ) { line += array [ f ] + " | " ; } logger . debug ( line ) ; }
Lists a 1D array to the System console .
28,941
public void write ( IChemObject object ) throws CDKException { if ( object instanceof ICrystal ) { writeCrystal ( ( ICrystal ) object ) ; } else { throw new CDKException ( "Only Crystal objects can be read." ) ; } }
Serializes the IChemObject to ShelX and redirects it to the output Writer .
28,942
private void setActiveCenters ( IAtomContainer reactant ) throws CDKException { Iterator < IAtom > atoms = reactant . atoms ( ) . iterator ( ) ; while ( atoms . hasNext ( ) ) { IAtom atom = atoms . next ( ) ; if ( reactant . getConnectedLonePairsCount ( atom ) > 0 && reactant . getConnectedSingleElectronsCount ( atom ) == 0 ) atom . setFlag ( CDKConstants . REACTIVE_CENTER , true ) ; } }
set the active center for this molecule . The active center will be heteroatoms which contain at least one group of lone pair electrons .
28,943
public static void add3DCoordinates1 ( IAtomContainer atomContainer ) { IAtomContainer noCoords = atomContainer . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; IAtomContainer refAtoms = atomContainer . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; for ( int i = 0 ; i < atomContainer . getAtomCount ( ) ; i ++ ) { IAtom atom = atomContainer . getAtom ( i ) ; if ( atom . getPoint3d ( ) == null ) { List < IAtom > connectedAtoms = atomContainer . getConnectedAtomsList ( atom ) ; if ( connectedAtoms . size ( ) == 1 ) { IAtom refAtom = ( IAtom ) connectedAtoms . get ( 0 ) ; ; if ( refAtom . getPoint3d ( ) != null ) { refAtoms . addAtom ( refAtom ) ; noCoords . addAtom ( atom ) ; noCoords . addAtom ( refAtom ) ; noCoords . addBond ( atomContainer . getBuilder ( ) . newInstance ( IBond . class , atom , refAtom , Order . SINGLE ) ) ; } } } } double length = 1.0 ; double angle = TETRAHEDRAL_ANGLE ; for ( int i = 0 ; i < refAtoms . getAtomCount ( ) ; i ++ ) { IAtom refAtom = refAtoms . getAtom ( i ) ; List < IAtom > noCoordLigands = noCoords . getConnectedAtomsList ( refAtom ) ; int nLigands = noCoordLigands . size ( ) ; int nwanted = nLigands ; String elementType = refAtom . getSymbol ( ) ; if ( elementType . equals ( "N" ) || elementType . equals ( "O" ) || elementType . equals ( "S" ) ) { nwanted = 3 ; } Point3d [ ] newPoints = calculate3DCoordinatesForLigands ( atomContainer , refAtom , nwanted , length , angle ) ; for ( int j = 0 ; j < nLigands ; j ++ ) { IAtom ligand = ( IAtom ) noCoordLigands . get ( j ) ; Point3d newPoint = rescaleBondLength ( refAtom , ligand , newPoints [ j ] ) ; ligand . setPoint3d ( newPoint ) ; } } }
Generate coordinates for all atoms which are singly bonded and have no coordinates . This is useful when hydrogens are present but have no coordinates . It knows about C O N S only and will give tetrahedral or trigonal geometry elsewhere . Bond lengths are computed from covalent radii if available . Angles are tetrahedral or trigonal
28,944
public static Point3d rescaleBondLength ( IAtom atom1 , IAtom atom2 , Point3d point2 ) { Point3d point1 = atom1 . getPoint3d ( ) ; double d1 = atom1 . getCovalentRadius ( ) ; double d2 = atom2 . getCovalentRadius ( ) ; double distance = ( d1 < 0.1 || d2 < 0.1 ) ? 1.0 : atom1 . getCovalentRadius ( ) + atom2 . getCovalentRadius ( ) ; Vector3d vect = new Vector3d ( point2 ) ; vect . sub ( point1 ) ; vect . normalize ( ) ; vect . scale ( distance ) ; Point3d newPoint = new Point3d ( point1 ) ; newPoint . add ( vect ) ; return newPoint ; }
Rescales Point2 so that length 1 - 2 is sum of covalent radii . if covalent radii cannot be found use bond length of 1 . 0
28,945
protected void newAtomData ( ) { atomCounter = 0 ; elsym = new ArrayList < String > ( ) ; elid = new ArrayList < String > ( ) ; eltitles = new ArrayList < String > ( ) ; formalCharges = new ArrayList < String > ( ) ; partialCharges = new ArrayList < String > ( ) ; isotope = new ArrayList < String > ( ) ; atomicNumbers = new ArrayList < String > ( ) ; exactMasses = new ArrayList < String > ( ) ; x3 = new ArrayList < String > ( ) ; y3 = new ArrayList < String > ( ) ; z3 = new ArrayList < String > ( ) ; x2 = new ArrayList < String > ( ) ; y2 = new ArrayList < String > ( ) ; xfract = new ArrayList < String > ( ) ; yfract = new ArrayList < String > ( ) ; zfract = new ArrayList < String > ( ) ; hCounts = new ArrayList < String > ( ) ; atomParities = new ArrayList < String > ( ) ; parityARef1 = new ArrayList < String > ( ) ; parityARef2 = new ArrayList < String > ( ) ; parityARef3 = new ArrayList < String > ( ) ; parityARef4 = new ArrayList < String > ( ) ; atomAromaticities = new ArrayList < String > ( ) ; atomDictRefs = new ArrayList < String > ( ) ; spinMultiplicities = new ArrayList < String > ( ) ; occupancies = new ArrayList < String > ( ) ; atomCustomProperty = new HashMap < Integer , List < String > > ( ) ; }
Clean all data about read atoms .
28,946
protected void newBondData ( ) { bondCounter = 0 ; bondid = new ArrayList < String > ( ) ; bondARef1 = new ArrayList < String > ( ) ; bondARef2 = new ArrayList < String > ( ) ; order = new ArrayList < String > ( ) ; bondStereo = new ArrayList < String > ( ) ; bondCustomProperty = new Hashtable < String , Map < String , String > > ( ) ; bondDictRefs = new ArrayList < String > ( ) ; bondElid = new ArrayList < String > ( ) ; bondAromaticity = new ArrayList < Boolean > ( ) ; }
Clean all data about read bonds .
28,947
public static double atof ( String s ) { int i = 0 ; int sign = 1 ; double r = 0 ; double p = 1 ; int state = 0 ; while ( i < s . length ( ) && Character . isWhitespace ( s . charAt ( i ) ) ) i ++ ; if ( i < s . length ( ) && s . charAt ( i ) == '-' ) { sign = - 1 ; i ++ ; } else if ( i < s . length ( ) && s . charAt ( i ) == '+' ) { i ++ ; } while ( i < s . length ( ) ) { char ch = s . charAt ( i ) ; if ( '0' <= ch && ch <= '9' ) { if ( state == 0 ) r = r * 10 + ch - '0' ; else if ( state == 1 ) { p = p / 10 ; r = r + p * ( ch - '0' ) ; } } else if ( ch == '.' ) { if ( state == 0 ) state = 1 ; else return sign * r ; } else if ( ch == 'e' || ch == 'E' || ch == 'd' || ch == 'D' ) { long e = ( int ) parseLong ( s . substring ( i + 1 ) , 10 ) ; return sign * r * Math . pow ( 10 , e ) ; } else return sign * r ; i ++ ; } return sign * r ; }
Converts a string of digits to an double .
28,948
public DescriptorValue calculate ( IAtomContainer mol ) { try { mol = mol . clone ( ) ; } catch ( CloneNotSupportedException ex ) { } double polar = 0 , weight = 0 ; try { IChemObjectBuilder builder = mol . getBuilder ( ) ; CDKAtomTypeMatcher matcher = CDKAtomTypeMatcher . getInstance ( builder ) ; for ( IAtom atom : mol . atoms ( ) ) { IAtomType type = matcher . findMatchingAtomType ( mol , atom ) ; AtomTypeManipulator . configure ( atom , type ) ; } CDKHydrogenAdder adder = CDKHydrogenAdder . getInstance ( builder ) ; adder . addImplicitHydrogens ( mol ) ; TPSADescriptor tpsa = new TPSADescriptor ( ) ; DescriptorValue value = tpsa . calculate ( mol ) ; polar = ( ( DoubleResult ) value . getValue ( ) ) . doubleValue ( ) ; for ( IAtom atom : mol . atoms ( ) ) { weight += Isotopes . getInstance ( ) . getMajorIsotope ( atom . getSymbol ( ) ) . getExactMass ( ) ; Integer hcount = atom . getImplicitHydrogenCount ( ) ; if ( hcount != CDKConstants . UNSET ) weight += hcount * 1.00782504 ; } } catch ( CDKException | IOException exception ) { return getDummyDescriptorValue ( exception ) ; } return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( weight == 0 ? 0 : polar / weight ) , getDescriptorNames ( ) ) ; }
Calculates the topological polar surface area and expresses it as a ratio to molecule size .
28,949
public static IAtomContainerSet partitionIntoMolecules ( IAtomContainer container ) { ConnectedComponents cc = new ConnectedComponents ( GraphUtil . toAdjList ( container ) ) ; return partitionIntoMolecules ( container , cc . components ( ) ) ; }
Partitions the atoms in an AtomContainer into covalently connected components .
28,950
public static double [ ] [ ] getMatrix ( IAtomContainer container ) { IBond bond = null ; int indexAtom1 ; int indexAtom2 ; double [ ] [ ] conMat = new double [ container . getAtomCount ( ) ] [ container . getAtomCount ( ) ] ; for ( int f = 0 ; f < container . getBondCount ( ) ; f ++ ) { bond = container . getBond ( f ) ; indexAtom1 = container . indexOf ( bond . getBegin ( ) ) ; indexAtom2 = container . indexOf ( bond . getEnd ( ) ) ; conMat [ indexAtom1 ] [ indexAtom2 ] = BondManipulator . destroyBondOrder ( bond . getOrder ( ) ) ; conMat [ indexAtom2 ] [ indexAtom1 ] = BondManipulator . destroyBondOrder ( bond . getOrder ( ) ) ; } return conMat ; }
Returns the connection matrix representation of this AtomContainer .
28,951
public boolean isIdentity ( ) { for ( int i = 0 ; i < this . values . length ; i ++ ) { if ( this . values [ i ] != i ) { return false ; } } return true ; }
Check to see if this permutation is the identity permutation .
28,952
public void setTo ( Permutation other ) { if ( this . values . length != other . values . length ) throw new IllegalArgumentException ( "permutations are different size" ) ; for ( int i = 0 ; i < this . values . length ; i ++ ) { this . values [ i ] = other . values [ i ] ; } }
Alter a permutation by setting it to the values in the other permutation .
28,953
public String toCycleString ( ) { int n = this . values . length ; boolean [ ] p = new boolean [ n ] ; Arrays . fill ( p , true ) ; StringBuilder sb = new StringBuilder ( ) ; int j = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( p [ i ] ) { sb . append ( '(' ) ; sb . append ( i ) ; p [ i ] = false ; j = i ; while ( p [ values [ j ] ] ) { sb . append ( ", " ) ; j = values [ j ] ; sb . append ( j ) ; p [ j ] = false ; } sb . append ( ')' ) ; } } return sb . toString ( ) ; }
An easily - readable version of the permutation as a product of cycles .
28,954
static boolean isSelected ( IChemObject object , RendererModel model ) { if ( object . getProperty ( StandardGenerator . HIGHLIGHT_COLOR ) != null ) return true ; if ( model . getSelection ( ) != null ) return model . getSelection ( ) . contains ( object ) ; return false ; }
Determine if an object is selected .
28,955
static boolean hasSelectedBond ( List < IBond > bonds , RendererModel model ) { for ( IBond bond : bonds ) { if ( isSelected ( bond , model ) ) return true ; } return false ; }
Determines if any bond in the list is selected
28,956
public void add ( double x , double y ) { if ( x < minX ) minX = x ; if ( y < minY ) minY = y ; if ( x > maxX ) maxX = x ; if ( y > maxY ) maxY = y ; }
Ensure the point x y is included in the bounding box .
28,957
public void add ( Bounds bounds ) { if ( bounds . minX < minX ) minX = bounds . minX ; if ( bounds . minY < minY ) minY = bounds . minY ; if ( bounds . maxX > maxX ) maxX = bounds . maxX ; if ( bounds . maxY > maxY ) maxY = bounds . maxY ; }
Add one bounds to another .
28,958
private void add ( GeneralPath path ) { double [ ] points = new double [ 6 ] ; for ( org . openscience . cdk . renderer . elements . path . PathElement element : path . elements ) { element . points ( points ) ; switch ( element . type ( ) ) { case MoveTo : case LineTo : add ( points [ 0 ] , points [ 1 ] ) ; break ; case QuadTo : add ( points [ 2 ] , points [ 3 ] ) ; break ; case CubicTo : add ( points [ 4 ] , points [ 5 ] ) ; break ; } } }
Add the provided general path to the bounding box .
28,959
public DescriptorValue calculate ( IAtom atom , IAtomContainer ac ) { if ( factory == null ) try { factory = AtomTypeFactory . getInstance ( "org/openscience/cdk/config/data/jmol_atomtypes.txt" , ac . getBuilder ( ) ) ; } catch ( Exception exception ) { return getDummyDescriptorValue ( exception ) ; } Iterator < IAtom > allAtoms = ac . atoms ( ) . iterator ( ) ; double atomicSoftness ; double radiusTarget ; atomicSoftness = 0 ; double partial ; double radius ; String symbol ; IAtomType type ; try { symbol = atom . getSymbol ( ) ; type = factory . getAtomType ( symbol ) ; radiusTarget = type . getCovalentRadius ( ) ; } catch ( Exception execption ) { logger . debug ( execption ) ; return getDummyDescriptorValue ( execption ) ; } while ( allAtoms . hasNext ( ) ) { IAtom curAtom = ( IAtom ) allAtoms . next ( ) ; if ( atom . getPoint3d ( ) == null || curAtom . getPoint3d ( ) == null ) { return getDummyDescriptorValue ( new CDKException ( "The target atom or current atom had no 3D coordinates. These are required" ) ) ; } if ( ! atom . equals ( curAtom ) ) { partial = 0 ; symbol = curAtom . getSymbol ( ) ; try { type = factory . getAtomType ( symbol ) ; } catch ( Exception exception ) { logger . debug ( exception ) ; return getDummyDescriptorValue ( exception ) ; } radius = type . getCovalentRadius ( ) ; partial += radius * radius ; partial += ( radiusTarget * radiusTarget ) ; partial = partial / ( calculateSquareDistanceBetweenTwoAtoms ( curAtom , atom ) ) ; atomicSoftness += partial ; } } atomicSoftness = 2 * atomicSoftness ; atomicSoftness = atomicSoftness * 0.172 ; return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( atomicSoftness ) , NAMES ) ; }
It is needed to call the addExplicitHydrogensToSatisfyValency method from the class tools . HydrogenAdder and 3D coordinates .
28,960
private TextElement makePlus ( Rectangle2D moleculeBox1 , Rectangle2D moleculeBox2 , double axis , Color color ) { double arrowCenter = ( moleculeBox1 . getCenterX ( ) + moleculeBox2 . getCenterX ( ) ) / 2 ; return new TextElement ( arrowCenter , axis , "+" , color ) ; }
Place a + sign between two molecules .
28,961
private void print ( String level , SAXParseException exception ) { if ( level . equals ( "warning" ) ) { logger . warn ( "** " + level + ": " + exception . getMessage ( ) ) ; logger . warn ( " URI = " + exception . getSystemId ( ) ) ; logger . warn ( " line = " + exception . getLineNumber ( ) ) ; } else { logger . error ( "** " + level + ": " + exception . getMessage ( ) ) ; logger . error ( " URI = " + exception . getSystemId ( ) ) ; logger . error ( " line = " + exception . getLineNumber ( ) ) ; } }
Internal procedure that outputs an SAXParseException with a significance level to the cdk . tools . LoggingTool logger .
28,962
public void error ( SAXParseException exception ) throws SAXException { if ( reportErrors ) print ( "error" , exception ) ; if ( abortOnErrors ) throw exception ; }
Outputs a SAXParseException error to the logger .
28,963
public void fatalError ( SAXParseException exception ) throws SAXException { if ( reportErrors ) print ( "fatal" , exception ) ; if ( abortOnErrors ) throw exception ; }
Outputs as fatal SAXParseException error to the logger .
28,964
public static SymbolVisibility all ( ) { return new SymbolVisibility ( ) { public boolean visible ( IAtom atom , List < IBond > neighbors , RendererModel model ) { return true ; } } ; }
All atom symbols are visible .
28,965
public synchronized void sortResultsByStereoAndBondMatch ( ) throws CDKException { Map < Integer , Map < Integer , Integer > > allStereoMCS = new HashMap < Integer , Map < Integer , Integer > > ( ) ; Map < Integer , Map < IAtom , IAtom > > allStereoAtomMCS = new HashMap < Integer , Map < IAtom , IAtom > > ( ) ; Map < Integer , Integer > fragmentScoreMap = new TreeMap < Integer , Integer > ( ) ; Map < Integer , Double > energyScoreMap = new TreeMap < Integer , Double > ( ) ; Map < Integer , Double > stereoScoreMap = new HashMap < Integer , Double > ( ) ; initializeMaps ( allStereoMCS , allStereoAtomMCS , stereoScoreMap , fragmentScoreMap , energyScoreMap ) ; boolean stereoMatchFlag = getStereoBondChargeMatch ( stereoScoreMap , allStereoMCS , allStereoAtomMCS ) ; boolean flag = false ; if ( stereoMatchFlag ) { stereoScoreMap = sortMapByValueInDecendingOrder ( stereoScoreMap ) ; double higestStereoScore = stereoScoreMap . isEmpty ( ) ? 0 : stereoScoreMap . values ( ) . iterator ( ) . next ( ) ; double secondhigestStereoScore = higestStereoScore ; for ( Integer key : stereoScoreMap . keySet ( ) ) { if ( secondhigestStereoScore < higestStereoScore && stereoScoreMap . get ( key ) > secondhigestStereoScore ) { secondhigestStereoScore = stereoScoreMap . get ( key ) ; } else if ( secondhigestStereoScore == higestStereoScore && stereoScoreMap . get ( key ) < secondhigestStereoScore ) { secondhigestStereoScore = stereoScoreMap . get ( key ) ; } } if ( ! stereoScoreMap . isEmpty ( ) ) { flag = true ; clear ( ) ; } int counter = 0 ; for ( Integer i : stereoScoreMap . keySet ( ) ) { if ( higestStereoScore == stereoScoreMap . get ( i ) . doubleValue ( ) ) { addSolution ( counter , i , allStereoAtomMCS , allStereoMCS , stereoScoreMap , energyScoreMap , fragmentScoreMap ) ; counter ++ ; } } if ( flag ) { firstSolution . putAll ( allMCS . get ( 0 ) ) ; firstAtomMCS . putAll ( allAtomMCS . get ( 0 ) ) ; clear ( allStereoMCS , allStereoAtomMCS , stereoScoreMap , fragmentScoreMap , energyScoreMap ) ; } } }
Sort MCS solution by stereo and bond type matches .
28,966
public synchronized void sortResultsByFragments ( ) { Map < Integer , Map < Integer , Integer > > allFragmentMCS = new TreeMap < Integer , Map < Integer , Integer > > ( ) ; Map < Integer , Map < IAtom , IAtom > > allFragmentAtomMCS = new TreeMap < Integer , Map < IAtom , IAtom > > ( ) ; Map < Integer , Double > stereoScoreMap = new TreeMap < Integer , Double > ( ) ; Map < Integer , Double > energyScoreMap = new TreeMap < Integer , Double > ( ) ; Map < Integer , Integer > fragmentScoreMap = new TreeMap < Integer , Integer > ( ) ; initializeMaps ( allFragmentMCS , allFragmentAtomMCS , stereoScoreMap , fragmentScoreMap , energyScoreMap ) ; int minFragmentScore = 9999 ; for ( Integer key : allFragmentAtomMCS . keySet ( ) ) { Map < IAtom , IAtom > mcsAtom = allFragmentAtomMCS . get ( key ) ; int fragmentCount = getMappedMoleculeFragmentSize ( mcsAtom ) ; fragmentScoreMap . put ( key , fragmentCount ) ; if ( minFragmentScore > fragmentCount ) { minFragmentScore = fragmentCount ; } } boolean flag = false ; if ( minFragmentScore < 9999 ) { flag = true ; clear ( ) ; } int counter = 0 ; for ( Map . Entry < Integer , Integer > map : fragmentScoreMap . entrySet ( ) ) { if ( minFragmentScore == map . getValue ( ) . intValue ( ) ) { addSolution ( counter , map . getKey ( ) , allFragmentAtomMCS , allFragmentMCS , stereoScoreMap , energyScoreMap , fragmentScoreMap ) ; counter ++ ; } } if ( flag ) { firstSolution . putAll ( allMCS . get ( 0 ) ) ; firstAtomMCS . putAll ( allAtomMCS . get ( 0 ) ) ; clear ( allFragmentMCS , allFragmentAtomMCS , stereoScoreMap , fragmentScoreMap , energyScoreMap ) ; } }
Sort solution by ascending order of the fragment count .
28,967
public synchronized void sortResultsByEnergies ( ) throws CDKException { Map < Integer , Map < Integer , Integer > > allEnergyMCS = new TreeMap < Integer , Map < Integer , Integer > > ( ) ; Map < Integer , Map < IAtom , IAtom > > allEnergyAtomMCS = new TreeMap < Integer , Map < IAtom , IAtom > > ( ) ; Map < Integer , Double > stereoScoreMap = new TreeMap < Integer , Double > ( ) ; Map < Integer , Integer > fragmentScoreMap = new TreeMap < Integer , Integer > ( ) ; Map < Integer , Double > energySelectionMap = new TreeMap < Integer , Double > ( ) ; initializeMaps ( allEnergyMCS , allEnergyAtomMCS , stereoScoreMap , fragmentScoreMap , energySelectionMap ) ; for ( Integer key : allEnergyMCS . keySet ( ) ) { Map < Integer , Integer > mcsAtom = allEnergyMCS . get ( key ) ; Double energies = getMappedMoleculeEnergies ( mcsAtom ) ; energySelectionMap . put ( key , energies ) ; } energySelectionMap = sortMapByValueInAccendingOrder ( energySelectionMap ) ; boolean flag = false ; double lowestEnergyScore = 99999999.99 ; for ( Integer key : energySelectionMap . keySet ( ) ) { lowestEnergyScore = energySelectionMap . get ( key ) . doubleValue ( ) ; flag = true ; clear ( ) ; break ; } int counter = 0 ; for ( Map . Entry < Integer , Double > map : energySelectionMap . entrySet ( ) ) { if ( lowestEnergyScore == map . getValue ( ) . doubleValue ( ) ) { addSolution ( counter , map . getKey ( ) , allEnergyAtomMCS , allEnergyMCS , stereoScoreMap , energySelectionMap , fragmentScoreMap ) ; counter ++ ; } } if ( flag ) { firstSolution . putAll ( allMCS . get ( 0 ) ) ; firstAtomMCS . putAll ( allAtomMCS . get ( 0 ) ) ; clear ( allEnergyMCS , allEnergyAtomMCS , stereoScoreMap , fragmentScoreMap , energySelectionMap ) ; } }
Sort MCS solution by bond breaking energy .
28,968
public static int convertBondStereo ( IBond bond ) { int value = 0 ; switch ( bond . getStereo ( ) ) { case UP : value = 1 ; break ; case UP_INVERTED : value = 1 ; break ; case DOWN : value = 6 ; break ; case DOWN_INVERTED : value = 6 ; break ; case UP_OR_DOWN : value = 4 ; break ; case UP_OR_DOWN_INVERTED : value = 4 ; break ; case E_OR_Z : value = 3 ; break ; default : value = 0 ; } return value ; }
Get stereo value as integer
28,969
public static IBond . Stereo convertStereo ( int stereoValue ) { IBond . Stereo stereo = IBond . Stereo . NONE ; if ( stereoValue == 1 ) { stereo = IBond . Stereo . UP ; } else if ( stereoValue == 6 ) { stereo = IBond . Stereo . DOWN ; } else if ( stereoValue == 0 ) { stereo = IBond . Stereo . NONE ; } else if ( stereoValue == 4 ) { stereo = IBond . Stereo . UP_OR_DOWN ; } else if ( stereoValue == 3 ) { stereo = IBond . Stereo . E_OR_Z ; } return stereo ; }
Get stereo value as Stereo enum
28,970
List < IStereoElement > recognise ( Set < Projection > projections ) { if ( ! projections . contains ( Projection . Fischer ) ) return Collections . emptyList ( ) ; Map < IAtom , Integer > atomToIndex = new HashMap < IAtom , Integer > ( ) ; for ( IAtom atom : container . atoms ( ) ) { if ( atom . getPoint2d ( ) == null ) return Collections . emptyList ( ) ; atomToIndex . put ( atom , atomToIndex . size ( ) ) ; } RingSearch ringSearch = new RingSearch ( container , graph ) ; final List < IStereoElement > elements = new ArrayList < IStereoElement > ( 5 ) ; for ( int v = 0 ; v < container . getAtomCount ( ) ; v ++ ) { IAtom focus = container . getAtom ( v ) ; Elements elem = Elements . ofNumber ( focus . getAtomicNumber ( ) ) ; if ( elem != Carbon ) continue ; if ( ringSearch . cyclic ( v ) ) continue ; if ( stereocenters . elementType ( v ) != Tetracoordinate ) continue ; if ( ! stereocenters . isStereocenter ( v ) ) continue ; ITetrahedralChirality element = newTetrahedralCenter ( focus , neighbors ( v , graph , bonds ) ) ; if ( element == null ) continue ; IAtom east = element . getLigands ( ) [ EAST ] ; IAtom west = element . getLigands ( ) [ WEST ] ; if ( ! east . equals ( focus ) && ! isTerminal ( east , atomToIndex ) ) continue ; if ( ! west . equals ( focus ) && ! isTerminal ( west , atomToIndex ) ) continue ; elements . add ( element ) ; } return elements ; }
Recognise the tetrahedral stereochemistry in the provided structure .
28,971
static ITetrahedralChirality newTetrahedralCenter ( IAtom focus , IBond [ ] bonds ) { IBond [ ] cardinalBonds = cardinalBonds ( focus , bonds ) ; if ( cardinalBonds == null ) return null ; if ( ! isPlanarSigmaBond ( cardinalBonds [ NORTH ] ) || ! isPlanarSigmaBond ( cardinalBonds [ SOUTH ] ) ) return null ; if ( cardinalBonds [ EAST ] == null && cardinalBonds [ WEST ] == null ) return null ; IAtom [ ] neighbors = new IAtom [ ] { cardinalBonds [ NORTH ] . getOther ( focus ) , focus , cardinalBonds [ SOUTH ] . getOther ( focus ) , focus } ; if ( isPlanarSigmaBond ( cardinalBonds [ EAST ] ) ) { neighbors [ EAST ] = cardinalBonds [ EAST ] . getOther ( focus ) ; } else if ( cardinalBonds [ EAST ] != null || bonds . length == 4 ) { return null ; } if ( isPlanarSigmaBond ( cardinalBonds [ WEST ] ) ) { neighbors [ WEST ] = cardinalBonds [ WEST ] . getOther ( focus ) ; } else if ( cardinalBonds [ WEST ] != null || bonds . length == 4 ) { return null ; } return new TetrahedralChirality ( focus , neighbors , ANTI_CLOCKWISE ) ; }
Create a new tetrahedral stereocenter of the given focus and neighboring bonds . This is an internal method and is presumed the atom can support tetrahedral stereochemistry and it has three or four explicit neighbors .
28,972
private boolean isTerminal ( IAtom atom , Map < IAtom , Integer > atomToIndex ) { return graph [ atomToIndex . get ( atom ) ] . length == 1 ; }
Is the atom terminal having only one connection .
28,973
private static IBond [ ] neighbors ( int v , int [ ] [ ] g , EdgeToBondMap bondMap ) { int [ ] ws = g [ v ] ; IBond [ ] bonds = new IBond [ ws . length ] ; for ( int i = 0 ; i < ws . length ; i ++ ) { bonds [ i ] = bondMap . get ( v , ws [ i ] ) ; } return bonds ; }
Helper method to obtain the neighbouring bonds from an adjacency list graph and edge - > bond map .
28,974
private static boolean match ( String regExp , String userInput ) { Pattern pattern = Pattern . compile ( regExp ) ; Matcher matcher = pattern . matcher ( userInput ) ; if ( matcher . find ( ) ) return true ; else return false ; }
Helper method for regular expression matching .
28,975
AtomSymbol addAnnotation ( TextOutline annotation ) { List < TextOutline > newAnnotations = new ArrayList < TextOutline > ( annotationAdjuncts ) ; newAnnotations . add ( annotation ) ; return new AtomSymbol ( element , adjuncts , newAnnotations , alignment , hull ) ; }
Include a new annotation adjunct in the atom symbol .
28,976
Point2D getAlignmentCenter ( ) { if ( alignment == SymbolAlignment . Left ) { return element . getFirstGlyphCenter ( ) ; } else if ( alignment == SymbolAlignment . Right ) { return element . getLastGlyphCenter ( ) ; } else { return element . getCenter ( ) ; } }
Access the center point of the symbol . The center point is determined by the alignment .
28,977
List < Shape > getOutlines ( ) { List < Shape > shapes = new ArrayList < Shape > ( ) ; shapes . add ( element . getOutline ( ) ) ; for ( TextOutline adjunct : adjuncts ) shapes . add ( adjunct . getOutline ( ) ) ; return shapes ; }
Access the Java 2D shape text outlines that display the atom symbol .
28,978
List < Shape > getAnnotationOutlines ( ) { List < Shape > shapes = new ArrayList < Shape > ( ) ; for ( TextOutline adjunct : annotationAdjuncts ) shapes . add ( adjunct . getOutline ( ) ) ; return shapes ; }
Access the java . awt . Shape outlines of each annotation adjunct .
28,979
AtomSymbol transform ( AffineTransform transform ) { List < TextOutline > transformedAdjuncts = new ArrayList < TextOutline > ( adjuncts . size ( ) ) ; for ( TextOutline adjunct : adjuncts ) transformedAdjuncts . add ( adjunct . transform ( transform ) ) ; List < TextOutline > transformedAnnAdjuncts = new ArrayList < TextOutline > ( adjuncts . size ( ) ) ; for ( TextOutline adjunct : annotationAdjuncts ) transformedAnnAdjuncts . add ( adjunct . transform ( transform ) ) ; return new AtomSymbol ( element . transform ( transform ) , transformedAdjuncts , transformedAnnAdjuncts , alignment , hull . transform ( transform ) ) ; }
Transform the position and orientation of the symbol .
28,980
AtomSymbol resize ( double scaleX , double scaleY ) { Point2D center = element . getCenter ( ) ; AffineTransform transform = new AffineTransform ( ) ; transform . translate ( center . getX ( ) , center . getY ( ) ) ; transform . scale ( scaleX , scaleY ) ; transform . translate ( - center . getX ( ) , - center . getY ( ) ) ; return transform ( transform ) ; }
Convenience function to resize an atom symbol .
28,981
AtomSymbol center ( double x , double y ) { Point2D center = getAlignmentCenter ( ) ; return translate ( x - center . getX ( ) , y - center . getY ( ) ) ; }
Convenience function to center an atom symbol on a specified point . The centering depends on the symbol alignment .
28,982
public StereoElementFactory interpretProjections ( Projection ... projections ) { Collections . addAll ( this . projections , projections ) ; this . check = true ; return this ; }
Indicate that stereochemistry drawn as a certain projection should be interpreted .
28,983
public double resolveOverlap ( IAtomContainer ac , IRingSet sssr ) { Vector overlappingAtoms = new Vector ( ) ; Vector overlappingBonds = new Vector ( ) ; logger . debug ( "Start of resolveOverlap" ) ; double overlapScore = getOverlapScore ( ac , overlappingAtoms , overlappingBonds ) ; if ( overlapScore > 0 ) { overlapScore = displace ( ac , overlappingAtoms , overlappingBonds ) ; } logger . debug ( "overlapScore = " + overlapScore ) ; logger . debug ( "End of resolveOverlap" ) ; return overlapScore ; }
Main method to be called to resolve overlap situations .
28,984
public double displace ( IAtomContainer ac , Vector overlappingAtoms , Vector overlappingBonds ) { double bondLength = GeometryUtil . getBondLengthAverage ( ac ) ; OverlapPair op = null ; IAtom a1 = null , a2 = null ; Vector2d v1 = null , v2 = null ; int steps = 0 ; int p = 0 ; double overlapScore = 0 ; double choice = 0 ; logger . debug ( "We are here because of an overlap situation." ) ; do { p = ( int ) ( Math . random ( ) * overlappingAtoms . size ( ) ) ; logger . debug ( "Taking overlap pair no. " + p ) ; op = ( OverlapPair ) overlappingAtoms . elementAt ( p ) ; a1 = ( IAtom ) op . chemObject1 ; a2 = ( IAtom ) op . chemObject2 ; v1 = new Vector2d ( a1 . getPoint2d ( ) ) ; v2 = new Vector2d ( a2 . getPoint2d ( ) ) ; v2 . sub ( v1 ) ; v2 . normalize ( ) ; if ( Double . isNaN ( v2 . x ) ) v2 . x = 0.01 ; if ( Double . isNaN ( v2 . y ) ) v2 . y = 0.01 ; v2 . scale ( bondLength / 20.0 ) ; logger . debug ( "Calculation translation vector " + v2 ) ; choice = Math . random ( ) ; if ( choice > 0.5 ) { a2 . getPoint2d ( ) . add ( v2 ) ; logger . debug ( "Random variable: " + choice + ", displacing first atom" ) ; } else { a1 . getPoint2d ( ) . sub ( v2 ) ; logger . debug ( "Random variable: " + choice + ", displacing second atom" ) ; } overlapScore = getOverlapScore ( ac , overlappingAtoms , overlappingBonds ) ; steps ++ ; } while ( overlapScore > 0 && ! ( steps > maxSteps ) ) ; if ( steps < 100 ) { logger . debug ( "Overlap situation resolved" ) ; logger . debug ( "Overlap score: " + overlapScore ) ; logger . debug ( steps + " steps needed to clear situation" ) ; } else { logger . debug ( "Could not resolve overlap situation" ) ; logger . debug ( "Number of " + steps + " steps taken exceeds limit of " + maxSteps ) ; logger . debug ( "Overlap score: " + overlapScore ) ; } return overlapScore ; }
Makes a small displacement to some atoms or rings in the given atomcontainer .
28,985
public double getOverlapScore ( IAtomContainer ac , Vector overlappingAtoms , Vector overlappingBonds ) { double overlapScore = 0 ; overlapScore = getAtomOverlapScore ( ac , overlappingAtoms ) ; return overlapScore ; }
Calculates a score based on the overlap of atoms and intersection of bonds . The overlap is calculated by summing up the distances between all pairs of atoms if they are less than half the standard bondlength apart .
28,986
public double getAtomOverlapScore ( IAtomContainer ac , Vector overlappingAtoms ) { overlappingAtoms . removeAllElements ( ) ; IAtom atom1 = null ; IAtom atom2 = null ; Point2d p1 = null ; Point2d p2 = null ; double distance = 0 ; double overlapScore = 0 ; double bondLength = GeometryUtil . getBondLengthAverage ( ac ) ; double overlapCutoff = bondLength / 4 ; logger . debug ( "Bond length is set to " + bondLength ) ; logger . debug ( "Now cyling through all pairs of atoms" ) ; for ( int f = 0 ; f < ac . getAtomCount ( ) ; f ++ ) { atom1 = ac . getAtom ( f ) ; p1 = atom1 . getPoint2d ( ) ; for ( int g = f + 1 ; g < ac . getAtomCount ( ) ; g ++ ) { atom2 = ac . getAtom ( g ) ; p2 = atom2 . getPoint2d ( ) ; distance = p1 . distance ( p2 ) ; if ( distance < overlapCutoff ) { logger . debug ( "Detected atom clash with distance: " + distance + ", which is smaller than overlapCutoff " + overlapCutoff ) ; overlapScore += overlapCutoff ; overlappingAtoms . addElement ( new OverlapPair ( atom1 , atom2 ) ) ; } } } return overlapScore ; }
Calculates a score based on the overlap of atoms . The overlap is calculated by summing up the distances between all pairs of atoms if they are less than half the standard bondlength apart .
28,987
public double getBondOverlapScore ( IAtomContainer ac , Vector overlappingBonds ) { overlappingBonds . removeAllElements ( ) ; double overlapScore = 0 ; IBond bond1 = null ; IBond bond2 = null ; double bondLength = GeometryUtil . getBondLengthAverage ( ac ) ; ; double overlapCutoff = bondLength / 2 ; for ( int f = 0 ; f < ac . getBondCount ( ) ; f ++ ) { bond1 = ac . getBond ( f ) ; for ( int g = f ; g < ac . getBondCount ( ) ; g ++ ) { bond2 = ac . getBond ( g ) ; if ( ! bond1 . isConnectedTo ( bond2 ) ) { if ( areIntersected ( bond1 , bond2 ) ) { overlapScore += overlapCutoff ; overlappingBonds . addElement ( new OverlapPair ( bond1 , bond2 ) ) ; } } } } return overlapScore ; }
Calculates a score based on the intersection of bonds .
28,988
public boolean areIntersected ( IBond bond1 , IBond bond2 ) { double x1 = 0 , x2 = 0 , x3 = 0 , x4 = 0 ; double y1 = 0 , y2 = 0 , y3 = 0 , y4 = 0 ; x1 = bond1 . getBegin ( ) . getPoint2d ( ) . x ; x2 = bond1 . getEnd ( ) . getPoint2d ( ) . x ; x3 = bond2 . getBegin ( ) . getPoint2d ( ) . x ; x4 = bond2 . getEnd ( ) . getPoint2d ( ) . x ; y1 = bond1 . getBegin ( ) . getPoint2d ( ) . y ; y2 = bond1 . getEnd ( ) . getPoint2d ( ) . y ; y3 = bond2 . getBegin ( ) . getPoint2d ( ) . y ; y4 = bond2 . getEnd ( ) . getPoint2d ( ) . y ; Line2D . Double line1 = new Line2D . Double ( new Point2D . Double ( x1 , y1 ) , new Point2D . Double ( x2 , y2 ) ) ; Line2D . Double line2 = new Line2D . Double ( new Point2D . Double ( x3 , y3 ) , new Point2D . Double ( x4 , y4 ) ) ; if ( line1 . intersectsLine ( line2 ) ) { logger . debug ( "Two intersecting bonds detected." ) ; return true ; } return false ; }
Checks if two bonds cross each other .
28,989
private void setActiveCenters ( IAtomContainer reactant ) throws CDKException { if ( AtomContainerManipulator . getTotalCharge ( reactant ) != 0 ) return ; Iterator < IBond > bondis = reactant . bonds ( ) . iterator ( ) ; while ( bondis . hasNext ( ) ) { IBond bondi = bondis . next ( ) ; if ( ( ( bondi . getOrder ( ) == IBond . Order . DOUBLE ) || ( bondi . getOrder ( ) == IBond . Order . TRIPLE ) ) ) { int chargeAtom0 = bondi . getBegin ( ) . getFormalCharge ( ) == null ? 0 : bondi . getBegin ( ) . getFormalCharge ( ) ; int chargeAtom1 = bondi . getEnd ( ) . getFormalCharge ( ) == null ? 0 : bondi . getEnd ( ) . getFormalCharge ( ) ; if ( chargeAtom0 >= 0 && chargeAtom1 >= 0 && reactant . getConnectedSingleElectronsCount ( bondi . getBegin ( ) ) == 0 && reactant . getConnectedSingleElectronsCount ( bondi . getEnd ( ) ) == 0 && reactant . getConnectedLonePairsCount ( bondi . getBegin ( ) ) == 0 && reactant . getConnectedLonePairsCount ( bondi . getEnd ( ) ) == 0 ) { bondi . setFlag ( CDKConstants . REACTIVE_CENTER , true ) ; bondi . getBegin ( ) . setFlag ( CDKConstants . REACTIVE_CENTER , true ) ; bondi . getEnd ( ) . setFlag ( CDKConstants . REACTIVE_CENTER , true ) ; } } } }
set the active center for this molecule . The active center will be those which correspond with X = Y .
28,990
public DescriptorValue calculate ( IAtom atom , IAtomContainer container ) { double value ; try { int i = container . indexOf ( atom ) ; if ( i < 0 ) throw new CDKException ( "atom was not a memeber of the provided container" ) ; container = container . clone ( ) ; atom = container . getAtom ( i ) ; AtomContainerManipulator . percieveAtomTypesAndConfigureAtoms ( container ) ; LonePairElectronChecker lpcheck = new LonePairElectronChecker ( ) ; lpcheck . saturate ( container ) ; } catch ( CDKException | CloneNotSupportedException e ) { return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( Double . NaN ) , NAMES , null ) ; } value = db . extractAffinity ( container , atom ) ; return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( value ) , NAMES ) ; }
This method calculates the protonation affinity of an atom .
28,991
public Double [ ] getMultipliers ( ) { Double [ ] returnArray = new Double [ this . atomContainerCount ] ; System . arraycopy ( this . multipliers , 0 , returnArray , 0 , this . atomContainerCount ) ; return returnArray ; }
Returns an array of double with the stoichiometric coefficients of the products .
28,992
public boolean setMultipliers ( Double [ ] newMultipliers ) { if ( newMultipliers . length == atomContainerCount ) { if ( multipliers == null ) { multipliers = new Double [ atomContainerCount ] ; } System . arraycopy ( newMultipliers , 0 , multipliers , 0 , atomContainerCount ) ; notifyChanged ( ) ; return true ; } return false ; }
Sets the multipliers of the AtomContainers .
28,993
public void addAtomContainer ( IAtomContainer atomContainer , double multiplier ) { if ( atomContainerCount + 1 >= atomContainers . length ) { growAtomContainerArray ( ) ; } atomContainer . addListener ( this ) ; atomContainers [ atomContainerCount ] = atomContainer ; multipliers [ atomContainerCount ] = multiplier ; atomContainerCount ++ ; notifyChanged ( ) ; }
Adds an atomContainer to this container with the given multiplier .
28,994
public void add ( IAtomContainerSet atomContainerSet ) { for ( IAtomContainer iter : atomContainerSet . atomContainers ( ) ) { addAtomContainer ( iter ) ; } }
Adds all atomContainers in the AtomContainerSet to this container .
28,995
public Iterable < IAtomContainer > atomContainers ( ) { return new Iterable < IAtomContainer > ( ) { public Iterator < IAtomContainer > iterator ( ) { return new AtomContainerIterator ( ) ; } } ; }
Get an iterator for this AtomContainerSet .
28,996
public Double getMultiplier ( IAtomContainer container ) { for ( int i = 0 ; i < atomContainerCount ; i ++ ) { if ( atomContainers [ i ] . equals ( container ) ) { return multipliers [ i ] ; } } return - 1.0 ; }
Returns the multiplier of the given AtomContainer .
28,997
protected void growAtomContainerArray ( ) { growArraySize = atomContainers . length ; IAtomContainer [ ] newatomContainers = new IAtomContainer [ atomContainers . length + growArraySize ] ; System . arraycopy ( atomContainers , 0 , newatomContainers , 0 , atomContainers . length ) ; atomContainers = newatomContainers ; Double [ ] newMultipliers = new Double [ multipliers . length + growArraySize ] ; System . arraycopy ( multipliers , 0 , newMultipliers , 0 , multipliers . length ) ; multipliers = newMultipliers ; }
Grows the atomContainer array by a given size .
28,998
public void sortAtomContainers ( final Comparator < IAtomContainer > comparator ) { Integer [ ] indexes = new Integer [ atomContainerCount ] ; for ( int i = 0 ; i < indexes . length ; i ++ ) indexes [ i ] = i ; Arrays . sort ( indexes , new Comparator < Integer > ( ) { public int compare ( Integer o1 , Integer o2 ) { return comparator . compare ( atomContainers [ o1 ] , atomContainers [ o2 ] ) ; } } ) ; IAtomContainer [ ] containersTmp = Arrays . copyOf ( atomContainers , indexes . length ) ; Double [ ] multipliersTmp = Arrays . copyOf ( multipliers , indexes . length ) ; for ( int i = 0 ; i < indexes . length ; i ++ ) { atomContainers [ i ] = containersTmp [ indexes [ i ] ] ; multipliers [ i ] = multipliersTmp [ indexes [ i ] ] ; } }
Sort the AtomContainers and multipliers using a provided Comparator .
28,999
public Collection essentialCycles ( ) { Collection result = new HashSet ( ) ; for ( Object subgraphBase : subgraphBases ) { SimpleCycleBasis cycleBasis = ( SimpleCycleBasis ) subgraphBase ; result . addAll ( cycleBasis . essentialCycles ( ) ) ; } return result ; }
Returns the essential cycles of this cycle basis . A essential cycle is contained in every minimum cycle basis of a graph .