idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
28,300
private int getNumberOfHydrogen ( IAtomContainer atomContainer , IAtom atom ) { java . util . List < IBond > bonds = atomContainer . getConnectedBondsList ( atom ) ; IAtom connectedAtom ; int hCounter = 0 ; for ( IBond bond : bonds ) { connectedAtom = bond . getOther ( atom ) ; if ( connectedAtom . getSymbol ( ) . equals ( "H" ) ) { hCounter += 1 ; } } return hCounter ; }
Gets the numberOfHydrogen attribute of the Polarizability object .
28,301
private static boolean checkAbbreviationHighlight ( IAtomContainer container , Sgroup sgroup ) { assert sgroup . getType ( ) == SgroupType . CtabAbbreviation ; Set < IAtom > sgroupAtoms = sgroup . getAtoms ( ) ; int atomHighlight = 0 ; int bondHighlight = 0 ; int numSgroupAtoms = sgroupAtoms . size ( ) ; int numSgroupBonds = 0 ; Color color = null ; Color refcolor = null ; for ( IAtom atom : sgroupAtoms ) { if ( ( color = atom . getProperty ( StandardGenerator . HIGHLIGHT_COLOR ) ) != null ) { atomHighlight ++ ; if ( refcolor == null ) refcolor = color ; else if ( ! color . equals ( refcolor ) ) return false ; } else if ( atomHighlight != 0 ) { return false ; } } for ( IBond bond : container . bonds ( ) ) { IAtom beg = bond . getBegin ( ) ; IAtom end = bond . getEnd ( ) ; if ( sgroupAtoms . contains ( beg ) && sgroupAtoms . contains ( end ) ) { numSgroupBonds ++ ; if ( ( color = bond . getProperty ( StandardGenerator . HIGHLIGHT_COLOR ) ) != null ) { bondHighlight ++ ; if ( refcolor == null ) refcolor = color ; else if ( ! color . equals ( refcolor ) ) return false ; } else if ( bondHighlight != 0 ) { return false ; } } } return atomHighlight + bondHighlight == 0 || ( atomHighlight == numSgroupAtoms && bondHighlight == numSgroupBonds ) ; }
Checks whether the given abbreviation Sgroup either has no highlight or is fully highlighted . If an abbreviation is partially highlighted we don t want to contract it as this would hide the part being highlighted .
28,302
private static void hideMultipleParts ( IAtomContainer container , Sgroup sgroup ) { final Set < IBond > crossing = sgroup . getBonds ( ) ; final Set < IAtom > atoms = sgroup . getAtoms ( ) ; final Set < IAtom > parentAtoms = sgroup . getValue ( SgroupKey . CtabParentAtomList ) ; for ( IBond bond : container . bonds ( ) ) { if ( parentAtoms . contains ( bond . getBegin ( ) ) && parentAtoms . contains ( bond . getEnd ( ) ) ) continue ; if ( atoms . contains ( bond . getBegin ( ) ) || atoms . contains ( bond . getEnd ( ) ) ) StandardGenerator . hide ( bond ) ; } for ( IAtom atom : atoms ) { if ( ! parentAtoms . contains ( atom ) ) StandardGenerator . hide ( atom ) ; } for ( IBond bond : crossing ) { StandardGenerator . unhide ( bond ) ; } }
Hide the repeated atoms and bonds of a multiple group . We hide al atoms that belong to the group unless they are defined in the parent atom list . Any bond to those atoms that is not a crossing bond or one connecting atoms in the parent list is hidden .
28,303
IRenderingElement generateSgroups ( IAtomContainer container , AtomSymbol [ ] symbols ) { ElementGroup result = new ElementGroup ( ) ; List < Sgroup > sgroups = container . getProperty ( CDKConstants . CTAB_SGROUPS ) ; if ( sgroups == null || sgroups . isEmpty ( ) ) return result ; Map < IAtom , AtomSymbol > symbolMap = new HashMap < > ( ) ; for ( int i = 0 ; i < symbols . length ; i ++ ) { if ( symbols [ i ] != null ) symbolMap . put ( container . getAtom ( i ) , symbols [ i ] ) ; } for ( Sgroup sgroup : sgroups ) { switch ( sgroup . getType ( ) ) { case CtabAbbreviation : result . add ( generateAbbreviationSgroup ( container , sgroup ) ) ; break ; case CtabMultipleGroup : result . add ( generateMultipleSgroup ( sgroup , symbolMap ) ) ; break ; case CtabAnyPolymer : case CtabMonomer : case CtabCrossLink : case CtabCopolymer : case CtabStructureRepeatUnit : case CtabMer : case CtabGraft : case CtabModified : result . add ( generatePolymerSgroup ( sgroup , symbolMap ) ) ; break ; case CtabComponent : case CtabMixture : case CtabFormulation : result . add ( generateMixtureSgroup ( sgroup ) ) ; break ; case CtabGeneric : result . add ( generatePolymerSgroup ( sgroup , null ) ) ; break ; } } return result ; }
Generate the Sgroup elements for the provided atom contains .
28,304
private IRenderingElement generatePolymerSgroup ( Sgroup sgroup , Map < IAtom , AtomSymbol > symbolMap ) { List < SgroupBracket > brackets = sgroup . getValue ( SgroupKey . CtabBracket ) ; if ( brackets != null ) { SgroupType type = sgroup . getType ( ) ; String subscript = sgroup . getValue ( SgroupKey . CtabSubScript ) ; String connectivity = sgroup . getValue ( SgroupKey . CtabConnectivity ) ; switch ( type ) { case CtabCopolymer : subscript = "co" ; String subtype = sgroup . getValue ( SgroupKey . CtabSubType ) ; if ( "RAN" . equals ( subtype ) ) subscript = "ran" ; else if ( "BLK" . equals ( subtype ) ) subscript = "blk" ; else if ( "ALT" . equals ( subtype ) ) subscript = "alt" ; break ; case CtabCrossLink : subscript = "xl" ; break ; case CtabAnyPolymer : subscript = "any" ; break ; case CtabGraft : subscript = "grf" ; break ; case CtabMer : subscript = "mer" ; break ; case CtabMonomer : subscript = "mon" ; break ; case CtabModified : subscript = "mod" ; break ; case CtabStructureRepeatUnit : if ( subscript == null ) subscript = "n" ; if ( connectivity == null ) connectivity = "eu" ; break ; } if ( "ht" . equals ( connectivity ) || sgroup . getAtoms ( ) . size ( ) == 1 ) connectivity = null ; return generateSgroupBrackets ( sgroup , brackets , symbolMap , subscript , connectivity ) ; } else { return new ElementGroup ( ) ; } }
Generates polymer Sgroup elements .
28,305
public static Partition unit ( int size ) { Partition unit = new Partition ( ) ; unit . cells . add ( new TreeSet < Integer > ( ) ) ; for ( int i = 0 ; i < size ; i ++ ) { unit . cells . get ( 0 ) . add ( i ) ; } return unit ; }
Create a unit partition - in other words the coarsest possible partition where all the elements are in one cell .
28,306
public int numberOfElements ( ) { int n = 0 ; for ( SortedSet < Integer > cell : cells ) { n += cell . size ( ) ; } return n ; }
Calculate the size of the partition as the sum of the sizes of the cells .
28,307
public Permutation toPermutation ( ) { Permutation p = new Permutation ( this . size ( ) ) ; for ( int i = 0 ; i < this . size ( ) ; i ++ ) { p . set ( i , this . cells . get ( i ) . first ( ) ) ; } return p ; }
Converts the whole partition into a permutation .
28,308
public Partition splitBefore ( int cellIndex , int splitElement ) { Partition r = new Partition ( ) ; for ( int j = 0 ; j < cellIndex ; j ++ ) { r . addCell ( this . copyBlock ( j ) ) ; } r . addSingletonCell ( splitElement ) ; SortedSet < Integer > splitBlock = this . copyBlock ( cellIndex ) ; splitBlock . remove ( splitElement ) ; r . addCell ( splitBlock ) ; for ( int j = cellIndex + 1 ; j < this . size ( ) ; j ++ ) { r . addCell ( this . copyBlock ( j ) ) ; } return r ; }
Splits this partition by taking the cell at cellIndex and making two new cells - the first with the singleton splitElement and the second with the rest of the elements from that cell .
28,309
public void addSingletonCell ( int element ) { SortedSet < Integer > cell = new TreeSet < Integer > ( ) ; cell . add ( element ) ; this . cells . add ( cell ) ; }
Add a new singleton cell to the end of the partition containing only this element .
28,310
public void addCell ( int ... elements ) { SortedSet < Integer > cell = new TreeSet < Integer > ( ) ; for ( int element : elements ) { cell . add ( element ) ; } this . cells . add ( cell ) ; }
Adds a new cell to the end of the partition containing these elements .
28,311
public void addToCell ( int index , int element ) { if ( cells . size ( ) < index + 1 ) { addSingletonCell ( element ) ; } else { cells . get ( index ) . add ( element ) ; } }
Add an element to a particular cell .
28,312
public void order ( ) { Collections . sort ( cells , new Comparator < SortedSet < Integer > > ( ) { public int compare ( SortedSet < Integer > cellA , SortedSet < Integer > cellB ) { return cellA . first ( ) . compareTo ( cellB . first ( ) ) ; } } ) ; }
Sort the cells in increasing order .
28,313
public boolean inSameCell ( int elementI , int elementJ ) { for ( int cellIndex = 0 ; cellIndex < size ( ) ; cellIndex ++ ) { SortedSet < Integer > cell = getCell ( cellIndex ) ; if ( cell . contains ( elementI ) && cell . contains ( elementJ ) ) { return true ; } } return false ; }
Check that two elements are in the same cell of the partition .
28,314
public < T > Iterable < T > map ( final Function < int [ ] , T > f ) { return Iterables . transform ( iterable , f ) ; }
Map the mappings to another type . Each mapping is transformed using the provided function .
28,315
public Mappings limit ( int limit ) { return new Mappings ( query , target , Iterables . limit ( iterable , limit ) ) ; }
Limit the number of mappings - only this number of mappings will be generate .
28,316
public Mappings uniqueAtoms ( ) { return new Mappings ( query , target , new Iterable < int [ ] > ( ) { public Iterator < int [ ] > iterator ( ) { return Iterators . filter ( iterable . iterator ( ) , new UniqueAtomMatches ( ) ) ; } } ) ; }
Filter the mappings for those which cover a unique set of atoms in the target . The unique atom mappings are a subset of the unique bond matches .
28,317
public Mappings uniqueBonds ( ) { final int [ ] [ ] g = GraphUtil . toAdjList ( query ) ; return new Mappings ( query , target , new Iterable < int [ ] > ( ) { public Iterator < int [ ] > iterator ( ) { return Iterators . filter ( iterable . iterator ( ) , new UniqueBondMatches ( g ) ) ; } } ) ; }
Filter the mappings for those which cover a unique set of bonds in the target .
28,318
public int [ ] [ ] toArray ( ) { int [ ] [ ] res = new int [ 14 ] [ ] ; int size = 0 ; for ( int [ ] map : this ) { if ( size == res . length ) res = Arrays . copyOf ( res , size + ( size >> 1 ) ) ; res [ size ++ ] = map . clone ( ) ; } return Arrays . copyOf ( res , size ) ; }
Mappings are lazily generated and best used in a loop . However if all mappings are required this method can provide a fixed size array of mappings .
28,319
public static float calculate ( IAtomContainer query , IAtomContainer target ) throws CDKException { float [ ] mom1 = generateMoments ( query ) ; float [ ] mom2 = generateMoments ( target ) ; float sum = 0 ; for ( int i = 0 ; i < mom1 . length ; i ++ ) { sum += Math . abs ( mom1 [ i ] - mom2 [ i ] ) ; } return ( float ) ( 1.0 / ( 1.0 + sum / 12.0 ) ) ; }
Evaluate the 3D similarity between two molecules .
28,320
public boolean isCachedAtomContainer ( IAtomContainer container ) { if ( cachedDescriptorValues == null ) return false ; return ( cachedDescriptorValues . get ( PREVIOUS_ATOMCONTAINER ) == container ) ; }
Returns true if the cached IDescriptorResult s are for the given IAtomContainer .
28,321
public IDescriptorResult getCachedDescriptorValue ( IAtom atom ) { if ( cachedDescriptorValues == null ) return null ; return ( IDescriptorResult ) cachedDescriptorValues . get ( atom ) ; }
Returns the cached DescriptorValue for the given IAtom .
28,322
synchronized public void addLabel ( String label ) { if ( ! labelMap . contains ( label ) ) { labelMap . add ( labelCounter ++ , label ) ; } }
Add label if its not present
28,323
public DescriptorValue calculate ( IAtomContainer atomContainer ) { int hBondAcceptors = 0 ; IAtomContainer ac ; try { ac = ( IAtomContainer ) atomContainer . clone ( ) ; } catch ( CloneNotSupportedException e ) { return getDummyDescriptorValue ( e ) ; } if ( checkAromaticity ) { try { AtomContainerManipulator . percieveAtomTypesAndConfigureAtoms ( ac ) ; Aromaticity . cdkLegacy ( ) . apply ( ac ) ; } catch ( CDKException e ) { return getDummyDescriptorValue ( e ) ; } } atomloop : for ( IAtom atom : ac . atoms ( ) ) { if ( atom . getSymbol ( ) . equals ( "N" ) && atom . getFormalCharge ( ) <= 0 ) { List < IBond > bonds = ac . getConnectedBondsList ( atom ) ; int nPiBonds = 0 ; for ( IBond bond : bonds ) { if ( bond . getOther ( atom ) . getSymbol ( ) . equals ( "O" ) ) continue atomloop ; if ( IBond . Order . DOUBLE . equals ( bond . getOrder ( ) ) ) nPiBonds ++ ; } if ( atom . getFlag ( CDKConstants . ISAROMATIC ) && nPiBonds == 0 ) continue ; hBondAcceptors ++ ; } else if ( atom . getSymbol ( ) . equals ( "O" ) && atom . getFormalCharge ( ) <= 0 ) { List < IBond > neighbours = ac . getConnectedBondsList ( atom ) ; for ( IBond bond : neighbours ) { IAtom neighbor = bond . getOther ( atom ) ; if ( neighbor . getSymbol ( ) . equals ( "N" ) || ( neighbor . getSymbol ( ) . equals ( "C" ) && neighbor . isAromatic ( ) && bond . getOrder ( ) != IBond . Order . DOUBLE ) ) continue atomloop ; ; } hBondAcceptors ++ ; } } return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new IntegerResult ( hBondAcceptors ) , getDescriptorNames ( ) ) ; }
Calculates the number of H bond acceptors .
28,324
private ILigand [ ] order ( ILigand [ ] ligands ) { ILigand [ ] newLigands = new ILigand [ ligands . length ] ; System . arraycopy ( ligands , 0 , newLigands , 0 , ligands . length ) ; Arrays . sort ( newLigands , numberRule ) ; ILigand [ ] reverseLigands = new ILigand [ newLigands . length ] ; for ( int i = 0 ; i < newLigands . length ; i ++ ) { reverseLigands [ ( newLigands . length - 1 ) - i ] = newLigands [ i ] ; } return reverseLigands ; }
Order the ligands from high to low precedence according to atomic and mass numbers .
28,325
public DescriptorValue calculate ( IAtom atom , IAtomContainer ac ) { Double originalCharge = atom . getCharge ( ) ; String originalAtomtypeName = atom . getAtomTypeName ( ) ; Integer originalNeighborCount = atom . getFormalNeighbourCount ( ) ; Integer originalValency = atom . getValency ( ) ; IAtomType . Hybridization originalHybridization = atom . getHybridization ( ) ; Double originalBondOrderSum = atom . getBondOrderSum ( ) ; Order originalMaxBondOrder = atom . getMaxBondOrder ( ) ; if ( ! isCachedAtomContainer ( ac ) ) { try { AtomContainerManipulator . percieveAtomTypesAndConfigureAtoms ( ac ) ; } catch ( CDKException e ) { new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( Double . NaN ) , NAMES , e ) ; } if ( lpeChecker ) { LonePairElectronChecker lpcheck = new LonePairElectronChecker ( ) ; try { lpcheck . saturate ( ac ) ; } catch ( CDKException e ) { new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( Double . NaN ) , NAMES , e ) ; } } if ( maxIterations != - 1 ) pepe . setMaxGasteigerIters ( maxIterations ) ; if ( maxResonStruc != - 1 ) pepe . setMaxResoStruc ( maxResonStruc ) ; try { peoe . assignGasteigerMarsiliSigmaPartialCharges ( ac , true ) ; List < Double > peoeAtom = new ArrayList < Double > ( ) ; for ( Iterator < IAtom > it = ac . atoms ( ) . iterator ( ) ; it . hasNext ( ) ; ) peoeAtom . add ( it . next ( ) . getCharge ( ) ) ; for ( Iterator < IAtom > it = ac . atoms ( ) . iterator ( ) ; it . hasNext ( ) ; ) it . next ( ) . setCharge ( 0.0 ) ; pepe . assignGasteigerPiPartialCharges ( ac , true ) ; for ( int i = 0 ; i < ac . getAtomCount ( ) ; i ++ ) cacheDescriptorValue ( ac . getAtom ( i ) , ac , new DoubleResult ( peoeAtom . get ( i ) + ac . getAtom ( i ) . getCharge ( ) ) ) ; } catch ( Exception e ) { new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( Double . NaN ) , NAMES , e ) ; } } atom . setCharge ( originalCharge ) ; atom . setAtomTypeName ( originalAtomtypeName ) ; atom . setFormalNeighbourCount ( originalNeighborCount ) ; atom . setValency ( originalValency ) ; atom . setHybridization ( originalHybridization ) ; atom . setMaxBondOrder ( originalMaxBondOrder ) ; atom . setBondOrderSum ( originalBondOrderSum ) ; return getCachedDescriptorValue ( atom ) != null ? new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , getCachedDescriptorValue ( atom ) , NAMES ) : null ; }
The method returns partial total charges assigned to an heavy atom through PEOE method . It is needed to call the addExplicitHydrogensToSatisfyValency method from the class tools . HydrogenAdder .
28,326
public static boolean isValid ( String casNumber ) { boolean overall = true ; String format = "^(\\d+)-(\\d\\d)-(\\d)$" ; Pattern pattern = Pattern . compile ( format ) ; Matcher matcher = pattern . matcher ( casNumber ) ; overall = overall && matcher . matches ( ) ; if ( matcher . matches ( ) ) { String part1 = matcher . group ( 1 ) ; String part2 = matcher . group ( 2 ) ; String part3 = matcher . group ( 3 ) ; int part1value = Integer . parseInt ( part1 ) ; if ( part1value < 50 ) { overall = false ; } else { int digit = CASNumber . calculateCheckDigit ( part1 , part2 ) ; overall = overall && ( digit == Integer . parseInt ( part3 ) ) ; } } return overall ; }
Checks whether the registry number is valid .
28,327
public static String getVersion ( ) { if ( version != null ) return version ; try ( InputStream stream = CDK . class . getResourceAsStream ( RESOURCE_LOCATION ) ) { if ( stream == null ) { version = CDK . class . getPackage ( ) . getImplementationVersion ( ) ; } Properties props = new Properties ( ) ; props . load ( stream ) ; version = props . getProperty ( "version" ) ; return version ; } catch ( IOException exception ) { logger . error ( "Error while loading the build.props file: " , exception . getMessage ( ) ) ; logger . debug ( exception ) ; } return null ; }
Returns the version of this CDK library .
28,328
private static BitSet available ( int [ ] [ ] graph , IAtom [ ] atoms , EdgeToBondMap bonds ) { final BitSet available = new BitSet ( ) ; ATOMS : for ( int i = 0 ; i < atoms . length ; i ++ ) { final IAtom atom = atoms [ i ] ; if ( atom . getAtomicNumber ( ) == null ) throw new IllegalArgumentException ( "atom " + ( i + 1 ) + " had unset atomic number" ) ; if ( atom . getFormalCharge ( ) == null ) throw new IllegalArgumentException ( "atom " + ( i + 1 ) + " had unset formal charge" ) ; if ( atom . getImplicitHydrogenCount ( ) == null ) throw new IllegalArgumentException ( "atom " + ( i + 1 ) + " had unset implicit hydrogen count" ) ; if ( ! atom . getFlag ( ISAROMATIC ) ) continue ; int nPiBonds = 0 ; for ( final int w : graph [ i ] ) { IBond . Order order = bonds . get ( i , w ) . getOrder ( ) ; if ( order == DOUBLE ) { nPiBonds ++ ; } else if ( order . numeric ( ) > 2 ) { continue ATOMS ; } } final int element = atom . getAtomicNumber ( ) ; final int charge = atom . getFormalCharge ( ) ; final int valence = graph [ i ] . length + atom . getImplicitHydrogenCount ( ) + nPiBonds ; if ( available ( element , charge , valence ) ) { available . set ( i ) ; } } return available ; }
Determine the set of atoms that are available to have a double - bond .
28,329
private static boolean available ( final int element , final int charge , final int valence ) { switch ( Elements . ofNumber ( element ) ) { case Boron : if ( charge == 0 && valence <= 2 ) return true ; if ( charge == - 1 && valence <= 3 ) return true ; break ; case Carbon : case Silicon : case Germanium : case Tin : if ( charge == 0 && valence <= 3 ) return true ; break ; case Nitrogen : case Phosphorus : case Arsenic : case Antimony : if ( charge == 0 ) return valence <= 2 || valence == 4 ; if ( charge == 1 ) return valence <= 3 ; break ; case Oxygen : case Sulfur : case Selenium : case Tellurium : if ( charge == 0 ) return valence <= 1 || valence == 3 || valence == 5 ; if ( charge == 1 ) return valence <= 2 || valence == 4 ; break ; } return false ; }
Determine if the specified element with the provided charge and valance requires a pi bond?
28,330
public void addReaction ( IReaction reaction , int position ) { hashMapChain . put ( reaction , position ) ; this . addReaction ( reaction ) ; }
Added a IReaction for this chain in position .
28,331
public IReaction getReaction ( int position ) { if ( ! hashMapChain . containsValue ( position ) ) return null ; Set < Entry < IReaction , Integer > > entries = hashMapChain . entrySet ( ) ; for ( Iterator < Entry < IReaction , Integer > > it = entries . iterator ( ) ; it . hasNext ( ) ; ) { Entry < IReaction , Integer > entry = it . next ( ) ; if ( entry . getValue ( ) . equals ( position ) ) return entry . getKey ( ) ; } return null ; }
Get the reaction of this chain reaction object at the position .
28,332
public static IAtomContainerSet getAllAtomContainers ( IReactionScheme scheme ) { return getAllAtomContainers ( scheme , scheme . getBuilder ( ) . newInstance ( IAtomContainerSet . class ) ) ; }
get all AtomContainers object from a set of Reactions .
28,333
public static List < String > getAllIDs ( IReactionScheme scheme ) { List < String > IDlist = new ArrayList < String > ( ) ; if ( scheme . getID ( ) != null ) IDlist . add ( scheme . getID ( ) ) ; for ( IReaction reaction : scheme . reactions ( ) ) { IDlist . addAll ( ReactionManipulator . getAllIDs ( reaction ) ) ; } if ( scheme . getReactionSchemeCount ( ) != 0 ) for ( IReactionScheme rs : scheme . reactionSchemes ( ) ) { IDlist . addAll ( getAllIDs ( rs ) ) ; } return IDlist ; }
Get all ID of this IReactionSet .
28,334
public static IReactionSet getAllReactions ( IReactionScheme scheme ) { IReactionSet reactionSet = scheme . getBuilder ( ) . newInstance ( IReactionSet . class ) ; if ( scheme . getReactionSchemeCount ( ) != 0 ) for ( IReactionScheme schemeInt : scheme . reactionSchemes ( ) ) { for ( IReaction reaction : getAllReactions ( schemeInt ) . reactions ( ) ) reactionSet . addReaction ( reaction ) ; } for ( IReaction reaction : scheme . reactions ( ) ) reactionSet . addReaction ( reaction ) ; return reactionSet ; }
Get all IReaction s object from a given IReactionScheme .
28,335
public static IReactionScheme createReactionScheme ( IReactionSet reactionSet ) { IReactionScheme reactionScheme = reactionSet . getBuilder ( ) . newInstance ( IReactionScheme . class ) ; ArrayList < IReaction > listTopR = new ArrayList < IReaction > ( ) ; for ( IReaction reaction : reactionSet . reactions ( ) ) { if ( extractPrecursorReaction ( reaction , reactionSet ) . getReactionCount ( ) == 0 ) listTopR . add ( reaction ) ; } for ( IReaction reaction : listTopR ) { reactionScheme . addReaction ( reaction ) ; IReactionScheme newReactionScheme = setScheme ( reaction , reactionSet ) ; if ( newReactionScheme . getReactionCount ( ) != 0 || newReactionScheme . getReactionSchemeCount ( ) != 0 ) reactionScheme . add ( newReactionScheme ) ; } return reactionScheme ; }
Create a IReactionScheme give a IReactionSet object .
28,336
public static IReactionSet extractTopReactions ( IReactionScheme reactionScheme ) { IReactionSet reactionSet = reactionScheme . getBuilder ( ) . newInstance ( IReactionSet . class ) ; IReactionSet allSet = getAllReactions ( reactionScheme ) ; for ( IReaction reaction : allSet . reactions ( ) ) { IReactionSet precuSet = extractPrecursorReaction ( reaction , allSet ) ; if ( precuSet . getReactionCount ( ) == 0 ) { boolean found = false ; for ( IReaction reactIn : reactionSet . reactions ( ) ) { if ( reactIn . equals ( reaction ) ) found = true ; } if ( ! found ) reactionSet . addReaction ( reaction ) ; } } return reactionSet ; }
Extract a set of Reactions which are in top of a IReactionScheme . The top reactions are those which any of their reactants are participating in other reactions as a products .
28,337
private static IReactionScheme setScheme ( IReaction reaction , IReactionSet reactionSet ) { IReactionScheme reactionScheme = reaction . getBuilder ( ) . newInstance ( IReactionScheme . class ) ; IReactionSet reactConSet = extractSubsequentReaction ( reaction , reactionSet ) ; if ( reactConSet . getReactionCount ( ) != 0 ) { for ( IReaction reactionInt : reactConSet . reactions ( ) ) { reactionScheme . addReaction ( reactionInt ) ; IReactionScheme newRScheme = setScheme ( reactionInt , reactionSet ) ; if ( newRScheme . getReactionCount ( ) != 0 || newRScheme . getReactionSchemeCount ( ) != 0 ) { reactionScheme . add ( newRScheme ) ; } } } return reactionScheme ; }
Create a IReactionScheme given as a top a IReaction . If it doesn t exist any subsequent reaction return null ;
28,338
private static IReactionSet extractPrecursorReaction ( IReaction reaction , IReactionSet reactionSet ) { IReactionSet reactConSet = reaction . getBuilder ( ) . newInstance ( IReactionSet . class ) ; for ( IAtomContainer reactant : reaction . getReactants ( ) . atomContainers ( ) ) { for ( IReaction reactionInt : reactionSet . reactions ( ) ) { for ( IAtomContainer precursor : reactionInt . getProducts ( ) . atomContainers ( ) ) { if ( reactant . equals ( precursor ) ) { reactConSet . addReaction ( reactionInt ) ; } } } } return reactConSet ; }
Extract reactions from a IReactionSet which at least one product is existing as reactant given a IReaction
28,339
public static ArrayList < IAtomContainerSet > getAtomContainerSet ( IAtomContainer origenMol , IAtomContainer finalMol , IReactionScheme reactionScheme ) { ArrayList < IAtomContainerSet > listPath = new ArrayList < IAtomContainerSet > ( ) ; IReactionSet reactionSet = getAllReactions ( reactionScheme ) ; boolean found = false ; for ( IReaction reaction : reactionSet . reactions ( ) ) { if ( found ) break ; for ( IAtomContainer reactant : reaction . getReactants ( ) . atomContainers ( ) ) { if ( found ) break ; if ( reactant . equals ( origenMol ) ) { IAtomContainerSet allSet = reactionSet . getBuilder ( ) . newInstance ( IAtomContainerSet . class ) ; for ( IAtomContainer product : reaction . getProducts ( ) . atomContainers ( ) ) { if ( found ) break ; if ( ! product . equals ( finalMol ) ) { IAtomContainerSet allSet2 = getReactionPath ( product , finalMol , reactionSet ) ; if ( allSet2 . getAtomContainerCount ( ) != 0 ) { allSet . addAtomContainer ( origenMol ) ; allSet . addAtomContainer ( product ) ; allSet . add ( allSet2 ) ; } } else { allSet . addAtomContainer ( origenMol ) ; allSet . addAtomContainer ( product ) ; } if ( allSet . getAtomContainerCount ( ) != 0 ) { listPath . add ( allSet ) ; found = true ; } } break ; } } } return listPath ; }
Extract the list of AtomContainers taking part in the IReactionScheme to originate a product given a reactant .
28,340
public double compare ( IsotopePattern isoto1 , IsotopePattern isoto2 ) { IsotopePattern iso1 = IsotopePatternManipulator . sortAndNormalizedByIntensity ( isoto1 ) ; IsotopePattern iso2 = IsotopePatternManipulator . sortAndNormalizedByIntensity ( isoto2 ) ; if ( isoto1 . getCharge ( ) == 1 ) chargeToAdd = massE ; else if ( isoto1 . getCharge ( ) == - 1 ) chargeToAdd = - massE ; else chargeToAdd = 0 ; for ( IsotopeContainer isoC : iso1 . getIsotopes ( ) ) { double mass = isoC . getMass ( ) ; isoC . setMass ( mass + chargeToAdd ) ; } double diffMass , diffAbun , factor , totalFactor = 0d ; double score = 0d , tempScore ; int length = iso1 . getNumberOfIsotopes ( ) ; for ( int i = 0 ; i < length ; i ++ ) { IsotopeContainer isoContainer = iso1 . getIsotopes ( ) . get ( i ) ; factor = isoContainer . getIntensity ( ) ; totalFactor += factor ; int closestDp = getClosestDataDiff ( isoContainer , iso2 ) ; if ( closestDp == - 1 ) continue ; diffMass = isoContainer . getMass ( ) - iso2 . getIsotopes ( ) . get ( closestDp ) . getMass ( ) ; diffMass = Math . abs ( diffMass ) ; diffAbun = 1.0d - ( isoContainer . getIntensity ( ) / iso2 . getIsotopes ( ) . get ( closestDp ) . getIntensity ( ) ) ; diffAbun = Math . abs ( diffAbun ) ; tempScore = 1 - ( diffMass + diffAbun ) ; if ( tempScore < 0 ) tempScore = 0 ; score += ( tempScore * factor ) ; } return score / totalFactor ; }
Compare the IMolecularFormula with a isotope abundance pattern .
28,341
private int getClosestDataDiff ( IsotopeContainer isoContainer , IsotopePattern pattern ) { double diff = 100 ; int posi = - 1 ; for ( int i = 0 ; i < pattern . getNumberOfIsotopes ( ) ; i ++ ) { double tempDiff = Math . abs ( ( isoContainer . getMass ( ) ) - pattern . getIsotopes ( ) . get ( i ) . getMass ( ) ) ; if ( tempDiff <= ( tolerance_ppm / isoContainer . getMass ( ) ) && tempDiff < diff ) { diff = tempDiff ; posi = i ; } } return posi ; }
Search and find the closest difference in an array in terms of mass and intensity . Always return the position in this List .
28,342
private void setSmarts ( String [ ] smarts ) { keys . clear ( ) ; for ( String key : smarts ) { QueryAtomContainer qmol = new QueryAtomContainer ( null ) ; SmartsPattern ptrn = null ; ptrn = SmartsPattern . create ( key ) ; ptrn . setPrepare ( false ) ; keys . add ( new Key ( key , ptrn ) ) ; } }
Set the SMARTS patterns .
28,343
public void addAtom ( IAtom oAtom , IMonomer oMonomer ) { if ( ! contains ( oAtom ) ) { super . addAtom ( oAtom ) ; if ( oMonomer != null ) { oMonomer . addAtom ( oAtom ) ; if ( ! monomers . containsKey ( oMonomer . getMonomerName ( ) ) ) { monomers . put ( oMonomer . getMonomerName ( ) , oMonomer ) ; } } } }
Adds the atom oAtom to a specified Monomer .
28,344
private void adjust ( ExtendedCisTrans elem ) { IBond middle = elem . getFocus ( ) ; IAtom [ ] ends = ExtendedCisTrans . findTerminalAtoms ( container , middle ) ; IBond [ ] bonds = elem . getCarriers ( ) . toArray ( new IBond [ 2 ] ) ; IAtom left = ends [ 0 ] ; IAtom right = ends [ 1 ] ; int p = parity ( elem ) ; int q = parity ( getAtoms ( left , bonds [ 0 ] . getOther ( left ) , right ) ) * parity ( getAtoms ( right , bonds [ 1 ] . getOther ( right ) , left ) ) ; if ( p == 0 ) { for ( IBond bond : container . getConnectedBondsList ( left ) ) bond . setStereo ( IBond . Stereo . NONE ) ; for ( IBond bond : container . getConnectedBondsList ( right ) ) bond . setStereo ( IBond . Stereo . NONE ) ; bonds [ 0 ] . setStereo ( IBond . Stereo . UP_OR_DOWN ) ; return ; } if ( p == q ) return ; Arrays . fill ( visited , false ) ; visited [ atomToIndex . get ( left ) ] = true ; if ( ringSearch . cyclic ( atomToIndex . get ( middle . getBegin ( ) ) , atomToIndex . get ( middle . getEnd ( ) ) ) ) { return ; } for ( int w : graph [ atomToIndex . get ( right ) ] ) { if ( ! visited [ w ] ) reflect ( w , middle ) ; } }
Adjust the configuration of the cumulated double bonds to be either Cis or Trans .
28,345
private IAtom [ ] getAtoms ( IAtom focus , IAtom substituent , IAtom otherFocus ) { IAtom otherSubstituent = focus ; for ( int w : graph [ atomToIndex . get ( focus ) ] ) { IAtom atom = container . getAtom ( w ) ; if ( ! atom . equals ( substituent ) && ! atom . equals ( otherFocus ) ) otherSubstituent = atom ; } return new IAtom [ ] { substituent , otherSubstituent , otherFocus } ; }
Create an array of three atoms for a side of the double bond . This is used to determine the winding of one side of the double bond .
28,346
private static int parity ( Point2d a , Point2d b , Point2d c ) { double det = ( a . x - c . x ) * ( b . y - c . y ) - ( a . y - c . y ) * ( b . x - c . x ) ; return ( int ) Math . signum ( det ) ; }
Determine the parity of the triangle formed by the 3 coordinates a b and c .
28,347
public List < Orbit > calculateOrbits ( ) { List < Orbit > orbits = new ArrayList < Orbit > ( ) ; List < SymmetryClass > symmetryClasses = super . getSymmetryClasses ( ) ; for ( SymmetryClass symmetryClass : symmetryClasses ) { Orbit orbit = new Orbit ( symmetryClass . getSignatureString ( ) , - 1 ) ; for ( int atomIndex : symmetryClass ) { orbit . addAtom ( atomIndex ) ; } orbits . add ( orbit ) ; } return orbits ; }
Calculates the orbits of the atoms of the molecule .
28,348
public String toCanonicalSignatureString ( int height ) { String canonicalSignature = null ; for ( int i = 0 ; i < getVertexCount ( ) ; i ++ ) { String signatureForI = signatureStringForVertex ( i , height ) ; if ( canonicalSignature == null || canonicalSignature . compareTo ( signatureForI ) < 0 ) { canonicalSignature = signatureForI ; } } return canonicalSignature ; }
Make a canonical signature string of a given height .
28,349
public IAtom [ ] getAtoms ( ) { IAtom [ ] returnAtoms = new Atom [ atomCount ] ; System . arraycopy ( this . atoms , 0 , returnAtoms , 0 , returnAtoms . length ) ; return returnAtoms ; }
Returns the array of atoms making up this Association .
28,350
public boolean contains ( IAtom atom ) { for ( int i = 0 ; i < atomCount ; i ++ ) { if ( atoms [ i ] . equals ( atom ) ) { return true ; } } return false ; }
Returns true if the given atom participates in this Association .
28,351
public void addChild ( String text , Position position ) { this . children . add ( new Child ( text , position ) ) ; }
Add a child text element .
28,352
public Object [ ] getParameters ( ) { Object [ ] params = new Object [ 1 ] ; params [ 0 ] = ( Integer ) maxIterations ; return params ; }
Gets the parameters attribute of the BondPartialSigmaChargeDescriptor object .
28,353
public DescriptorValue calculate ( IBond bond , IAtomContainer ac ) { Double originalCharge1 = bond . getBegin ( ) . getCharge ( ) ; Double originalCharge2 = bond . getEnd ( ) . getCharge ( ) ; if ( ! isCachedAtomContainer ( ac ) ) { IAtomContainer mol = ac . getBuilder ( ) . newInstance ( IAtomContainer . class , ac ) ; if ( maxIterations != 0 ) peoe . setMaxGasteigerIters ( maxIterations ) ; try { peoe . assignGasteigerMarsiliSigmaPartialCharges ( mol , true ) ; for ( Iterator < IBond > it = ac . bonds ( ) . iterator ( ) ; it . hasNext ( ) ; ) { IBond bondi = it . next ( ) ; double result = Math . abs ( bondi . getBegin ( ) . getCharge ( ) - bondi . getEnd ( ) . getCharge ( ) ) ; cacheDescriptorValue ( bondi , ac , new DoubleResult ( result ) ) ; } } catch ( Exception ex1 ) { return getDummyDescriptorValue ( ex1 ) ; } } bond . getBegin ( ) . setCharge ( originalCharge1 ) ; bond . getEnd ( ) . setCharge ( originalCharge2 ) ; return getCachedDescriptorValue ( bond ) != null ? new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , getCachedDescriptorValue ( bond ) , NAMES ) : null ; }
The method calculates the bond - sigma Partial charge of a given bond It is needed to call the addExplicitHydrogensToSatisfyValency method from the class tools . HydrogenAdder .
28,354
public Object getParameterType ( String name ) { if ( "maxIterations" . equals ( name ) ) return Integer . MAX_VALUE ; return null ; }
Gets the parameterType attribute of the BondPartialSigmaChargeDescriptor object .
28,355
private List < IBond > heavyBonds ( final List < IBond > bonds ) { final List < IBond > heavy = new ArrayList < IBond > ( bonds . size ( ) ) ; for ( final IBond bond : bonds ) { if ( ! ( bond . getBegin ( ) . getSymbol ( ) . equals ( "H" ) && bond . getEnd ( ) . getSymbol ( ) . equals ( "H" ) ) ) { heavy . add ( bond ) ; } } return heavy ; }
Filter a bond list keeping only bonds between heavy atoms .
28,356
private int countAttachedBonds ( List < IBond > connectedBonds , IAtom atom , IBond . Order order , String symbol ) { int neighborcount = connectedBonds . size ( ) ; int doubleBondedAtoms = 0 ; for ( int i = neighborcount - 1 ; i >= 0 ; i -- ) { IBond bond = connectedBonds . get ( i ) ; if ( bond . getOrder ( ) == order ) { if ( bond . getAtomCount ( ) == 2 ) { if ( symbol != null ) { if ( bond . getOther ( atom ) . getSymbol ( ) . equals ( symbol ) ) { doubleBondedAtoms ++ ; } } else { doubleBondedAtoms ++ ; } } } } return doubleBondedAtoms ; }
Count the number of doubly bonded atoms .
28,357
public InputSource resolveEntity ( String publicId , String systemId ) { logger . debug ( "CMLResolver: resolving " , publicId , ", " , systemId ) ; systemId = systemId . toLowerCase ( ) ; if ( ( systemId . indexOf ( "cml-1999-05-15.dtd" ) != - 1 ) || ( systemId . indexOf ( "cml.dtd" ) != - 1 ) || ( systemId . indexOf ( "cml1_0.dtd" ) != - 1 ) ) { logger . info ( "File has CML 1.0 DTD" ) ; return getCMLType ( "cml1_0.dtd" ) ; } else if ( ( systemId . indexOf ( "cml-2001-04-06.dtd" ) != - 1 ) || ( systemId . indexOf ( "cml1_0_1.dtd" ) != - 1 ) || ( systemId . indexOf ( "cml_1_0_1.dtd" ) != - 1 ) ) { logger . info ( "File has CML 1.0.1 DTD" ) ; return getCMLType ( "cml1_0_1.dtd" ) ; } else { logger . warn ( "Could not resolve systemID: " , systemId ) ; return null ; } }
Resolves SYSTEM and PUBLIC identifiers for CML DTDs .
28,358
protected void checkInputParameters ( final IChemObjectBuilder builder , final double minMass , final double maxMass , final MolecularFormulaRange mfRange ) { if ( ( minMass < 0.0 ) || ( maxMass < 0.0 ) ) { throw ( new IllegalArgumentException ( "The minimum and maximum mass values must be >=0" ) ) ; } if ( ( minMass > maxMass ) ) { throw ( new IllegalArgumentException ( "Minimum mass must be <= maximum mass" ) ) ; } if ( ( mfRange == null ) || ( mfRange . getIsotopeCount ( ) == 0 ) ) { throw ( new IllegalArgumentException ( "The MolecularFormulaRange parameter must be non-null and must contain at least one isotope" ) ) ; } for ( IIsotope isotope : mfRange . isotopes ( ) ) { if ( isotope . getExactMass ( ) == null ) throw new IllegalArgumentException ( "The exact mass value of isotope " + isotope + " is not set" ) ; } }
Checks if input parameters are valid and throws an IllegalArgumentException otherwise .
28,359
public int [ ] [ ] paths ( ) { final int [ ] [ ] paths = new int [ size ( ) ] [ 0 ] ; int i = 0 ; for ( final Cycle c : basis . members ( ) ) paths [ i ++ ] = c . path ( ) ; return paths ; }
The paths of all cycles in the minimum cycle basis .
28,360
public boolean compare ( Object object ) { if ( ! ( object instanceof IAtom ) ) { return false ; } if ( ! super . compare ( object ) ) { return false ; } Atom atom = ( Atom ) object ; if ( ( ( point2d == atom . point2d ) || ( ( point2d != null ) && ( point2d . equals ( atom . point2d ) ) ) ) && ( ( point3d == atom . point3d ) || ( ( point3d != null ) && ( point3d . equals ( atom . point3d ) ) ) ) && ( Objects . equals ( hydrogenCount , atom . hydrogenCount ) ) && ( Objects . equals ( stereoParity , atom . stereoParity ) ) && ( Objects . equals ( charge , atom . charge ) ) ) { return true ; } return false ; }
Compares a atom with this atom .
28,361
public ISimpleChemObjectReader createReader ( InputStream input ) throws IOException { IChemFormat format = null ; ISimpleChemObjectReader reader = null ; if ( input instanceof GZIPInputStream ) { format = formatFactory . guessFormat ( input ) ; reader = createReader ( format ) ; if ( reader != null ) { try { reader . setReader ( input ) ; } catch ( CDKException e1 ) { IOException wrapper = new IOException ( "Exception while setting the InputStream: " + e1 . getMessage ( ) ) ; wrapper . initCause ( e1 ) ; throw wrapper ; } } } else { BufferedInputStream bistream = new BufferedInputStream ( input , headerLength ) ; InputStream istreamToRead = bistream ; bistream . mark ( 5 ) ; int countRead = 0 ; byte [ ] abMagic = new byte [ 4 ] ; countRead = bistream . read ( abMagic , 0 , 4 ) ; bistream . reset ( ) ; if ( countRead == 4 ) { if ( abMagic [ 0 ] == ( byte ) 0x1F && abMagic [ 1 ] == ( byte ) 0x8B ) { istreamToRead = new BufferedInputStream ( new GZIPInputStream ( bistream ) ) ; } } format = formatFactory . guessFormat ( istreamToRead ) ; reader = createReader ( format ) ; if ( reader != null ) { try { reader . setReader ( istreamToRead ) ; } catch ( CDKException e1 ) { IOException wrapper = new IOException ( "Exception while setting the InputStream: " + e1 . getMessage ( ) ) ; wrapper . initCause ( e1 ) ; throw wrapper ; } } } return reader ; }
Detects the format of the Reader input and if known it will return a CDK Reader to read the format or null when the reader is not implemented .
28,362
public ISimpleChemObjectReader createReader ( IChemFormat format ) { if ( format != null ) { String readerClassName = format . getReaderClassName ( ) ; if ( readerClassName != null ) { try { return ( ISimpleChemObjectReader ) this . getClass ( ) . getClassLoader ( ) . loadClass ( readerClassName ) . newInstance ( ) ; } catch ( ClassNotFoundException exception ) { logger . error ( "Could not find this ChemObjectReader: " , readerClassName ) ; logger . debug ( exception ) ; } catch ( InstantiationException | IllegalAccessException exception ) { logger . error ( "Could not create this ChemObjectReader: " , readerClassName ) ; logger . debug ( exception ) ; } } else { logger . warn ( "ChemFormat is recognized, but no reader is available." ) ; } } else { logger . warn ( "ChemFormat is not recognized." ) ; } return null ; }
Creates a new IChemObjectReader based on the given IChemFormat .
28,363
public List < IAtomContainer > getTautomers ( IAtomContainer mol ) throws CDKException , CloneNotSupportedException { String opt = "" ; if ( ( flags & KETO_ENOL ) != 0 ) opt += " -KET" ; if ( ( flags & ONE_FIVE_SHIFT ) != 0 ) opt += " -15T" ; InChIGenerator gen = InChIGeneratorFactory . getInstance ( ) . getInChIGenerator ( mol , opt ) ; String inchi = gen . getInchi ( ) ; String aux = gen . getAuxInfo ( ) ; long [ ] amap = new long [ mol . getAtomCount ( ) ] ; InChINumbersTools . parseAuxInfo ( aux , amap ) ; if ( inchi == null ) throw new CDKException ( InChIGenerator . class + " failed to create an InChI for the provided molecule, InChI -> null." ) ; return getTautomers ( mol , inchi , amap ) ; }
Public method to get tautomers for an input molecule based on the InChI which will be calculated by JNI - InChI .
28,364
private IAtomContainer connectAtoms ( String inputInchi , IAtomContainer inputMolecule , Map < Integer , IAtom > inchiAtomsByPosition ) throws CDKException { String inchi = inputInchi ; inchi = inchi . substring ( inchi . indexOf ( '/' ) + 1 ) ; inchi = inchi . substring ( inchi . indexOf ( '/' ) + 1 ) ; String connections = inchi . substring ( 1 , inchi . indexOf ( '/' ) ) ; Pattern connectionPattern = Pattern . compile ( "(-|\\(|\\)|,|([0-9])*)" ) ; Matcher match = connectionPattern . matcher ( connections ) ; Stack < IAtom > atomStack = new Stack < IAtom > ( ) ; IAtomContainer inchiMolGraph = inputMolecule . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; boolean pop = false ; boolean push = true ; while ( match . find ( ) ) { String group = match . group ( ) ; push = true ; if ( ! group . isEmpty ( ) ) { if ( group . matches ( "[0-9]*" ) ) { IAtom atom = inchiAtomsByPosition . get ( Integer . valueOf ( group ) ) ; if ( ! inchiMolGraph . contains ( atom ) ) inchiMolGraph . addAtom ( atom ) ; IAtom prevAtom = null ; if ( atomStack . size ( ) != 0 ) { if ( pop ) { prevAtom = atomStack . pop ( ) ; } else { prevAtom = atomStack . get ( atomStack . size ( ) - 1 ) ; } IBond bond = inputMolecule . getBuilder ( ) . newInstance ( IBond . class , prevAtom , atom , IBond . Order . SINGLE ) ; inchiMolGraph . addBond ( bond ) ; } if ( push ) { atomStack . push ( atom ) ; } } else if ( group . equals ( "-" ) ) { pop = true ; push = true ; } else if ( group . equals ( "," ) ) { atomStack . pop ( ) ; pop = false ; push = false ; } else if ( group . equals ( "(" ) ) { pop = false ; push = true ; } else if ( group . equals ( ")" ) ) { atomStack . pop ( ) ; pop = true ; push = true ; } else { throw new CDKException ( "Unexpected token " + group + " in connection table encountered." ) ; } } } for ( IAtom at : inchiAtomsByPosition . values ( ) ) { if ( ! inchiMolGraph . contains ( at ) ) inchiMolGraph . addAtom ( at ) ; } return inchiMolGraph ; }
Pops and pushes its ways through the InChI connection table to build up a simple molecule .
28,365
private void mapInputMoleculeToInchiMolgraph ( IAtomContainer inchiMolGraph , IAtomContainer mol ) throws CDKException { Iterator < Map < IAtom , IAtom > > iter = org . openscience . cdk . isomorphism . VentoFoggia . findIdentical ( inchiMolGraph , AtomMatcher . forElement ( ) , BondMatcher . forAny ( ) ) . matchAll ( mol ) . limit ( 1 ) . toAtomMap ( ) . iterator ( ) ; if ( iter . hasNext ( ) ) { for ( Map . Entry < IAtom , IAtom > e : iter . next ( ) . entrySet ( ) ) { IAtom src = e . getKey ( ) ; IAtom dst = e . getValue ( ) ; String position = src . getID ( ) ; dst . setID ( position ) ; LOGGER . debug ( "Mapped InChI " , src . getSymbol ( ) , " " , src . getID ( ) , " to " , dst . getSymbol ( ) , " " + dst . getID ( ) ) ; } } else { throw new IllegalArgumentException ( CANSMI . create ( inchiMolGraph ) + " " + CANSMI . create ( mol ) ) ; } }
Atom - atom mapping of the input molecule to the bare container constructed from the InChI connection table . This makes it possible to map the positions of the mobile hydrogens in the InChI back to the input molecule .
28,366
private void combineHydrogenPositions ( List < Integer > taken , List < List < Integer > > combinations , IAtomContainer skeleton , int totalMobHydrCount , List < Integer > mobHydrAttachPositions ) { if ( taken . size ( ) != totalMobHydrCount ) { for ( int i = 0 ; i < mobHydrAttachPositions . size ( ) ; i ++ ) { int pos = mobHydrAttachPositions . get ( i ) ; IAtom atom = findAtomByPosition ( skeleton , pos ) ; int conn = getConnectivity ( atom , skeleton ) ; int hCnt = 0 ; for ( int t : taken ) if ( t == pos ) hCnt ++ ; if ( atom . getValency ( ) - atom . getFormalCharge ( ) > ( hCnt + conn ) ) { taken . add ( pos ) ; combineHydrogenPositions ( taken , combinations , skeleton , totalMobHydrCount , mobHydrAttachPositions ) ; taken . remove ( taken . size ( ) - 1 ) ; } } } else { List < Integer > addList = new ArrayList < Integer > ( taken . size ( ) ) ; addList . addAll ( taken ) ; Collections . sort ( addList ) ; if ( ! combinations . contains ( addList ) ) { combinations . add ( addList ) ; } } }
Makes combinations recursively of all possible mobile Hydrogen positions .
28,367
private IAtom findAtomByPosition ( IAtomContainer container , int position ) { String pos = String . valueOf ( position ) ; for ( IAtom atom : container . atoms ( ) ) { if ( atom . getID ( ) . equals ( pos ) ) return atom ; } return null ; }
Helper method that locates an atom based on its InChI atom table position which has been set as ID .
28,368
private List < Integer > tryDoubleBondCombinations ( IAtomContainer container , int dblBondsAdded , int bondOffSet , int doubleBondMax , List < IAtom > atomsInNeedOfFix ) { int offSet = bondOffSet ; List < Integer > dblBondPositions = null ; while ( offSet < container . getBondCount ( ) && dblBondPositions == null ) { IBond bond = container . getBond ( offSet ) ; if ( atomsInNeedOfFix . contains ( bond . getBegin ( ) ) && atomsInNeedOfFix . contains ( bond . getEnd ( ) ) ) { bond . setOrder ( IBond . Order . DOUBLE ) ; dblBondsAdded = dblBondsAdded + 1 ; if ( dblBondsAdded == doubleBondMax ) { boolean validDoubleBondConfig = true ; CHECK : for ( IAtom atom : container . atoms ( ) ) { if ( atom . getValency ( ) != atom . getImplicitHydrogenCount ( ) + getConnectivity ( atom , container ) ) { validDoubleBondConfig = false ; break CHECK ; } } if ( validDoubleBondConfig ) { dblBondPositions = new ArrayList < Integer > ( ) ; for ( int idx = 0 ; idx < container . getBondCount ( ) ; idx ++ ) { if ( container . getBond ( idx ) . getOrder ( ) . equals ( IBond . Order . DOUBLE ) ) dblBondPositions . add ( idx ) ; } return dblBondPositions ; } } else { dblBondPositions = tryDoubleBondCombinations ( container , dblBondsAdded , offSet + 1 , doubleBondMax , atomsInNeedOfFix ) ; } bond . setOrder ( IBond . Order . SINGLE ) ; dblBondsAdded = dblBondsAdded - 1 ; } offSet ++ ; } return dblBondPositions ; }
Tries double bond combinations for a certain input container of which the double bonds have been stripped around the mobile hydrogen positions . Recursively .
28,369
static double max ( double [ ] values ) { double max = values [ 0 ] ; for ( double value : values ) if ( value > max ) max = value ; return max ; }
Analog of Math . max that returns the largest double value in an array of doubles .
28,370
static double min ( double [ ] values ) { double min = values [ 0 ] ; for ( double value : values ) if ( value < min ) min = value ; return min ; }
Analog of Math . min that returns the largest double value in an array of double .
28,371
public void addChemModel ( IChemModel chemModel ) { if ( chemModelCount + 1 >= chemModels . length ) { growChemModelArray ( ) ; } chemModels [ chemModelCount ] = chemModel ; chemModelCount ++ ; }
Adds an chemModel to this container .
28,372
public StereoEncoder create ( IAtomContainer container , int [ ] [ ] graph ) { List < StereoEncoder > encoders = new ArrayList < StereoEncoder > ( 5 ) ; for ( IBond bond : container . bonds ( ) ) { if ( DOUBLE . equals ( bond . getOrder ( ) ) && ! E_OR_Z . equals ( bond . getStereo ( ) ) ) { IAtom left = bond . getBegin ( ) ; IAtom right = bond . getEnd ( ) ; if ( Integer . valueOf ( 7 ) . equals ( left . getAtomicNumber ( ) ) && Integer . valueOf ( 7 ) . equals ( right . getAtomicNumber ( ) ) ) continue ; StereoEncoder encoder = newEncoder ( container , left , right , right , left , graph ) ; if ( encoder != null ) { encoders . add ( encoder ) ; } } } return encoders . isEmpty ( ) ? StereoEncoder . EMPTY : new MultiStereoEncoder ( encoders ) ; }
Create a stereo encoder for all potential 2D and 3D double bond stereo configurations .
28,373
static StereoEncoder newEncoder ( IAtomContainer container , IAtom left , IAtom leftParent , IAtom right , IAtom rightParent , int [ ] [ ] graph ) { List < IBond > leftBonds = container . getConnectedBondsList ( left ) ; List < IBond > rightBonds = container . getConnectedBondsList ( right ) ; if ( accept ( left , leftBonds ) && accept ( right , rightBonds ) ) { int leftIndex = container . indexOf ( left ) ; int rightIndex = container . indexOf ( right ) ; int leftParentIndex = container . indexOf ( leftParent ) ; int rightParentIndex = container . indexOf ( rightParent ) ; int [ ] leftNeighbors = moveToBack ( graph [ leftIndex ] , leftParentIndex ) ; int [ ] rightNeighbors = moveToBack ( graph [ rightIndex ] , rightParentIndex ) ; int l1 = leftNeighbors [ 0 ] ; int l2 = leftNeighbors [ 1 ] == leftParentIndex ? leftIndex : leftNeighbors [ 1 ] ; int r1 = rightNeighbors [ 0 ] ; int r2 = rightNeighbors [ 1 ] == rightParentIndex ? rightIndex : rightNeighbors [ 1 ] ; GeometricParity geometric = geometric ( container , leftIndex , rightIndex , l1 , l2 , r1 , r2 ) ; if ( geometric != null ) { return new GeometryEncoder ( new int [ ] { leftIndex , rightIndex } , new CombinedPermutationParity ( permutation ( leftNeighbors ) , permutation ( rightNeighbors ) ) , geometric ) ; } } return null ; }
Create a new encoder for the specified left and right atoms . The parent is the atom which is connected by a double bond to the left and right atom . For simple double bonds the parent of each is the other atom in cumulenes the parents are not the same .
28,374
static PermutationParity permutation ( int [ ] neighbors ) { return neighbors . length == 2 ? PermutationParity . IDENTITY : new BasicPermutationParity ( Arrays . copyOf ( neighbors , neighbors . length - 1 ) ) ; }
Create a permutation parity for the given neighbors . The neighbor list should include the other double bonded atom but in the last index .
28,375
public DescriptorValue calculate ( IAtom atom , IAtomContainer org ) { if ( atom . getProperty ( CHARGE_CACHE ) == null ) { IAtomContainer copy ; try { copy = org . clone ( ) ; } catch ( CloneNotSupportedException e ) { return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( Double . NaN ) , NAMES ) ; } for ( IAtom a : org . atoms ( ) ) { if ( a . getImplicitHydrogenCount ( ) == null || a . getImplicitHydrogenCount ( ) != 0 ) { logger . error ( "Hydrogens must be explict for MMFF charge calculation" ) ; return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( Double . NaN ) , NAMES ) ; } } if ( ! mmff . assignAtomTypes ( copy ) ) logger . warn ( "One or more atoms could not be assigned an MMFF atom type" ) ; mmff . partialCharges ( copy ) ; mmff . clearProps ( copy ) ; for ( int i = 0 ; i < org . getAtomCount ( ) ; i ++ ) { org . getAtom ( i ) . setProperty ( CHARGE_CACHE , copy . getAtom ( i ) . getCharge ( ) ) ; } } return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( atom . getProperty ( CHARGE_CACHE , Double . class ) ) , NAMES ) ; }
The method returns partial charges assigned to an heavy atom through MMFF94 method . It is needed to call the addExplicitHydrogensToSatisfyValency method from the class tools . HydrogenAdder .
28,376
private void fixNCNTypes ( String [ ] symbs , int [ ] [ ] graph ) { for ( int v = 0 ; v < graph . length ; v ++ ) { if ( "NCN+" . equals ( symbs [ v ] ) ) { boolean foundCNN = false ; for ( int w : graph [ v ] ) { foundCNN = foundCNN || "CNN+" . equals ( symbs [ w ] ) || "CIM+" . equals ( symbs [ w ] ) ; } if ( ! foundCNN ) { symbs [ v ] = "NC=N" ; } } } }
Special case NCN + matches entries that the validation suite say should actually be NC = N . We can achieve 100% compliance by checking if NCN + is still next to CNN + or CIM + after aromatic types are assigned
28,377
private void checkPreconditions ( IAtomContainer container ) { for ( IAtom atom : container . atoms ( ) ) { if ( atom . getImplicitHydrogenCount ( ) == null || atom . getImplicitHydrogenCount ( ) != 0 ) throw new IllegalArgumentException ( "Hydrogens should be unsuppressed (explicit)" ) ; if ( atom . getFlag ( CDKConstants . ISAROMATIC ) ) throw new IllegalArgumentException ( "No aromatic flags should be set" ) ; } }
preconditions 1 . all hydrogens must be present as explicit nodes in the connection table . this requires that each atom explicitly states it has exactly 0 hydrogens 2 . the SMARTS treat all atoms as aliphatic and therefore no aromatic flags should be set we could remove this but ideally we don t want to modify the structure
28,378
private void assignHydrogenTypes ( IAtomContainer container , String [ ] symbs , int [ ] [ ] graph ) { for ( int v = 0 ; v < graph . length ; v ++ ) { if ( container . getAtom ( v ) . getSymbol ( ) . equals ( "H" ) && graph [ v ] . length == 1 ) { int w = graph [ v ] [ 0 ] ; symbs [ v ] = this . hydrogenMap . get ( symbs [ w ] ) ; } } }
Hydrogen types assigned based on the MMFFHDEF . PAR parent associations .
28,379
private void assignPreliminaryTypes ( IAtomContainer container , String [ ] symbs ) { IAtomContainer cpy = container . getBuilder ( ) . newInstance ( IAtomContainer . class , container ) ; Cycles . markRingAtomsAndBonds ( cpy ) ; for ( AtomTypePattern matcher : patterns ) { for ( final int idx : matcher . matches ( cpy ) ) { if ( symbs [ idx ] == null ) { symbs [ idx ] = matcher . symb ; } } } }
Preliminary atom types are assigned using SMARTS definitions .
28,380
static AtomTypePattern [ ] loadPatterns ( InputStream smaIn ) throws IOException { List < AtomTypePattern > matchers = new ArrayList < AtomTypePattern > ( ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( smaIn ) ) ; String line = null ; while ( ( line = br . readLine ( ) ) != null ) { if ( skipLine ( line ) ) continue ; String [ ] cols = line . split ( " " ) ; String sma = cols [ 0 ] ; String symb = cols [ 1 ] ; try { matchers . add ( new AtomTypePattern ( SmartsPattern . create ( sma ) . setPrepare ( false ) , symb ) ) ; } catch ( IllegalArgumentException ex ) { throw new IOException ( ex ) ; } } return matchers . toArray ( new AtomTypePattern [ matchers . size ( ) ] ) ; }
Internal - load the SMARTS patterns for each atom type from MMFFSYMB . sma .
28,381
private Map < String , String > loadHydrogenDefinitions ( InputStream hdefIn ) throws IOException { final Map < String , String > hdefs = new HashMap < String , String > ( 200 ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( hdefIn ) ) ; br . readLine ( ) ; String line = null ; while ( ( line = br . readLine ( ) ) != null ) { String [ ] cols = line . split ( "\t" ) ; hdefs . put ( cols [ 0 ] . trim ( ) , cols [ 3 ] . trim ( ) ) ; } return hdefs ; }
Hydrogen atom types are assigned based on their parent types . The mmff - symb - mapping file provides this mapping .
28,382
public static IsotopePattern normalize ( IsotopePattern isotopeP ) { IsotopeContainer isoHighest = null ; double biggestAbundance = 0 ; for ( IsotopeContainer isoContainer : isotopeP . getIsotopes ( ) ) { double abundance = isoContainer . getIntensity ( ) ; if ( biggestAbundance < abundance ) { biggestAbundance = abundance ; isoHighest = isoContainer ; } } IsotopePattern isoNormalized = new IsotopePattern ( ) ; for ( IsotopeContainer isoContainer : isotopeP . getIsotopes ( ) ) { double inten = isoContainer . getIntensity ( ) / isoHighest . getIntensity ( ) ; IsotopeContainer icClone ; try { icClone = ( IsotopeContainer ) isoContainer . clone ( ) ; icClone . setIntensity ( inten ) ; if ( isoHighest . equals ( isoContainer ) ) isoNormalized . setMonoIsotope ( icClone ) ; else isoNormalized . addIsotope ( icClone ) ; } catch ( CloneNotSupportedException e ) { e . printStackTrace ( ) ; } } isoNormalized . setCharge ( isotopeP . getCharge ( ) ) ; return isoNormalized ; }
Return the isotope pattern normalized to the highest abundance .
28,383
public static IsotopePattern sortAndNormalizedByIntensity ( IsotopePattern isotopeP ) { IsotopePattern isoNorma = normalize ( isotopeP ) ; return sortByIntensity ( isoNorma ) ; }
Return the isotope pattern sorted and normalized by intensity to the highest abundance .
28,384
public static IsotopePattern sortByMass ( IsotopePattern isotopeP ) { try { IsotopePattern isoSort = ( IsotopePattern ) isotopeP . clone ( ) ; if ( isoSort . getNumberOfIsotopes ( ) == 0 ) return isoSort ; List < IsotopeContainer > listISO = isoSort . getIsotopes ( ) ; Collections . sort ( listISO , new Comparator < IsotopeContainer > ( ) { public int compare ( IsotopeContainer o1 , IsotopeContainer o2 ) { return Double . compare ( o1 . getMass ( ) , o2 . getMass ( ) ) ; } } ) ; isoSort . setMonoIsotope ( listISO . get ( 0 ) ) ; return isoSort ; } catch ( CloneNotSupportedException e ) { e . printStackTrace ( ) ; } return null ; }
Return the isotope pattern sorted by mass to the highest abundance .
28,385
public double weight ( ) { double result = 0 ; Iterator edgeIterator = edgeSet ( ) . iterator ( ) ; while ( edgeIterator . hasNext ( ) ) { result += ( ( Edge ) edgeIterator . next ( ) ) . getWeight ( ) ; } return result ; }
Returns the sum of the weights of all edges in this cycle .
28,386
public List vertexList ( ) { List vertices = new ArrayList ( edgeSet ( ) . size ( ) ) ; Object startVertex = vertexSet ( ) . iterator ( ) . next ( ) ; Object vertex = startVertex ; Object previousVertex = null ; Object nextVertex = null ; while ( nextVertex != startVertex ) { assert ( degreeOf ( vertex ) == 2 ) ; List edges = edgesOf ( vertex ) ; vertices . add ( vertex ) ; Edge edge = ( Edge ) edges . get ( 0 ) ; nextVertex = edge . oppositeVertex ( vertex ) ; if ( nextVertex == previousVertex ) { edge = ( Edge ) edges . get ( 1 ) ; nextVertex = edge . oppositeVertex ( vertex ) ; } previousVertex = vertex ; vertex = nextVertex ; } return vertices ; }
Returns a list of the vertices contained in this cycle . The vertices are in the order of a traversal of the cycle .
28,387
public static Point3d [ ] zmatrixToCartesian ( double [ ] distances , int [ ] first_atoms , double [ ] angles , int [ ] second_atoms , double [ ] dihedrals , int [ ] third_atoms ) { Point3d [ ] cartesianCoords = new Point3d [ distances . length ] ; for ( int index = 0 ; index < distances . length ; index ++ ) { if ( index == 0 ) { cartesianCoords [ index ] = new Point3d ( 0d , 0d , 0d ) ; } else if ( index == 1 ) { cartesianCoords [ index ] = new Point3d ( distances [ 1 ] , 0d , 0d ) ; } else if ( index == 2 ) { cartesianCoords [ index ] = new Point3d ( - Math . cos ( ( angles [ 2 ] / 180 ) * Math . PI ) * distances [ 2 ] + distances [ 1 ] , Math . sin ( ( angles [ 2 ] / 180 ) * Math . PI ) * distances [ 2 ] , 0d ) ; if ( first_atoms [ index ] == 0 ) cartesianCoords [ index ] . x = ( cartesianCoords [ index ] . x - distances [ 1 ] ) * - 1 ; } else { Vector3d cd = new Vector3d ( ) ; cd . sub ( cartesianCoords [ third_atoms [ index ] ] , cartesianCoords [ second_atoms [ index ] ] ) ; Vector3d bc = new Vector3d ( ) ; bc . sub ( cartesianCoords [ second_atoms [ index ] ] , cartesianCoords [ first_atoms [ index ] ] ) ; Vector3d n1 = new Vector3d ( ) ; n1 . cross ( cd , bc ) ; Vector3d n2 = rotate ( n1 , bc , - dihedrals [ index ] ) ; Vector3d ba = rotate ( bc , n2 , - angles [ index ] ) ; ba . normalize ( ) ; ba . scale ( distances [ index ] ) ; Point3d result = new Point3d ( ) ; result . add ( cartesianCoords [ first_atoms [ index ] ] , ba ) ; cartesianCoords [ index ] = result ; } } return cartesianCoords ; }
Takes the given Z Matrix coordinates and converts them to cartesian coordinates . The first Atom end up in the origin the second on on the x axis and the third one in the XY plane . The rest is added by applying the Zmatrix distances angles and dihedrals . Angles are in degrees .
28,388
public void setParameters ( Object [ ] params ) throws CDKException { if ( params . length > 1 ) { throw new CDKException ( "SigmaElectronegativityDescriptor only expects one parameter" ) ; } if ( ! ( params [ 0 ] instanceof Integer ) ) { throw new CDKException ( "The parameter must be of type Integer" ) ; } if ( params . length == 0 ) return ; maxIterations = ( Integer ) params [ 0 ] ; }
Sets the parameters attribute of the SigmaElectronegativityDescriptor object
28,389
public DescriptorValue calculate ( IAtom atom , IAtomContainer ac ) { IAtomContainer clone ; IAtom localAtom ; try { clone = ( IAtomContainer ) ac . clone ( ) ; localAtom = clone . getAtom ( ac . indexOf ( atom ) ) ; AtomContainerManipulator . percieveAtomTypesAndConfigureAtoms ( clone ) ; } catch ( CDKException e ) { return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( Double . NaN ) , NAMES , e ) ; } catch ( CloneNotSupportedException e ) { return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( Double . NaN ) , NAMES , e ) ; } if ( maxIterations != - 1 && maxIterations != 0 ) electronegativity . setMaxIterations ( maxIterations ) ; double result = electronegativity . calculateSigmaElectronegativity ( clone , localAtom ) ; return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( result ) , NAMES ) ; }
The method calculates the sigma electronegativity of a given atom It is needed to call the addExplicitHydrogensToSatisfyValency method from the class tools . HydrogenAdder .
28,390
public void addIsotope ( IIsotope isotope , int countMin , int countMax ) { if ( isotope == null ) throw new IllegalArgumentException ( "Isotope must not be null" ) ; boolean flag = false ; for ( Iterator < IIsotope > it = isotopes ( ) . iterator ( ) ; it . hasNext ( ) ; ) { IIsotope thisIsotope = it . next ( ) ; if ( isTheSame ( thisIsotope , isotope ) ) { isotopesMax . put ( thisIsotope , countMax ) ; isotopesMin . put ( thisIsotope , countMin ) ; flag = true ; break ; } } if ( ! flag ) { isotopesMax . put ( isotope , countMax ) ; isotopesMin . put ( isotope , countMin ) ; } }
Adds an Isotope to this MolecularFormulaExpand in a number of maximum and minimum occurrences allowed .
28,391
public Iterable < IIsotope > isotopes ( ) { return new Iterable < IIsotope > ( ) { public Iterator < IIsotope > iterator ( ) { return isotopesMax . keySet ( ) . iterator ( ) ; } } ; }
Returns an Iterator for looping over all isotopes in this MolecularFormulaExpand .
28,392
public void removeIsotope ( IIsotope isotope ) { isotopesMax . remove ( getIsotope ( isotope ) ) ; isotopesMin . remove ( getIsotope ( isotope ) ) ; }
Removes the given isotope from the MolecularFormulaExpand .
28,393
private IChemFile readChemFile ( IChemFile chemFile ) throws CDKException { IChemSequence chemSequence = chemFile . getBuilder ( ) . newInstance ( IChemSequence . class ) ; IChemModel chemModel = chemFile . getBuilder ( ) . newInstance ( IChemModel . class ) ; chemSequence . addChemModel ( readChemModel ( chemModel ) ) ; chemFile . addChemSequence ( chemSequence ) ; return chemFile ; }
Read a ChemFile from a file in MDL RDF format .
28,394
private IChemModel readChemModel ( IChemModel chemModel ) throws CDKException { IReactionSet setOfReactions = chemModel . getReactionSet ( ) ; if ( setOfReactions == null ) { setOfReactions = chemModel . getBuilder ( ) . newInstance ( IReactionSet . class ) ; } chemModel . setReactionSet ( readReactionSet ( setOfReactions ) ) ; return chemModel ; }
Read a IChemModel from a file in MDL RDF format .
28,395
private IReactionSet readReactionSet ( IReactionSet setOfReactions ) throws CDKException { IReaction r = readReaction ( setOfReactions . getBuilder ( ) ) ; if ( r != null ) { setOfReactions . addReaction ( r ) ; } try { String line ; while ( ( line = input . readLine ( ) ) != null ) { logger . debug ( "line: " , line ) ; if ( line . equals ( "$$$$" ) ) { r = readReaction ( setOfReactions . getBuilder ( ) ) ; if ( r != null ) { setOfReactions . addReaction ( r ) ; } } else { if ( r != null ) { String fieldName = null ; if ( line . startsWith ( "> " ) ) { int index = line . indexOf ( '<' ) ; if ( index != - 1 ) { int index2 = line . substring ( index ) . indexOf ( '>' ) ; if ( index2 != - 1 ) { fieldName = line . substring ( index + 1 , index + index2 ) ; } } while ( ( line = input . readLine ( ) ) != null && line . startsWith ( ">" ) ) { logger . debug ( "data header line: " , line ) ; } } if ( line == null ) { throw new CDKException ( "Expecting data line here, but found null!" ) ; } String data = line ; while ( ( line = input . readLine ( ) ) != null && line . trim ( ) . length ( ) > 0 ) { if ( line . equals ( "$$$$" ) ) { logger . error ( "Expecting data line here, but found end of molecule: " , line ) ; break ; } logger . debug ( "data line: " , line ) ; data += line ; if ( line . length ( ) < 80 ) data += "\n" ; } if ( fieldName != null ) { logger . info ( "fieldName, data: " , fieldName , ", " , data ) ; r . setProperty ( fieldName , data ) ; } } } } } catch ( CDKException cdkexc ) { throw cdkexc ; } catch ( IOException exception ) { String error = "Error while parsing SDF" ; logger . error ( error ) ; logger . debug ( exception ) ; throw new CDKException ( error , exception ) ; } return setOfReactions ; }
Read a IReactionSet from a file in MDL RDF format .
28,396
void markRow ( int i , int marking ) { for ( int j = ( i * mCols ) , end = j + mCols ; j < end ; j ++ ) if ( data [ j ] > 0 ) data [ j ] = marking ; }
Mark all values in row i allowing it to be reset later .
28,397
public void setAtom ( IAtom atom , int position ) { if ( atoms [ position ] == null && atom != null ) atomCount ++ ; if ( atoms [ position ] != null && atom == null ) atomCount -- ; atoms [ position ] = atom ; }
Sets an Atom in this bond .
28,398
public void setOrder ( Order order ) { this . order = order ; if ( order != null ) { switch ( order ) { case SINGLE : this . electronCount = 2 ; break ; case DOUBLE : this . electronCount = 4 ; break ; case TRIPLE : this . electronCount = 6 ; break ; case QUADRUPLE : this . electronCount = 8 ; break ; case QUINTUPLE : this . electronCount = 10 ; break ; case SEXTUPLE : this . electronCount = 12 ; break ; default : this . electronCount = 0 ; break ; } } }
Sets the bond order of this bond .
28,399
public static int [ ] [ ] aaBondInfo ( ) { if ( aminoAcids == null ) { createAAs ( ) ; } int [ ] [ ] info = new int [ 153 ] [ 4 ] ; int counter = 0 ; int total = 0 ; for ( int aa = 0 ; aa < aminoAcids . length ; aa ++ ) { AminoAcid acid = aminoAcids [ aa ] ; LOGGER . debug ( "#bonds for " , acid . getProperty ( RESIDUE_NAME ) . toString ( ) , " = " + acid . getBondCount ( ) ) ; total += acid . getBondCount ( ) ; LOGGER . debug ( "total #bonds: " , total ) ; Iterator < IBond > bonds = acid . bonds ( ) . iterator ( ) ; while ( bonds . hasNext ( ) ) { IBond bond = ( IBond ) bonds . next ( ) ; info [ counter ] [ 0 ] = counter ; info [ counter ] [ 1 ] = acid . indexOf ( bond . getBegin ( ) ) ; info [ counter ] [ 2 ] = acid . indexOf ( bond . getEnd ( ) ) ; info [ counter ] [ 3 ] = bond . getOrder ( ) . numeric ( ) ; counter ++ ; } } if ( counter > 153 ) { LOGGER . error ( "Error while creating AA info! Bond count is too large: " , counter ) ; return null ; } return info ; }
Creates matrix with info about the bonds in the amino acids . 0 = bond id 1 = atom1 in bond 2 = atom2 in bond 3 = bond order .