idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
28,800
protected IAtomContainer buildMolecule ( int mainChain , List < AttachedGroup > attachedSubstituents , List < AttachedGroup > attachedGroups , boolean isMainCyclic , String name ) throws ParseException , CDKException { currentMolecule . setID ( name ) ; currentMolecule . add ( buildChain ( mainChain , isMainCyclic ) ) ; if ( mainChain != 0 ) endOfChain = currentMolecule . getAtom ( currentMolecule . getAtomCount ( ) - 1 ) ; buildFunGroups ( attachedGroups ) ; addHeads ( attachedSubstituents ) ; CDKAtomTypeMatcher matcher = CDKAtomTypeMatcher . getInstance ( currentMolecule . getBuilder ( ) ) ; Iterator < IAtom > atoms = currentMolecule . atoms ( ) . iterator ( ) ; while ( atoms . hasNext ( ) ) { IAtom atom = atoms . next ( ) ; IAtomType type = matcher . findMatchingAtomType ( currentMolecule , atom ) ; AtomTypeManipulator . configure ( atom , type ) ; } CDKHydrogenAdder hAdder = CDKHydrogenAdder . getInstance ( currentMolecule . getBuilder ( ) ) ; hAdder . addImplicitHydrogens ( currentMolecule ) ; return currentMolecule ; }
Start of the process of building a molecule from the parsed data . Passes the parsed tokens to other functions which build up the Molecule .
28,801
public static int getAtomCount ( IMolecularFormula formula ) { int count = 0 ; for ( IIsotope isotope : formula . isotopes ( ) ) { count += formula . getIsotopeCount ( isotope ) ; } return count ; }
Checks a set of Nodes for the occurrence of each isotopes instance in the molecular formula . In short number of atoms .
28,802
public static int getElementCount ( IMolecularFormula formula , IElement element ) { int count = 0 ; for ( IIsotope isotope : formula . isotopes ( ) ) { if ( isotope . getSymbol ( ) . equals ( element . getSymbol ( ) ) ) count += formula . getIsotopeCount ( isotope ) ; } return count ; }
Checks a set of Nodes for the occurrence of the isotopes in the molecular formula from a particular IElement . It returns 0 if the element does not exist . The search is based only on the IElement .
28,803
public static int getElementCount ( IMolecularFormula formula , IIsotope isotope ) { return getElementCount ( formula , formula . getBuilder ( ) . newInstance ( IElement . class , isotope ) ) ; }
Occurrences of a given element from an isotope in a molecular formula .
28,804
public static int getElementCount ( IMolecularFormula formula , String symbol ) { return getElementCount ( formula , formula . getBuilder ( ) . newInstance ( IElement . class , symbol ) ) ; }
Occurrences of a given element in a molecular formula .
28,805
public static List < IIsotope > getIsotopes ( IMolecularFormula formula , IElement element ) { List < IIsotope > isotopeList = new ArrayList < IIsotope > ( ) ; for ( IIsotope isotope : formula . isotopes ( ) ) { if ( isotope . getSymbol ( ) . equals ( element . getSymbol ( ) ) ) isotopeList . add ( isotope ) ; } return isotopeList ; }
Get a list of IIsotope from a given IElement which is contained molecular . The search is based only on the IElement .
28,806
public static List < IElement > elements ( IMolecularFormula formula ) { List < IElement > elementList = new ArrayList < IElement > ( ) ; List < String > stringList = new ArrayList < String > ( ) ; for ( IIsotope isotope : formula . isotopes ( ) ) { if ( ! stringList . contains ( isotope . getSymbol ( ) ) ) { elementList . add ( isotope ) ; stringList . add ( isotope . getSymbol ( ) ) ; } } return elementList ; }
Get a list of all Elements which are contained molecular .
28,807
public static boolean containsElement ( IMolecularFormula formula , IElement element ) { for ( IIsotope isotope : formula . isotopes ( ) ) { if ( element . getSymbol ( ) . equals ( isotope . getSymbol ( ) ) ) return true ; } return false ; }
True if the MolecularFormula contains the given element as IIsotope object .
28,808
public static IMolecularFormula removeElement ( IMolecularFormula formula , IElement element ) { for ( IIsotope isotope : getIsotopes ( formula , element ) ) { formula . removeIsotope ( isotope ) ; } return formula ; }
Removes all isotopes from a given element in the MolecularFormula .
28,809
public static String getString ( IMolecularFormula formula , boolean setOne ) { if ( containsElement ( formula , formula . getBuilder ( ) . newInstance ( IElement . class , "C" ) ) ) return getString ( formula , generateOrderEle_Hill_WithCarbons ( ) , setOne , false ) ; else return getString ( formula , generateOrderEle_Hill_NoCarbons ( ) , setOne , false ) ; }
Returns the string representation of the molecular formula . Based on Hill System . The Hill system is a system of writing chemical formulas such that the number of carbon atoms in a molecule is indicated first the number of hydrogen atoms next and then the number of all other chemical elements subsequently in alphabetical order . When the formula contains no carbon all the elements including hydrogen are listed alphabetically .
28,810
public static IMolecularFormula getMajorIsotopeMolecularFormula ( String stringMF , IChemObjectBuilder builder ) { return getMolecularFormula ( stringMF , true , builder ) ; }
Construct an instance of IMolecularFormula initialized with a molecular formula string . The string is immediately analyzed and a set of Nodes is built based on this analysis . The hydrogens must be implicit . Major isotopes are being used .
28,811
private static IMolecularFormula getMolecularFormula ( String stringMF , IMolecularFormula formula , boolean assumeMajorIsotope ) { if ( stringMF . contains ( "." ) || stringMF . contains ( "(" ) || stringMF . length ( ) > 0 && stringMF . charAt ( 0 ) >= '0' && stringMF . charAt ( 0 ) <= '9' ) stringMF = simplifyMolecularFormula ( stringMF ) ; Integer charge = null ; if ( ( stringMF . contains ( "[" ) && stringMF . contains ( "]" ) ) && ( stringMF . contains ( "+" ) || stringMF . contains ( HYPHEN_STR ) || stringMF . contains ( MINUS_STR ) ) ) { charge = extractCharge ( stringMF ) ; stringMF = cleanMFfromCharge ( stringMF ) ; } if ( stringMF . isEmpty ( ) ) return null ; int len = stringMF . length ( ) ; CharIter iter = new CharIter ( ) ; iter . str = stringMF ; while ( iter . pos < len ) { if ( ! parseIsotope ( iter , formula , assumeMajorIsotope ) ) { LoggingToolFactory . createLoggingTool ( MolecularFormulaManipulator . class ) . error ( "Could not parse MF: " + iter . str ) ; return null ; } } if ( charge != null ) formula . setCharge ( charge ) ; return formula ; }
Add to an instance of IMolecularFormula the elements extracts form molecular formula string . The string is immediately analyzed and a set of Nodes is built based on this analysis . The hydrogens are assumed to be implicit . The boolean indicates if the major isotope is to be assumed or if no assumption is to be made .
28,812
private static double correctMass ( double mass , Integer charge ) { if ( charge == null ) return mass ; double massE = 0.00054857990927 ; if ( charge > 0 ) mass -= massE * charge ; else if ( charge < 0 ) mass += massE * Math . abs ( charge ) ; return mass ; }
Correct the mass according the charge of the IMmoleculeFormula . Negative charge will add the mass of one electron to the mass .
28,813
public static double getTotalMassNumber ( IMolecularFormula formula ) { double mass = 0.0 ; for ( IIsotope isotope : formula . isotopes ( ) ) { try { IIsotope isotope2 = Isotopes . getInstance ( ) . getMajorIsotope ( isotope . getSymbol ( ) ) ; if ( isotope2 != null ) { mass += isotope2 . getMassNumber ( ) * formula . getIsotopeCount ( isotope ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } } return mass ; }
Get the summed mass number of all isotopes from an MolecularFormula . It assumes isotope masses to be preset and returns 0 . 0 if not .
28,814
public static double getTotalNaturalAbundance ( IMolecularFormula formula ) { double abundance = 1.0 ; for ( IIsotope isotope : formula . isotopes ( ) ) { if ( isotope . getNaturalAbundance ( ) == null ) return 0.0 ; abundance = abundance * Math . pow ( isotope . getNaturalAbundance ( ) , formula . getIsotopeCount ( isotope ) ) ; } return abundance / Math . pow ( 100 , getAtomCount ( formula ) ) ; }
Get the summed natural abundance of all isotopes from an MolecularFormula . Assumes abundances to be preset and will return 0 . 0 if not .
28,815
public static double getDBE ( IMolecularFormula formula ) throws CDKException { int valencies [ ] = new int [ 5 ] ; IAtomContainer ac = getAtomContainer ( formula ) ; AtomTypeFactory factory = AtomTypeFactory . getInstance ( "org/openscience/cdk/config/data/structgen_atomtypes.xml" , ac . getBuilder ( ) ) ; for ( int f = 0 ; f < ac . getAtomCount ( ) ; f ++ ) { IAtomType [ ] types = factory . getAtomTypes ( ac . getAtom ( f ) . getSymbol ( ) ) ; if ( types . length == 0 ) throw new CDKException ( "Calculation of double bond equivalents not possible due to problems with element " + ac . getAtom ( f ) . getSymbol ( ) ) ; valencies [ types [ 0 ] . getBondOrderSum ( ) . intValue ( ) ] ++ ; } return 1 + ( valencies [ 4 ] ) + ( valencies [ 3 ] / 2 ) - ( valencies [ 1 ] / 2 ) ; }
Returns the number of double bond equivalents in this molecule .
28,816
public static boolean compare ( IMolecularFormula formula1 , IMolecularFormula formula2 ) { if ( ! Objects . equals ( formula1 . getCharge ( ) , formula2 . getCharge ( ) ) ) return false ; if ( formula1 . getIsotopeCount ( ) != formula2 . getIsotopeCount ( ) ) return false ; for ( IIsotope isotope : formula1 . isotopes ( ) ) { if ( ! formula2 . contains ( isotope ) ) return false ; if ( formula1 . getIsotopeCount ( isotope ) != formula2 . getIsotopeCount ( isotope ) ) return false ; } for ( IIsotope isotope : formula2 . isotopes ( ) ) { if ( ! formula1 . contains ( isotope ) ) return false ; if ( formula2 . getIsotopeCount ( isotope ) != formula1 . getIsotopeCount ( isotope ) ) return false ; } return true ; }
Compare two IMolecularFormula looking at type and number of IIsotope and charge of the formula .
28,817
private static String muliplier ( String formula , int factor ) { String finalformula = "" ; String recentElementSymbol = "" ; String recentElementCountString = "0" ; for ( int f = 0 ; f < formula . length ( ) ; f ++ ) { char thisChar = formula . charAt ( f ) ; if ( f < formula . length ( ) ) { if ( thisChar >= 'A' && thisChar <= 'Z' ) { recentElementSymbol = String . valueOf ( thisChar ) ; recentElementCountString = "0" ; } if ( thisChar >= 'a' && thisChar <= 'z' ) { recentElementSymbol += thisChar ; } if ( thisChar >= '0' && thisChar <= '9' ) { recentElementCountString += thisChar ; } } if ( f == formula . length ( ) - 1 || ( formula . charAt ( f + 1 ) >= 'A' && formula . charAt ( f + 1 ) <= 'Z' ) ) { Integer recentElementCount = Integer . valueOf ( recentElementCountString ) ; if ( recentElementCount == 0 ) finalformula += recentElementSymbol + factor ; else finalformula += recentElementSymbol + recentElementCount * factor ; } } return finalformula ; }
This method multiply all the element over a value .
28,818
public static boolean adjustProtonation ( IMolecularFormula mf , int hcnt ) { if ( mf == null ) throw new NullPointerException ( "No formula provided" ) ; if ( hcnt == 0 ) return false ; final IChemObjectBuilder bldr = mf . getBuilder ( ) ; final int chg = mf . getCharge ( ) != null ? mf . getCharge ( ) : 0 ; IIsotope proton = null ; int pcount = 0 ; for ( IIsotope iso : mf . isotopes ( ) ) { if ( "H" . equals ( iso . getSymbol ( ) ) ) { final int count = mf . getIsotopeCount ( iso ) ; if ( count < hcnt ) continue ; if ( proton == null && ( iso . getMassNumber ( ) == null || iso . getMassNumber ( ) == 1 ) ) { proton = iso ; pcount = count ; } else if ( proton != null && iso . getMassNumber ( ) != null && iso . getMassNumber ( ) == 1 && proton . getMassNumber ( ) == null ) { proton = iso ; pcount = count ; } } } if ( proton == null && hcnt < 0 ) { return false ; } else if ( proton == null && hcnt > 0 ) { proton = bldr . newInstance ( IIsotope . class , "H" ) ; proton . setMassNumber ( 1 ) ; } mf . removeIsotope ( proton ) ; if ( pcount + hcnt > 0 ) mf . addIsotope ( proton , pcount + hcnt ) ; mf . setCharge ( chg + hcnt ) ; return true ; }
Adjust the protonation of a molecular formula . This utility method adjusts the hydrogen isotope count and charge at the same time .
28,819
private static int findOther ( int [ ] vs , int u , int x ) { for ( int v : vs ) { if ( v != u && v != x ) return v ; } throw new IllegalArgumentException ( "vs[] did not contain another vertex" ) ; }
Finds a vertex in vs which is not u or x . .
28,820
private static Map < IAtom , Integer > indexMap ( Map < IAtom , Integer > map , IAtomContainer container ) { if ( map != null ) return map ; map = new HashMap < IAtom , Integer > ( ) ; for ( IAtom a : container . atoms ( ) ) { map . put ( a , map . size ( ) ) ; } return map ; }
Lazy creation of an atom index map .
28,821
public IsotopePattern getIsotopes ( IMolecularFormula molFor ) { if ( builder == null ) { try { isoFactory = Isotopes . getInstance ( ) ; builder = molFor . getBuilder ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } String mf = MolecularFormulaManipulator . getString ( molFor , true ) ; IMolecularFormula molecularFormula = MolecularFormulaManipulator . getMajorIsotopeMolecularFormula ( mf , builder ) ; IsotopePattern abundance_Mass = null ; for ( IIsotope isos : molecularFormula . isotopes ( ) ) { String elementSymbol = isos . getSymbol ( ) ; int atomCount = molecularFormula . getIsotopeCount ( isos ) ; List < IsotopeContainer > additional = new ArrayList < > ( ) ; for ( IIsotope isotope : isoFactory . getIsotopes ( elementSymbol ) ) { double mass = isotope . getExactMass ( ) ; double abundance = isotope . getNaturalAbundance ( ) ; if ( abundance <= 0.000000001 ) continue ; IsotopeContainer container = new IsotopeContainer ( mass , abundance ) ; if ( storeFormula ) container . setFormula ( asFormula ( isotope ) ) ; additional . add ( container ) ; } for ( int i = 0 ; i < atomCount ; i ++ ) abundance_Mass = calculateAbundanceAndMass ( abundance_Mass , additional ) ; } IsotopePattern isoP = IsotopePatternManipulator . sortAndNormalizedByIntensity ( abundance_Mass ) ; isoP = cleanAbundance ( isoP , minIntensity ) ; IsotopePattern isoPattern = IsotopePatternManipulator . sortByMass ( isoP ) ; return isoPattern ; }
Get all combinatorial chemical isotopes given a structure .
28,822
protected boolean canDraw ( IAtom atom , IAtomContainer container , RendererModel model ) { if ( ! hasCoordinates ( atom ) ) { return false ; } if ( invisibleHydrogen ( atom , model ) ) { return false ; } if ( invisibleCarbon ( atom , container , model ) ) { return false ; } return true ; }
Checks an atom to see if it should be drawn . There are three reasons not to draw an atom - a ) no coordinates b ) an invisible hydrogen or c ) an invisible carbon .
28,823
public IRenderingElement generateCompactElement ( IAtom atom , RendererModel model ) { Point2d point = atom . getPoint2d ( ) ; double radius = ( Double ) model . get ( AtomRadius . class ) / model . getParameter ( Scale . class ) . getValue ( ) ; double distance = 2 * radius ; if ( model . get ( CompactShape . class ) == Shape . SQUARE ) { return new RectangleElement ( point . x - radius , point . y - radius , distance , distance , true , getAtomColor ( atom , model ) ) ; } else { return new OvalElement ( point . x , point . y , radius , true , getAtomColor ( atom , model ) ) ; } }
Generate a compact element for an atom such as a circle or a square rather than text element .
28,824
public AtomSymbolElement generateElement ( IAtom atom , int alignment , RendererModel model ) { String text ; if ( atom instanceof IPseudoAtom ) { text = ( ( IPseudoAtom ) atom ) . getLabel ( ) ; } else { text = atom . getSymbol ( ) ; } return new AtomSymbolElement ( atom . getPoint2d ( ) . x , atom . getPoint2d ( ) . y , text , atom . getFormalCharge ( ) , atom . getImplicitHydrogenCount ( ) , alignment , getAtomColor ( atom , model ) ) ; }
Generate an atom symbol element .
28,825
protected boolean showCarbon ( IAtom carbonAtom , IAtomContainer container , RendererModel model ) { if ( ( Boolean ) model . get ( KekuleStructure . class ) ) return true ; if ( carbonAtom . getFormalCharge ( ) != 0 ) return true ; int connectedBondCount = container . getConnectedBondsList ( carbonAtom ) . size ( ) ; if ( connectedBondCount < 1 ) return true ; if ( ( Boolean ) model . get ( ShowEndCarbons . class ) && connectedBondCount == 1 ) return true ; if ( carbonAtom . getProperty ( ProblemMarker . ERROR_MARKER ) != null ) return true ; if ( container . getConnectedSingleElectronsCount ( carbonAtom ) > 0 ) return true ; return false ; }
Checks a carbon atom to see if it should be shown .
28,826
public static void removeAcidicOxygen ( IAminoAcid acid ) throws CDKException { if ( acid . getCTerminus ( ) == null ) throw new CDKException ( "Cannot remove oxygen: C-terminus is not defined!" ) ; java . util . List < IBond > bonds = acid . getConnectedBondsList ( acid . getCTerminus ( ) ) ; for ( IBond bond : bonds ) { if ( bond . getOrder ( ) == Order . SINGLE ) { for ( int j = 0 ; j < bond . getAtomCount ( ) ; j ++ ) { if ( bond . getAtom ( j ) . getSymbol ( ) . equals ( "O" ) ) { acid . removeAtom ( bond . getAtom ( j ) ) ; } } } } }
Removes the singly bonded oxygen from the acid group of the AminoAcid .
28,827
public static void addAcidicOxygen ( IAminoAcid acid ) throws CDKException { if ( acid . getCTerminus ( ) == null ) throw new CDKException ( "Cannot add oxygen: C-terminus is not defined!" ) ; IAtom acidicOxygen = acid . getBuilder ( ) . newInstance ( IAtom . class , "O" ) ; acid . addAtom ( acidicOxygen ) ; acid . addBond ( acid . getBuilder ( ) . newInstance ( IBond . class , acid . getCTerminus ( ) , acidicOxygen , Order . SINGLE ) ) ; }
Adds the singly bonded oxygen from the acid group of the AminoAcid .
28,828
public void setRestrictions ( List < IRule > rulesNew ) throws CDKException { Iterator < IRule > itRules = rulesNew . iterator ( ) ; while ( itRules . hasNext ( ) ) { IRule rule = itRules . next ( ) ; if ( rule instanceof ElementRule ) { mfRange = ( MolecularFormulaRange ) ( ( Object [ ] ) rule . getParameters ( ) ) [ 0 ] ; Iterator < IRule > oldRuleIt = rules . iterator ( ) ; while ( oldRuleIt . hasNext ( ) ) { IRule oldRule = oldRuleIt . next ( ) ; if ( oldRule instanceof ElementRule ) { rules . remove ( oldRule ) ; rules . add ( rule ) ; break ; } } this . matrix_Base = getMatrix ( mfRange . getIsotopeCount ( ) ) ; } else if ( rule instanceof ChargeRule ) { this . charge = ( Double ) ( ( Object [ ] ) rule . getParameters ( ) ) [ 0 ] ; Iterator < IRule > oldRuleIt = rules . iterator ( ) ; while ( oldRuleIt . hasNext ( ) ) { IRule oldRule = oldRuleIt . next ( ) ; if ( oldRule instanceof ChargeRule ) { rules . remove ( oldRule ) ; rules . add ( rule ) ; break ; } } } else if ( rule instanceof ToleranceRangeRule ) { this . tolerance = ( Double ) ( ( Object [ ] ) rule . getParameters ( ) ) [ 1 ] ; Iterator < IRule > oldRuleIt = rules . iterator ( ) ; while ( oldRuleIt . hasNext ( ) ) { IRule oldRule = oldRuleIt . next ( ) ; if ( oldRule instanceof ToleranceRangeRule ) { rules . remove ( oldRule ) ; rules . add ( rule ) ; break ; } } } else { rules . add ( rule ) ; } } }
Set the restrictions that must be presents in the molecular formula .
28,829
public void setDefaultRestrictions ( ) { try { callDefaultRestrictions ( ) ; } catch ( CDKException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } }
Set the default restrictions that must be presents in the molecular formula .
28,830
private List < IIsotope > orderList ( List < IIsotope > isotopes_TO ) { List < IIsotope > newOrderList = new ArrayList < IIsotope > ( ) ; for ( int i = 0 ; i < orderElements . length ; i ++ ) { String symbol = orderElements [ i ] ; Iterator < IIsotope > itIso = isotopes_TO . iterator ( ) ; while ( itIso . hasNext ( ) ) { IIsotope isotopeToCo = itIso . next ( ) ; if ( isotopeToCo . getSymbol ( ) . equals ( symbol ) ) { newOrderList . add ( isotopeToCo ) ; } } } return newOrderList ; }
Put the order the List of IIsotope according the probability occurrence .
28,831
private int getMaxOccurence ( double massTo , int element_pos , int [ ] matrix , List < IIsotope > isoToCond_new ) { double massIn = isoToCond_new . get ( element_pos ) . getExactMass ( ) ; double massToM = massTo ; for ( int i = 0 ; i < matrix . length ; i ++ ) if ( i != element_pos ) if ( matrix [ i ] != 0 ) massToM -= isoToCond_new . get ( i ) . getExactMass ( ) * matrix [ i ] ; int value = ( int ) ( ( massToM + 1 ) / massIn ) ; return value ; }
Get the maximal occurrence of this List .
28,832
private IMolecularFormula getFormula ( List < IIsotope > isoToCond_new , int [ ] value_In ) { IMolecularFormula mf = builder . newInstance ( IMolecularFormula . class ) ; for ( int i = 0 ; i < isoToCond_new . size ( ) ; i ++ ) { if ( value_In [ i ] != 0 ) { for ( int j = 0 ; j < value_In [ i ] ; j ++ ) mf . addIsotope ( isoToCond_new . get ( i ) ) ; } } mf = putInOrder ( mf ) ; return mf ; }
Set the formula molecular as IMolecularFormula object .
28,833
private IMolecularFormula putInOrder ( IMolecularFormula formula ) { IMolecularFormula new_formula = formula . getBuilder ( ) . newInstance ( IMolecularFormula . class ) ; for ( int i = 0 ; i < orderElements . length ; i ++ ) { IElement element = builder . newInstance ( IElement . class , orderElements [ i ] ) ; if ( MolecularFormulaManipulator . containsElement ( formula , element ) ) { Iterator < IIsotope > isotopes = MolecularFormulaManipulator . getIsotopes ( formula , element ) . iterator ( ) ; while ( isotopes . hasNext ( ) ) { IIsotope isotope = isotopes . next ( ) ; new_formula . addIsotope ( isotope , formula . getIsotopeCount ( isotope ) ) ; } } } return new_formula ; }
Put in order the elements of the molecular formula .
28,834
private double calculateMassT ( List < IIsotope > isoToCond_new , int [ ] value_In ) { double result = 0 ; for ( int i = 0 ; i < isoToCond_new . size ( ) ; i ++ ) { if ( value_In [ i ] != 0 ) { result += isoToCond_new . get ( i ) . getExactMass ( ) * value_In [ i ] ; } } return result ; }
Calculate the mass total given the elements and their respective occurrences .
28,835
private IMolecularFormulaSet returnOrdered ( double mass , IMolecularFormulaSet formulaSet ) { IMolecularFormulaSet solutions_new = null ; if ( formulaSet . size ( ) != 0 ) { double valueMin = 100 ; int i_final = 0 ; solutions_new = formulaSet . getBuilder ( ) . newInstance ( IMolecularFormulaSet . class ) ; List < Integer > listI = new ArrayList < Integer > ( ) ; for ( int j = 0 ; j < formulaSet . size ( ) ; j ++ ) { for ( int i = 0 ; i < formulaSet . size ( ) ; i ++ ) { if ( listI . contains ( i ) ) continue ; double value = MolecularFormulaManipulator . getTotalExactMass ( formulaSet . getMolecularFormula ( i ) ) ; double diff = Math . abs ( mass - Math . abs ( value ) ) ; if ( valueMin > diff ) { valueMin = diff ; i_final = i ; } } valueMin = 100 ; solutions_new . addMolecularFormula ( formulaSet . getMolecularFormula ( i_final ) ) ; listI . add ( i_final ) ; } } return solutions_new ; }
Return all molecular formulas but ordered according the tolerance difference between masses .
28,836
private int [ ] [ ] getMatrix ( int size ) { logger . info ( "Creating matrix for isotopes combination" ) ; int lengthM = ( int ) Math . pow ( 2 , size ) ; lengthM -- ; int [ ] [ ] matrix = new int [ lengthM ] [ size ] ; int [ ] combi = new int [ size ] ; for ( int j = 0 ; j < size ; j ++ ) { combi [ j ] = 0 ; } int posChang = size - 1 ; int posRemov = size - 1 ; for ( int i = 0 ; i < lengthM ; i ++ ) { for ( int j = posRemov ; j < size ; j ++ ) { combi [ j ] = 0 ; } combi [ posChang ] = 1 ; for ( int j = 0 ; j < size ; j ++ ) matrix [ i ] [ j ] = combi [ j ] ; if ( posChang == size - 1 ) { for ( int j = posChang ; j >= 0 ; j -- ) { if ( combi [ j ] == 0 ) { posChang = j ; posRemov = j + 1 ; break ; } } } else { for ( int j = posChang ; j < size ; j ++ ) { if ( combi [ j ] == 0 ) { posChang = j ; } } } } return matrix ; }
Get the corresponding matrix and create it .
28,837
public static int getAtomCount ( IChemFile file ) { int count = 0 ; for ( int i = 0 ; i < file . getChemSequenceCount ( ) ; i ++ ) { count += ChemSequenceManipulator . getAtomCount ( file . getChemSequence ( i ) ) ; } return count ; }
Get the total number of atoms inside an IChemFile .
28,838
public static int getBondCount ( IChemFile file ) { int count = 0 ; for ( int i = 0 ; i < file . getChemSequenceCount ( ) ; i ++ ) { count += ChemSequenceManipulator . getBondCount ( file . getChemSequence ( i ) ) ; } return count ; }
Get the total number of bonds inside an IChemFile .
28,839
public static List < IChemObject > getAllChemObjects ( IChemFile file ) { List < IChemObject > list = new ArrayList < IChemObject > ( ) ; for ( int i = 0 ; i < file . getChemSequenceCount ( ) ; i ++ ) { list . add ( file . getChemSequence ( i ) ) ; list . addAll ( ChemSequenceManipulator . getAllChemObjects ( file . getChemSequence ( i ) ) ) ; } return list ; }
Returns a List of all IChemObject inside a ChemFile .
28,840
public static List < IAtomContainer > getAllAtomContainers ( IChemFile file ) { List < IAtomContainer > acList = new ArrayList < IAtomContainer > ( ) ; for ( IChemSequence sequence : file . chemSequences ( ) ) { acList . addAll ( ChemSequenceManipulator . getAllAtomContainers ( sequence ) ) ; } return acList ; }
Returns all the AtomContainer s of a ChemFile .
28,841
public static List < IChemModel > getAllChemModels ( IChemFile file ) { List < IChemModel > modelsList = new ArrayList < IChemModel > ( ) ; for ( int f = 0 ; f < file . getChemSequenceCount ( ) ; f ++ ) { for ( IChemModel model : file . getChemSequence ( f ) . chemModels ( ) ) { modelsList . add ( model ) ; } } return modelsList ; }
Get a list of all ChemModels inside an IChemFile .
28,842
public static List < IReaction > getAllReactions ( IChemFile file ) { List < IReaction > reactonList = new ArrayList < IReaction > ( ) ; List < IChemModel > chemModel = getAllChemModels ( file ) ; for ( int f = 0 ; f < chemModel . size ( ) ; f ++ ) { for ( IReaction reaction : chemModel . get ( f ) . getReactionSet ( ) . reactions ( ) ) { reactonList . add ( reaction ) ; } } return reactonList ; }
Get a list of all IReaction inside an IChemFile .
28,843
private int getHybridisationState ( IAtom atom1 ) { IBond . Order maxBondOrder = atom1 . getMaxBondOrder ( ) ; if ( atom1 . getFormalNeighbourCount ( ) == 1 ) { } else if ( atom1 . getFormalNeighbourCount ( ) == 2 || maxBondOrder == IBond . Order . TRIPLE ) { return 1 ; } else if ( atom1 . getFormalNeighbourCount ( ) == 3 || ( maxBondOrder == IBond . Order . DOUBLE ) ) { return 2 ; } else { return 3 ; } return - 1 ; }
Gets the hybridisation state of an atom .
28,844
private int getDoubleBondConfiguration2D ( IBond bond , Point2d a , Point2d b , Point2d c , Point2d d ) throws CDKException { if ( bond . getOrder ( ) != IBond . Order . DOUBLE ) { return 0 ; } if ( a == null || b == null || c == null || d == null ) return 0 ; Point2d cb = new Point2d ( c . x - b . x , c . y - b . y ) ; Point2d xT = new Point2d ( cb . x - 1 , cb . y ) ; a . y = a . y - b . y - xT . y ; d . y = d . y - b . y - xT . y ; if ( ( a . y > 0 && d . y > 0 ) || ( a . y < 0 && d . y < 0 ) ) { return 5 ; } else { return 6 ; } }
Gets the doubleBondConfiguration2D attribute of the AtomPlacer3D object using existing 2D coordinates .
28,845
public double getBondLengthValue ( String id1 , String id2 ) { String dkey = "" ; if ( pSet . containsKey ( ( "bond" + id1 + ";" + id2 ) ) ) { dkey = "bond" + id1 + ";" + id2 ; } else if ( pSet . containsKey ( ( "bond" + id2 + ";" + id1 ) ) ) { dkey = "bond" + id2 + ";" + id1 ; } else { logger . warn ( "KEYError: Unknown distance key in pSet: " + id2 + ";" + id1 + " take default bond length: " + DEFAULT_BOND_LENGTH ) ; return DEFAULT_BOND_LENGTH ; } return ( ( Double ) ( pSet . get ( dkey ) . get ( 0 ) ) ) . doubleValue ( ) ; }
Gets the distanceValue attribute of the parameter set .
28,846
public IAtom getNextUnplacedHeavyAtomWithAliphaticPlacedNeighbour ( IAtomContainer molecule ) { Iterator < IBond > bonds = molecule . bonds ( ) . iterator ( ) ; while ( bonds . hasNext ( ) ) { IBond bond = bonds . next ( ) ; if ( bond . getBegin ( ) . getFlag ( CDKConstants . ISPLACED ) && ! ( bond . getEnd ( ) . getFlag ( CDKConstants . ISPLACED ) ) ) { if ( isAliphaticHeavyAtom ( bond . getEnd ( ) ) ) { return bond . getEnd ( ) ; } } if ( bond . getEnd ( ) . getFlag ( CDKConstants . ISPLACED ) && ! ( bond . getBegin ( ) . getFlag ( CDKConstants . ISPLACED ) ) ) { if ( isAliphaticHeavyAtom ( bond . getBegin ( ) ) ) { return bond . getBegin ( ) ; } } } return null ; }
Gets the nextUnplacedHeavyAtomWithAliphaticPlacedNeighbour from an atom container or molecule .
28,847
IAtom getUnplacedHeavyAtom ( IAtomContainer molecule ) { for ( IAtom atom : molecule . atoms ( ) ) { if ( isUnplacedHeavyAtom ( atom ) ) return atom ; } return null ; }
Find the first unplaced atom .
28,848
public IAtom getNextPlacedHeavyAtomWithUnplacedAliphaticNeighbour ( IAtomContainer molecule ) { Iterator < IBond > bonds = molecule . bonds ( ) . iterator ( ) ; while ( bonds . hasNext ( ) ) { IBond bond = bonds . next ( ) ; IAtom atom0 = bond . getBegin ( ) ; IAtom atom1 = bond . getEnd ( ) ; if ( atom0 . getFlag ( CDKConstants . ISPLACED ) && ! ( atom1 . getFlag ( CDKConstants . ISPLACED ) ) ) { if ( isAliphaticHeavyAtom ( atom1 ) && isHeavyAtom ( atom0 ) ) { return atom0 ; } } if ( atom1 . getFlag ( CDKConstants . ISPLACED ) && ! ( atom0 . getFlag ( CDKConstants . ISPLACED ) ) ) { if ( isAliphaticHeavyAtom ( atom0 ) && isHeavyAtom ( atom1 ) ) { return atom1 ; } } } return null ; }
Gets the nextPlacedHeavyAtomWithAliphaticPlacedNeigbor from an atom container or molecule .
28,849
public IAtom getFarthestAtom ( Point3d refAtomPoint , IAtomContainer ac ) { double distance = 0 ; IAtom atom = null ; for ( int i = 0 ; i < ac . getAtomCount ( ) ; i ++ ) { if ( ac . getAtom ( i ) . getPoint3d ( ) != null ) { if ( Math . abs ( refAtomPoint . distance ( ac . getAtom ( i ) . getPoint3d ( ) ) ) > distance ) { atom = ac . getAtom ( i ) ; distance = Math . abs ( refAtomPoint . distance ( ac . getAtom ( i ) . getPoint3d ( ) ) ) ; } } } return atom ; }
Gets the farthestAtom attribute of the AtomPlacer3D object .
28,850
public IAtom getUnplacedRingHeavyAtom ( IAtomContainer molecule , IAtom atom ) { List < IBond > bonds = molecule . getConnectedBondsList ( atom ) ; IAtom connectedAtom = null ; for ( IBond bond : bonds ) { connectedAtom = bond . getOther ( atom ) ; if ( isUnplacedHeavyAtom ( connectedAtom ) && connectedAtom . getFlag ( CDKConstants . ISINRING ) ) { return connectedAtom ; } } return connectedAtom ; }
Gets the unplacedRingHeavyAtom attribute of the AtomPlacer3D object .
28,851
public Point3d geometricCenterAllPlacedAtoms ( IAtomContainer molecule ) { IAtomContainer allPlacedAtoms = getAllPlacedAtoms ( molecule ) ; return GeometryUtil . get3DCenter ( allPlacedAtoms ) ; }
Calculates the geometric center of all placed atoms in the atomcontainer .
28,852
public IAtom getPlacedHeavyAtom ( IAtomContainer molecule , IAtom atom ) { List < IBond > bonds = molecule . getConnectedBondsList ( atom ) ; for ( IBond bond : bonds ) { IAtom connectedAtom = bond . getOther ( atom ) ; if ( isPlacedHeavyAtom ( connectedAtom ) ) { return connectedAtom ; } } return null ; }
Returns a placed atom connected to a given atom .
28,853
public IAtom getPlacedHeavyAtom ( IAtomContainer molecule , IAtom atomA , IAtom atomB ) { List < IBond > bonds = molecule . getConnectedBondsList ( atomA ) ; for ( IBond bond : bonds ) { IAtom connectedAtom = bond . getOther ( atomA ) ; if ( isPlacedHeavyAtom ( connectedAtom ) && ! connectedAtom . equals ( atomB ) ) { return connectedAtom ; } } return null ; }
Gets the first placed Heavy Atom around atomA which is not atomB .
28,854
public IAtomContainer getPlacedHeavyAtoms ( IAtomContainer molecule , IAtom atom ) { List < IBond > bonds = molecule . getConnectedBondsList ( atom ) ; IAtomContainer connectedAtoms = molecule . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; IAtom connectedAtom = null ; for ( IBond bond : bonds ) { connectedAtom = bond . getOther ( atom ) ; if ( isPlacedHeavyAtom ( connectedAtom ) ) { connectedAtoms . addAtom ( connectedAtom ) ; } } return connectedAtoms ; }
Gets the placed Heavy Atoms connected to an atom .
28,855
private IAtomContainer getAllPlacedAtoms ( IAtomContainer molecule ) { IAtomContainer placedAtoms = new AtomContainer ( ) ; for ( int i = 0 ; i < molecule . getAtomCount ( ) ; i ++ ) { if ( molecule . getAtom ( i ) . getFlag ( CDKConstants . ISPLACED ) ) { placedAtoms . addAtom ( molecule . getAtom ( i ) ) ; } } return placedAtoms ; }
Gets the allPlacedAtoms attribute of the AtomPlacer3D object .
28,856
public boolean allHeavyAtomsPlaced ( IAtomContainer ac ) { for ( int i = 0 ; i < ac . getAtomCount ( ) ; i ++ ) { if ( isUnplacedHeavyAtom ( ac . getAtom ( i ) ) ) { return false ; } } return true ; }
True is all the atoms in the given AtomContainer have been placed .
28,857
public DescriptorValue calculate ( IAtomContainer atomContainer ) { IAtomContainer ac = null ; try { ac = ( IAtomContainer ) atomContainer . clone ( ) ; } catch ( CloneNotSupportedException e ) { return getDummyDescriptorValue ( e ) ; } int carbonCount = 0 ; int heteroCount = 0 ; for ( IAtom atom : ac . atoms ( ) ) { if ( ! Elements . HYDROGEN . getSymbol ( ) . equals ( atom . getSymbol ( ) ) ) { if ( Elements . CARBON . getSymbol ( ) . equals ( atom . getSymbol ( ) ) ) { carbonCount ++ ; } else { heteroCount ++ ; } } } double mLogP = 1.46 + 0.11 * carbonCount - 0.11 * heteroCount ; return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( mLogP ) , getDescriptorNames ( ) ) ; }
Calculates the Mannhold LogP for an atom container .
28,858
public ValidationReport validateBond ( IBond subject ) { ValidationReport report = new ValidationReport ( ) ; if ( subject . getAtomCount ( ) == 2 ) { double distance = subject . getBegin ( ) . getPoint3d ( ) . distance ( subject . getEnd ( ) . getPoint3d ( ) ) ; if ( distance > 3.0 ) { ValidationTest badBondLengthError = new ValidationTest ( subject , "Bond length cannot exceed 3 Angstroms." , "A bond length typically is between 0.5 and 3.0 Angstroms." ) ; report . addError ( badBondLengthError ) ; } } return report ; }
assumes 1 unit in the coordinate system is one angstrom
28,859
protected static < T > T [ ] invapply ( T [ ] src , int [ ] perm ) { T [ ] res = src . clone ( ) ; for ( int i = 0 ; i < src . length ; i ++ ) res [ i ] = src [ perm [ i ] ] ; return res ; }
apply the inverse of a permutation
28,860
private static Shape createAtomHighlight ( IAtom atom , double radius ) { double x = atom . getPoint2d ( ) . x ; double y = atom . getPoint2d ( ) . y ; return new RoundRectangle2D . Double ( x - radius , y - radius , 2 * radius , 2 * radius , 2 * radius , 2 * radius ) ; }
Create the shape which will highlight the provided atom .
28,861
private static Shape createBondHighlight ( IBond bond , double radius ) { double x1 = bond . getBegin ( ) . getPoint2d ( ) . x ; double x2 = bond . getEnd ( ) . getPoint2d ( ) . x ; double y1 = bond . getBegin ( ) . getPoint2d ( ) . y ; double y2 = bond . getEnd ( ) . getPoint2d ( ) . y ; double dx = x2 - x1 ; double dy = y2 - y1 ; double mag = Math . sqrt ( ( dx * dx ) + ( dy * dy ) ) ; dx /= mag ; dy /= mag ; double r2 = radius / 2 ; Shape s = new RoundRectangle2D . Double ( x1 - r2 , y1 - r2 , mag + radius , radius , radius , radius ) ; double theta = Math . atan2 ( dy , dx ) ; return AffineTransform . getRotateInstance ( theta , x1 , y1 ) . createTransformedShape ( s ) ; }
Create the shape which will highlight the provided bond .
28,862
public static Palette createPalette ( final Color color , final Color ... colors ) { Color [ ] cs = new Color [ colors . length + 1 ] ; cs [ 0 ] = color ; System . arraycopy ( colors , 0 , cs , 1 , colors . length ) ; return new FixedPalette ( cs ) ; }
Create a palette which uses the provided colors .
28,863
public IVector sub ( IVector b ) { IVector result = new IVector ( size ) ; sub ( b , result ) ; return result ; }
Subtraction from two vectors
28,864
public Complex dot ( IVector b ) { if ( ( b == null ) || ( size != b . size ) ) return new Complex ( Double . NaN , Double . NaN ) ; Complex result = new Complex ( 0d , 0d ) ; int i ; for ( i = 0 ; i < size ; i ++ ) { result . real += realvector [ i ] * b . realvector [ i ] - imagvector [ i ] * b . imagvector [ i ] ; result . imag += realvector [ i ] * b . imagvector [ i ] + imagvector [ i ] * b . realvector [ i ] ; } return result ; }
Multiplication from two vectors
28,865
public void duplicate ( IVector result ) { if ( result . size != size ) result . reshape ( size ) ; int i ; for ( i = 0 ; i < size ; i ++ ) { result . realvector [ i ] = realvector [ i ] ; result . imagvector [ i ] = imagvector [ i ] ; } }
Copy a vector
28,866
public void reshape ( int newsize ) { if ( ( newsize == size ) || ( newsize <= 0 ) ) return ; double [ ] newrealvector = new double [ newsize ] ; double [ ] newimagvector = new double [ newsize ] ; int min = Math . min ( size , newsize ) ; int i ; for ( i = 0 ; i < min ; i ++ ) { newrealvector [ i ] = realvector [ i ] ; newimagvector [ i ] = imagvector [ i ] ; } for ( i = min ; i < newsize ; i ++ ) { newrealvector [ i ] = 0d ; newimagvector [ i ] = 0d ; } realvector = newrealvector ; imagvector = newimagvector ; size = newsize ; }
Resize this vector
28,867
public String getInchiKey ( ) throws CDKException { JniInchiOutputKey key ; try { key = JniInchiWrapper . getInchiKey ( output . getInchi ( ) ) ; if ( key . getReturnStatus ( ) == INCHI_KEY . OK ) { return key . getKey ( ) ; } else { throw new CDKException ( "Error while creating InChIKey: " + key . getReturnStatus ( ) ) ; } } catch ( JniInchiException exception ) { throw new CDKException ( "Error while creating InChIKey: " + exception . getMessage ( ) , exception ) ; } }
Gets generated InChIKey string .
28,868
public void push ( ICMLModule item ) { if ( sp == stack . length ) { ICMLModule [ ] temp = new ICMLModule [ 2 * sp ] ; System . arraycopy ( stack , 0 , temp , 0 , sp ) ; stack = temp ; } stack [ sp ++ ] = item ; }
Adds an entry to the stack .
28,869
public PermutationGroup getAutomorphismGroup ( IAtomContainer atomContainer , Partition initialPartition ) { setup ( atomContainer ) ; super . refine ( initialPartition ) ; return super . getAutomorphismGroup ( ) ; }
Get the automorphism group of the molecule given an initial partition .
28,870
public IAtomContainer assignInductivePartialCharges ( IAtomContainer ac ) throws Exception { if ( factory == null ) { factory = AtomTypeFactory . getInstance ( "org/openscience/cdk/config/data/jmol_atomtypes.txt" , ac . getBuilder ( ) ) ; } int stepsLimit = 9 ; IAtom [ ] atoms = AtomContainerManipulator . getAtomArray ( ac ) ; double [ ] pChInch = new double [ atoms . length * ( stepsLimit + 1 ) ] ; double [ ] ElEn = new double [ atoms . length * ( stepsLimit + 1 ) ] ; double [ ] pCh = new double [ atoms . length * ( stepsLimit + 1 ) ] ; double [ ] startEE = getPaulingElectronegativities ( ac , true ) ; for ( int e = 0 ; e < atoms . length ; e ++ ) { ElEn [ e ] = startEE [ e ] ; } for ( int s = 1 ; s < 10 ; s ++ ) { for ( int a = 0 ; a < atoms . length ; a ++ ) { pChInch [ a + ( s * atoms . length ) ] = getAtomicChargeIncrement ( ac , a , ElEn , s ) ; pCh [ a + ( s * atoms . length ) ] = pChInch [ a + ( s * atoms . length ) ] + pCh [ a + ( ( s - 1 ) * atoms . length ) ] ; ElEn [ a + ( s * atoms . length ) ] = ElEn [ a + ( ( s - 1 ) * atoms . length ) ] + ( pChInch [ a + ( s * atoms . length ) ] / getAtomicSoftnessCore ( ac , a ) ) ; if ( s == 9 ) { atoms [ a ] . setProperty ( "InductivePartialCharge" , new Double ( pCh [ a + ( s * atoms . length ) ] ) ) ; atoms [ a ] . setProperty ( "EffectiveAtomicElectronegativity" , new Double ( ElEn [ a + ( s * atoms . length ) ] ) ) ; } } } return ac ; }
Main method set charge as atom properties .
28,871
public double [ ] getPaulingElectronegativities ( IAtomContainer ac , boolean modified ) throws CDKException { double [ ] paulingElectronegativities = new double [ ac . getAtomCount ( ) ] ; IElement element = null ; String symbol = null ; int atomicNumber = 0 ; try { ifac = Isotopes . getInstance ( ) ; for ( int i = 0 ; i < ac . getAtomCount ( ) ; i ++ ) { IAtom atom = ac . getAtom ( i ) ; symbol = ac . getAtom ( i ) . getSymbol ( ) ; element = ifac . getElement ( symbol ) ; atomicNumber = element . getAtomicNumber ( ) ; if ( modified ) { if ( symbol . equals ( "Cl" ) ) { paulingElectronegativities [ i ] = 3.28 ; } else if ( symbol . equals ( "Br" ) ) { paulingElectronegativities [ i ] = 3.13 ; } else if ( symbol . equals ( "I" ) ) { paulingElectronegativities [ i ] = 2.93 ; } else if ( symbol . equals ( "H" ) ) { paulingElectronegativities [ i ] = 2.10 ; } else if ( symbol . equals ( "C" ) ) { if ( ac . getMaximumBondOrder ( atom ) == IBond . Order . SINGLE ) { paulingElectronegativities [ i ] = 2.20 ; } else if ( ac . getMaximumBondOrder ( atom ) == IBond . Order . DOUBLE ) { paulingElectronegativities [ i ] = 2.31 ; } else { paulingElectronegativities [ i ] = 3.15 ; } } else if ( symbol . equals ( "O" ) ) { if ( ac . getMaximumBondOrder ( atom ) == IBond . Order . SINGLE ) { paulingElectronegativities [ i ] = 3.20 ; } else if ( ac . getMaximumBondOrder ( atom ) != IBond . Order . SINGLE ) { paulingElectronegativities [ i ] = 4.34 ; } } else if ( symbol . equals ( "Si" ) ) { paulingElectronegativities [ i ] = 1.99 ; } else if ( symbol . equals ( "S" ) ) { paulingElectronegativities [ i ] = 2.74 ; } else if ( symbol . equals ( "N" ) ) { paulingElectronegativities [ i ] = 2.59 ; } else { paulingElectronegativities [ i ] = pauling [ atomicNumber ] ; } } else { paulingElectronegativities [ i ] = pauling [ atomicNumber ] ; } } return paulingElectronegativities ; } catch ( Exception ex1 ) { logger . debug ( ex1 ) ; throw new CDKException ( "Problems with IsotopeFactory due to " + ex1 . toString ( ) , ex1 ) ; } }
Gets the paulingElectronegativities attribute of the InductivePartialCharges object .
28,872
public double getAtomicSoftnessCore ( IAtomContainer ac , int atomPosition ) throws CDKException { if ( factory == null ) { factory = AtomTypeFactory . getInstance ( "org/openscience/cdk/config/data/jmol_atomtypes.txt" , ac . getBuilder ( ) ) ; } IAtom target = null ; double core = 0 ; double radiusTarget = 0 ; target = ac . getAtom ( atomPosition ) ; double partial = 0 ; double radius = 0 ; String symbol = null ; IAtomType type = null ; try { symbol = ac . getAtom ( atomPosition ) . getSymbol ( ) ; type = factory . getAtomType ( symbol ) ; if ( getCovalentRadius ( symbol , ac . getMaximumBondOrder ( target ) ) > 0 ) { radiusTarget = getCovalentRadius ( symbol , ac . getMaximumBondOrder ( target ) ) ; } else { radiusTarget = type . getCovalentRadius ( ) ; } } catch ( Exception ex1 ) { logger . debug ( ex1 ) ; throw new CDKException ( "Problems with AtomTypeFactory due to " + ex1 . getMessage ( ) , ex1 ) ; } Iterator < IAtom > atoms = ac . atoms ( ) . iterator ( ) ; while ( atoms . hasNext ( ) ) { IAtom atom = atoms . next ( ) ; if ( ! target . equals ( atom ) ) { symbol = atom . getSymbol ( ) ; partial = 0 ; try { type = factory . getAtomType ( symbol ) ; } catch ( Exception ex1 ) { logger . debug ( ex1 ) ; throw new CDKException ( "Problems with AtomTypeFactory due to " + ex1 . getMessage ( ) , ex1 ) ; } if ( getCovalentRadius ( symbol , ac . getMaximumBondOrder ( atom ) ) > 0 ) { radius = getCovalentRadius ( symbol , ac . getMaximumBondOrder ( atom ) ) ; } else { radius = type . getCovalentRadius ( ) ; } partial += radius * radius ; partial += ( radiusTarget * radiusTarget ) ; partial = partial / ( calculateSquaredDistanceBetweenTwoAtoms ( target , atom ) ) ; core += partial ; } } core = 2 * core ; core = 0.172 * core ; return core ; }
of effective electronegativity
28,873
private double getAtomicChargeIncrement ( IAtomContainer ac , int atomPosition , double [ ] ElEn , int as ) throws CDKException { IAtom [ ] allAtoms = null ; IAtom target = null ; double incrementedCharge = 0 ; double radiusTarget = 0 ; target = ac . getAtom ( atomPosition ) ; allAtoms = AtomContainerManipulator . getAtomArray ( ac ) ; double tmp = 0 ; double radius = 0 ; String symbol = null ; IAtomType type = null ; try { symbol = target . getSymbol ( ) ; type = factory . getAtomType ( symbol ) ; if ( getCovalentRadius ( symbol , ac . getMaximumBondOrder ( target ) ) > 0 ) { radiusTarget = getCovalentRadius ( symbol , ac . getMaximumBondOrder ( target ) ) ; } else { radiusTarget = type . getCovalentRadius ( ) ; } } catch ( Exception ex1 ) { logger . debug ( ex1 ) ; throw new CDKException ( "Problems with AtomTypeFactory due to " + ex1 . getMessage ( ) , ex1 ) ; } for ( int a = 0 ; a < allAtoms . length ; a ++ ) { if ( ! target . equals ( allAtoms [ a ] ) ) { tmp = 0 ; symbol = allAtoms [ a ] . getSymbol ( ) ; try { type = factory . getAtomType ( symbol ) ; } catch ( Exception ex1 ) { logger . debug ( ex1 ) ; throw new CDKException ( "Problems with AtomTypeFactory due to " + ex1 . getMessage ( ) , ex1 ) ; } if ( getCovalentRadius ( symbol , ac . getMaximumBondOrder ( allAtoms [ a ] ) ) > 0 ) { radius = getCovalentRadius ( symbol , ac . getMaximumBondOrder ( allAtoms [ a ] ) ) ; } else { radius = type . getCovalentRadius ( ) ; } tmp = ( ElEn [ a + ( ( as - 1 ) * allAtoms . length ) ] - ElEn [ atomPosition + ( ( as - 1 ) * allAtoms . length ) ] ) ; tmp = tmp * ( ( radius * radius ) + ( radiusTarget * radiusTarget ) ) ; tmp = tmp / ( calculateSquaredDistanceBetweenTwoAtoms ( target , allAtoms [ a ] ) ) ; incrementedCharge += tmp ; } } incrementedCharge = 0.172 * incrementedCharge ; return incrementedCharge ; }
Gets the atomicChargeIncrement attribute of the InductivePartialCharges object .
28,874
private double getCovalentRadius ( String symbol , IBond . Order maxBondOrder ) { double radiusTarget = 0 ; if ( symbol . equals ( "F" ) ) { radiusTarget = 0.64 ; } else if ( symbol . equals ( "Cl" ) ) { radiusTarget = 0.99 ; } else if ( symbol . equals ( "Br" ) ) { radiusTarget = 1.14 ; } else if ( symbol . equals ( "I" ) ) { radiusTarget = 1.33 ; } else if ( symbol . equals ( "H" ) ) { radiusTarget = 0.30 ; } else if ( symbol . equals ( "C" ) ) { if ( maxBondOrder == IBond . Order . SINGLE ) { radiusTarget = 0.77 ; } else if ( maxBondOrder == IBond . Order . DOUBLE ) { radiusTarget = 0.67 ; } else { radiusTarget = 0.60 ; } } else if ( symbol . equals ( "O" ) ) { if ( maxBondOrder == IBond . Order . SINGLE ) { radiusTarget = 0.66 ; } else if ( maxBondOrder != IBond . Order . SINGLE ) { radiusTarget = 0.60 ; } } else if ( symbol . equals ( "Si" ) ) { radiusTarget = 1.11 ; } else if ( symbol . equals ( "S" ) ) { radiusTarget = 1.04 ; } else if ( symbol . equals ( "N" ) ) { radiusTarget = 0.70 ; } else { radiusTarget = 0 ; } return radiusTarget ; }
Gets the covalentRadius attribute of the InductivePartialCharges object .
28,875
public DescriptorValue calculate ( IAtom atom , IAtomContainer atomContainer ) { IAtomContainer clonedAtomContainer ; try { clonedAtomContainer = ( IAtomContainer ) atomContainer . clone ( ) ; } catch ( CloneNotSupportedException e ) { return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new IntegerResult ( ( int ) Double . NaN ) , NAMES , e ) ; } IAtom clonedAtom = clonedAtomContainer . getAtom ( atomContainer . indexOf ( atom ) ) ; int isProtonInAromaticSystem = 0 ; IAtomContainer mol = atom . getBuilder ( ) . newInstance ( IAtomContainer . class , clonedAtomContainer ) ; if ( checkAromaticity ) { try { AtomContainerManipulator . percieveAtomTypesAndConfigureAtoms ( mol ) ; Aromaticity . cdkLegacy ( ) . apply ( mol ) ; } catch ( CDKException e ) { return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new IntegerResult ( ( int ) Double . NaN ) , NAMES , e ) ; } } List < IAtom > neighboor = mol . getConnectedAtomsList ( clonedAtom ) ; IAtom neighbour0 = ( IAtom ) neighboor . get ( 0 ) ; if ( atom . getSymbol ( ) . equals ( "H" ) ) { if ( neighbour0 . getFlag ( CDKConstants . ISAROMATIC ) ) { isProtonInAromaticSystem = 1 ; } else { List < IAtom > betaAtoms = clonedAtomContainer . getConnectedAtomsList ( neighbour0 ) ; for ( IAtom betaAtom : betaAtoms ) { if ( betaAtom . getFlag ( CDKConstants . ISAROMATIC ) ) { isProtonInAromaticSystem = 2 ; } else { isProtonInAromaticSystem = 0 ; } } } } else { isProtonInAromaticSystem = 0 ; } return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new IntegerResult ( isProtonInAromaticSystem ) , NAMES ) ; }
The method is a proton descriptor that evaluate if a proton is bonded to an aromatic system or if there is distance of 2 bonds . It is needed to call the addExplicitHydrogensToSatisfyValency method from the class tools . HydrogenAdder .
28,876
private MaccsKey [ ] keys ( final IChemObjectBuilder builder ) throws CDKException { MaccsKey [ ] result = keys ; if ( result == null ) { synchronized ( lock ) { result = keys ; if ( result == null ) { try { keys = result = readKeyDef ( builder ) ; } catch ( IOException e ) { throw new CDKException ( "could not read MACCS definitions" , e ) ; } } } } return result ; }
Access MACCS keys definitions .
28,877
private Pattern createPattern ( String smarts , IChemObjectBuilder builder ) throws IOException { SmartsPattern ptrn = SmartsPattern . create ( smarts , builder ) ; ptrn . setPrepare ( false ) ; return ptrn ; }
Create a pattern for the provided SMARTS - if the SMARTS is ? a pattern is not created .
28,878
public void process ( ) throws CDKException { logger . debug ( "Started parsing from input..." ) ; try { parser . setFeature ( "http://xml.org/sax/features/validation" , false ) ; logger . info ( "Deactivated validation" ) ; } catch ( SAXException e ) { logger . warn ( "Cannot deactivate validation." ) ; } parser . setContentHandler ( new EventCMLHandler ( this , builder ) ) ; parser . setEntityResolver ( new CMLResolver ( ) ) ; parser . setErrorHandler ( new CMLErrorHandler ( ) ) ; try { logger . debug ( "Parsing from Reader" ) ; parser . parse ( new InputSource ( input ) ) ; } catch ( IOException e ) { String error = "Error while reading file: " + e . getMessage ( ) ; logger . error ( error ) ; logger . debug ( e ) ; throw new CDKException ( error , e ) ; } catch ( SAXParseException saxe ) { SAXParseException spe = ( SAXParseException ) saxe ; String error = "Found well-formedness error in line " + spe . getLineNumber ( ) ; logger . error ( error ) ; logger . debug ( saxe ) ; throw new CDKException ( error , saxe ) ; } catch ( SAXException saxe ) { String error = "Error while parsing XML: " + saxe . getMessage ( ) ; logger . error ( error ) ; logger . debug ( saxe ) ; throw new CDKException ( error , saxe ) ; } }
Starts the reading of the CML file . Whenever a new Molecule is read a event is thrown to the ReaderListener .
28,879
public void addReactant ( IAtomContainer reactant , Double coefficient ) { reactants . addAtomContainer ( reactant , coefficient ) ; notifyChanged ( ) ; }
Adds a reactant to this reaction with a stoichiometry coefficient .
28,880
public boolean setReactantCoefficients ( Double [ ] coefficients ) { boolean result = reactants . setMultipliers ( coefficients ) ; notifyChanged ( ) ; return result ; }
Sets the coefficients of the reactants .
28,881
public boolean setProductCoefficients ( Double [ ] coefficients ) { boolean result = products . setMultipliers ( coefficients ) ; notifyChanged ( ) ; return result ; }
Sets the coefficient of the products .
28,882
public void addMapping ( IMapping mapping ) { if ( mappingCount + 1 >= map . length ) growMappingArray ( ) ; map [ mappingCount ] = mapping ; mappingCount ++ ; notifyChanged ( ) ; }
Adds a mapping between the reactant and product side to this Reaction .
28,883
public void removeMapping ( int pos ) { for ( int i = pos ; i < mappingCount - 1 ; i ++ ) { map [ i ] = map [ i + 1 ] ; } map [ mappingCount - 1 ] = null ; mappingCount -- ; notifyChanged ( ) ; }
Removes a mapping between the reactant and product side to this Reaction .
28,884
public static MolecularFormulaRange getRange ( IMolecularFormulaSet mfSet ) { MolecularFormulaRange mfRange = new MolecularFormulaRange ( ) ; for ( IMolecularFormula mf : mfSet . molecularFormulas ( ) ) { for ( IIsotope isotope : mf . isotopes ( ) ) { int occur_new = mf . getIsotopeCount ( isotope ) ; if ( ! mfRange . contains ( isotope ) ) { mfRange . addIsotope ( isotope , occur_new , occur_new ) ; } else { int occur_old_Max = mfRange . getIsotopeCountMax ( isotope ) ; int occur_old_Min = mfRange . getIsotopeCountMin ( isotope ) ; if ( occur_new > occur_old_Max ) { mfRange . removeIsotope ( isotope ) ; mfRange . addIsotope ( isotope , occur_old_Min , occur_new ) ; } else if ( occur_new < occur_old_Min ) { mfRange . removeIsotope ( isotope ) ; mfRange . addIsotope ( isotope , occur_new , occur_old_Max ) ; } } } } for ( IMolecularFormula mf : mfSet . molecularFormulas ( ) ) { if ( mf . getIsotopeCount ( ) != mfRange . getIsotopeCount ( ) ) { for ( IIsotope isotope : mfRange . isotopes ( ) ) { if ( ! mf . contains ( isotope ) ) { int occurMax = mfRange . getIsotopeCountMax ( isotope ) ; mfRange . addIsotope ( isotope , 0 , occurMax ) ; } } } } return mfRange ; }
Extract from a set of MolecularFormula the range of each each element found and put the element and occurrence in a new MolecularFormulaRange .
28,885
public static IMolecularFormula getMaximalFormula ( MolecularFormulaRange mfRange , IChemObjectBuilder builder ) { IMolecularFormula formula = builder . newInstance ( IMolecularFormula . class ) ; for ( IIsotope isotope : mfRange . isotopes ( ) ) { formula . addIsotope ( isotope , mfRange . getIsotopeCountMax ( isotope ) ) ; } return formula ; }
Returns the maximal occurrence of the IIsotope into IMolecularFormula from this MolelecularFormulaRange .
28,886
public static IMolecularFormula getMinimalFormula ( MolecularFormulaRange mfRange , IChemObjectBuilder builder ) { IMolecularFormula formula = builder . newInstance ( IMolecularFormula . class ) ; for ( IIsotope isotope : mfRange . isotopes ( ) ) { formula . addIsotope ( isotope , mfRange . getIsotopeCountMin ( isotope ) ) ; } return formula ; }
Returns the minimal occurrence of the IIsotope into IMolecularFormula from this MolelecularFormulaRange .
28,887
public int [ ] transformPoint ( double xCoord , double yCoord ) { double [ ] src = new double [ ] { xCoord , yCoord } ; double [ ] dest = new double [ 2 ] ; this . transform . transform ( src , 0 , dest , 0 , 1 ) ; return new int [ ] { ( int ) dest [ 0 ] , ( int ) dest [ 1 ] } ; }
Transforms a point according to the current affine transformation converting a world coordinate into a screen coordinate .
28,888
protected Rectangle2D getTextBounds ( String text , double xCoord , double yCoord , Graphics2D graphics ) { FontMetrics fontMetrics = graphics . getFontMetrics ( ) ; Rectangle2D bounds = fontMetrics . getStringBounds ( text , graphics ) ; double widthPad = 3 ; double heightPad = 1 ; double width = bounds . getWidth ( ) + widthPad ; double height = bounds . getHeight ( ) + heightPad ; int [ ] point = this . transformPoint ( xCoord , yCoord ) ; return new Rectangle2D . Double ( point [ 0 ] - width / 2 , point [ 1 ] - height / 2 , width , height ) ; }
Calculates the boundaries of a text string in screen coordinates .
28,889
public Object [ ] getParameters ( ) { Object [ ] params = new Object [ 2 ] ; params [ 0 ] = checkAromaticity ; params [ 1 ] = checkRingSystem ; return params ; }
Gets the parameters attribute of the LargestChainDescriptor object .
28,890
public void setMode ( int mode ) { switch ( mode ) { case MODE_EXACT : case MODE_JCOMPOUNDMAPPER : break ; default : throw new IllegalArgumentException ( "Invalid mode specified!" ) ; } this . mode = mode ; int numAtoms = mol . getAtomCount ( ) ; for ( int atomIdx = 0 ; atomIdx < numAtoms ; atomIdx ++ ) this . aexpr [ atomIdx ] = encodeAtomExpr ( atomIdx ) ; }
Set the mode of SMARTS substructure selection
28,891
public String generate ( int [ ] atomIdxs ) { if ( atomIdxs == null ) throw new NullPointerException ( "No atom indexes provided" ) ; if ( atomIdxs . length == 0 ) return null ; if ( atomIdxs . length == 1 && mode == MODE_EXACT ) return aexpr [ atomIdxs [ 0 ] ] ; Arrays . fill ( rbnds , 0 ) ; Arrays . fill ( avisit , 0 ) ; for ( int atmIdx : atomIdxs ) avisit [ atmIdx ] = - 1 ; numVisit = 1 ; for ( int atomIdx : atomIdxs ) { if ( avisit [ atomIdx ] < 0 ) markRings ( atomIdx , - 1 ) ; } numVisit = 1 ; for ( int atmIdx : atomIdxs ) avisit [ atmIdx ] = - 1 ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < atomIdxs . length ; i ++ ) { if ( avisit [ atomIdxs [ i ] ] < 0 ) { if ( i > 0 ) sb . append ( '.' ) ; encodeExpr ( atomIdxs [ i ] , - 1 , sb ) ; } } return sb . toString ( ) ; }
Generate a SMARTS for the substructure formed of the provided atoms .
28,892
private void encodeExpr ( int idx , int bprev , StringBuilder sb ) { avisit [ idx ] = numVisit ++ ; sb . append ( aexpr [ idx ] ) ; final int d = deg [ idx ] ; int remain = d ; for ( int j = 0 ; j < d ; j ++ ) { int nbr = atomAdj [ idx ] [ j ] ; int bidx = bondAdj [ idx ] [ j ] ; if ( rbnds [ bidx ] < 0 ) { final int rnum = chooseRingNumber ( ) ; if ( rnum > 9 ) sb . append ( '%' ) ; sb . append ( rnum ) ; rbnds [ bidx ] = rnum ; } else if ( rbnds [ bidx ] > 0 ) { final int rnum = rbnds [ bidx ] ; releaseRingNumber ( rnum ) ; if ( rnum > 9 ) sb . append ( '%' ) ; sb . append ( rnum ) ; } if ( mode == MODE_EXACT && avisit [ nbr ] == 0 || bidx == bprev || rbnds [ bidx ] != 0 ) remain -- ; } for ( int j = 0 ; j < d ; j ++ ) { int nbr = atomAdj [ idx ] [ j ] ; int bidx = bondAdj [ idx ] [ j ] ; if ( mode == MODE_EXACT && avisit [ nbr ] == 0 || bidx == bprev || rbnds [ bidx ] != 0 ) continue ; remain -- ; if ( avisit [ nbr ] == 0 ) { if ( remain > 0 ) sb . append ( '(' ) ; sb . append ( bexpr [ bidx ] ) ; sb . append ( mol . getAtom ( nbr ) . isAromatic ( ) ? 'a' : '*' ) ; if ( remain > 0 ) sb . append ( ')' ) ; } else { if ( remain > 0 ) sb . append ( '(' ) ; sb . append ( bexpr [ bidx ] ) ; encodeExpr ( nbr , bidx , sb ) ; if ( remain > 0 ) sb . append ( ')' ) ; } } }
Recursively encodes a SMARTS expression into the provides string builder .
28,893
private int chooseRingNumber ( ) { for ( int i = 1 ; i < rnums . length ; i ++ ) { if ( rnums [ i ] == 0 ) { rnums [ i ] = 1 ; return i ; } } throw new IllegalStateException ( "No more ring numbers available!" ) ; }
Select the lowest ring number for use in SMARTS .
28,894
static public SimpleGraph getMoleculeGraph ( IAtomContainer molecule ) { SimpleGraph graph = new SimpleGraph ( ) ; for ( int i = 0 ; i < molecule . getAtomCount ( ) ; i ++ ) { IAtom atom = molecule . getAtom ( i ) ; graph . addVertex ( atom ) ; } for ( int i = 0 ; i < molecule . getBondCount ( ) ; i ++ ) { IBond bond = molecule . getBond ( i ) ; graph . addEdge ( bond . getBegin ( ) , bond . getEnd ( ) ) ; } return graph ; }
Creates a molecule graph for use with jgrapht . Bond orders are not respected .
28,895
public DescriptorValue calculate ( IAtomContainer container ) { if ( taeParams == null ) return getDummyDescriptorValue ( new CDKException ( "TAE parameters were not initialized" ) ) ; if ( ! ( container instanceof IBioPolymer ) ) return getDummyDescriptorValue ( new CDKException ( "The molecule should be of type IBioPolymer" ) ) ; IBioPolymer peptide = ( IBioPolymer ) container ; double [ ] desc = new double [ ndesc ] ; for ( int i = 0 ; i < ndesc ; i ++ ) desc [ i ] = 0.0 ; List < IMonomer > monomers = getMonomers ( peptide ) ; for ( Iterator < IMonomer > iterator = monomers . iterator ( ) ; iterator . hasNext ( ) ; ) { IMonomer monomer = iterator . next ( ) ; String o = monomer . getMonomerName ( ) ; if ( o . length ( ) == 0 ) continue ; String olc = String . valueOf ( o . toLowerCase ( ) . charAt ( 0 ) ) ; String tlc = ( String ) nametrans . get ( olc ) ; logger . debug ( "Converted " + olc + " to " + tlc ) ; Double [ ] params = ( Double [ ] ) taeParams . get ( tlc ) ; for ( int i = 0 ; i < ndesc ; i ++ ) desc [ i ] += params [ i ] ; } DoubleArrayResult retval = new DoubleArrayResult ( ndesc ) ; for ( int i = 0 ; i < ndesc ; i ++ ) retval . add ( desc [ i ] ) ; return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , retval , getDescriptorNames ( ) ) ; }
Calculates the 147 TAE descriptors for amino acids .
28,896
private List < Integer > getAttachedInOrder ( IRing macrocycle , IAtomContainer shared ) { List < Integer > ringAttach = new ArrayList < > ( ) ; Set < IAtom > visit = new HashSet < > ( ) ; IAtom atom = shared . getAtom ( 0 ) ; while ( atom != null ) { visit . add ( atom ) ; ringAttach . add ( macrocycle . indexOf ( atom ) ) ; List < IAtom > connected = shared . getConnectedAtomsList ( atom ) ; atom = null ; for ( IAtom neighbor : connected ) { if ( ! visit . contains ( neighbor ) ) { atom = neighbor ; break ; } } } return ringAttach ; }
Get the shared indices of a macrocycle and atoms shared with another ring .
28,897
private int selectCoords ( Collection < Point2d [ ] > ps , Point2d [ ] coords , IRing macrocycle , IRingSet ringset ) { assert ps . size ( ) != 0 ; final int [ ] winding = new int [ coords . length ] ; MacroScore best = null ; for ( Point2d [ ] p : ps ) { final int wind = winding ( p , winding ) ; MacroScore score = bestScore ( macrocycle , ringset , wind , winding ) ; if ( score . compareTo ( best ) < 0 ) { best = score ; System . arraycopy ( p , 0 , coords , 0 , p . length ) ; } } return best != null ? best . offset : 0 ; }
Select the best coordinates
28,898
private static int winding ( final Point2d [ ] coords , final int [ ] winding ) { int cw = 0 , ccw = 0 ; Point2d prev = coords [ coords . length - 1 ] ; for ( int i = 0 ; i < coords . length ; i ++ ) { Point2d curr = coords [ i ] ; Point2d next = coords [ ( i + 1 ) % coords . length ] ; winding [ i ] = winding ( prev , curr , next ) ; if ( winding [ i ] < 0 ) cw ++ ; else if ( winding [ i ] > 0 ) ccw ++ ; else return 0 ; prev = curr ; } if ( cw == ccw ) return 0 ; return cw > ccw ? CW : CCW ; }
Determine the overall winding and the vertex of a ring template .
28,899
private static int winding ( Point2d a , Point2d b , Point2d c ) { return ( int ) Math . signum ( ( b . x - a . x ) * ( c . y - a . y ) - ( b . y - a . y ) * ( c . x - a . x ) ) ; }
Determine the winding of three points using the determinant .