idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
28,000
protected void setupTransformNatural ( Rectangle2D modelBounds ) { double zoom = rendererModel . getParameter ( ZoomFactor . class ) . getValue ( ) ; this . fontManager . setFontForZoom ( zoom ) ; this . setup ( ) ; }
Set the transform for a non - fit to screen paint .
28,001
protected Rectangle convertToDiagramBounds ( Rectangle2D modelBounds ) { double xCenter = modelBounds . getCenterX ( ) ; double yCenter = modelBounds . getCenterY ( ) ; double modelWidth = modelBounds . getWidth ( ) ; double modelHeight = modelBounds . getHeight ( ) ; double scale = rendererModel . getParameter ( Scale . class ) . getValue ( ) ; double zoom = rendererModel . getParameter ( ZoomFactor . class ) . getValue ( ) ; Point2d screenCoord = this . toScreenCoordinates ( xCenter , yCenter ) ; if ( modelWidth == 0 && modelHeight == 0 ) { return new Rectangle ( ( int ) screenCoord . x , ( int ) screenCoord . y , 0 , 0 ) ; } double margin = rendererModel . getParameter ( Margin . class ) . getValue ( ) ; int width = ( int ) ( ( scale * zoom * modelWidth ) + ( 2 * margin ) ) ; int height = ( int ) ( ( scale * zoom * modelHeight ) + ( 2 * margin ) ) ; int xCoord = ( int ) ( screenCoord . x - width / 2 ) ; int yCoord = ( int ) ( screenCoord . y - height / 2 ) ; return new Rectangle ( xCoord , yCoord , width , height ) ; }
Calculate the bounds of the diagram on screen given the current scale zoom and margin .
28,002
void setupTransformToFit ( Rectangle2D screenBounds , Rectangle2D modelBounds , boolean reset ) { double scale = rendererModel . getParameter ( Scale . class ) . getValue ( ) ; if ( screenBounds == null ) return ; setDrawCenter ( screenBounds . getCenterX ( ) , screenBounds . getCenterY ( ) ) ; double drawWidth = screenBounds . getWidth ( ) ; double drawHeight = screenBounds . getHeight ( ) ; double diagramWidth = modelBounds . getWidth ( ) * scale ; double diagramHeight = modelBounds . getHeight ( ) * scale ; setZoomToFit ( drawWidth , drawHeight , diagramWidth , diagramHeight ) ; if ( reset || rendererModel . getParameter ( FitToScreen . class ) . getValue ( ) ) { setModelCenter ( modelBounds . getCenterX ( ) , modelBounds . getCenterY ( ) ) ; } setup ( ) ; }
Sets the transformation needed to draw the model on the canvas when the diagram needs to fit the screen .
28,003
public void setParameters ( Object [ ] params ) throws CDKException { if ( params . length != 2 ) throw new CDKException ( "IsotopePatternRule expects two parameter" ) ; if ( ! ( params [ 0 ] instanceof List ) ) throw new CDKException ( "The parameter one must be of type List<Double[]>" ) ; if ( ! ( params [ 1 ] instanceof Double ) ) throw new CDKException ( "The parameter two must be of type Double" ) ; pattern = new IsotopePattern ( ) ; for ( double [ ] listISO : ( List < double [ ] > ) params [ 0 ] ) { pattern . addIsotope ( new IsotopeContainer ( listISO [ 0 ] , listISO [ 1 ] ) ) ; } is . seTolerance ( ( Double ) params [ 1 ] ) ; }
Sets the parameters attribute of the IsotopePatternRule object .
28,004
public Object [ ] getParameters ( ) { Object [ ] params = new Object [ 2 ] ; if ( pattern == null ) params [ 0 ] = null ; else { List < double [ ] > params0 = new ArrayList < double [ ] > ( ) ; for ( IsotopeContainer isotope : pattern . getIsotopes ( ) ) { params0 . add ( new double [ ] { isotope . getMass ( ) , isotope . getIntensity ( ) } ) ; } params [ 0 ] = params0 ; } params [ 1 ] = toleranceMass ; return params ; }
Gets the parameters attribute of the IsotopePatternRule object .
28,005
private IAtom getAnotherUnsaturatedNode ( IAtom exclusionAtom , IAtomContainer exclusionAtomContainer , IAtomContainerSet atomContainers ) throws CDKException { IAtom atom ; for ( IAtomContainer ac : atomContainers . atomContainers ( ) ) { if ( ac != exclusionAtomContainer ) { int next = 0 ; for ( int f = next ; f < ac . getAtomCount ( ) ; f ++ ) { atom = ac . getAtom ( f ) ; if ( ! satCheck . isSaturated ( atom , ac ) && exclusionAtom != atom ) { return atom ; } } } } int next = exclusionAtomContainer . getAtomCount ( ) ; for ( int f = 0 ; f < next ; f ++ ) { atom = exclusionAtomContainer . getAtom ( f ) ; if ( ! satCheck . isSaturated ( atom , exclusionAtomContainer ) && exclusionAtom != atom && ! exclusionAtomContainer . getConnectedAtomsList ( exclusionAtom ) . contains ( atom ) ) { return atom ; } } return null ; }
Gets a randomly selected unsaturated atom from the set . If there are any it will be from another container than exclusionAtom .
28,006
public void setup ( IAtomContainer atomContainer , Rectangle screen ) { this . setScale ( atomContainer ) ; Rectangle2D bounds = BoundsCalculator . calculateBounds ( atomContainer ) ; this . modelCenter = new Point2d ( bounds . getCenterX ( ) , bounds . getCenterY ( ) ) ; this . drawCenter = new Point2d ( screen . getCenterX ( ) , screen . getCenterY ( ) ) ; this . setup ( ) ; }
Setup the transformations necessary to draw this Atom Container .
28,007
public void reset ( ) { modelCenter = new Point2d ( 0 , 0 ) ; drawCenter = new Point2d ( 200 , 200 ) ; rendererModel . getParameter ( ZoomFactor . class ) . setValue ( 1.0 ) ; setup ( ) ; }
Reset the draw center and model center and set the zoom to 100% .
28,008
public void setScale ( IAtomContainer atomContainer ) { double bondLength = GeometryUtil . getBondLengthAverage ( atomContainer ) ; rendererModel . getParameter ( Scale . class ) . setValue ( this . calculateScaleForBondLength ( bondLength ) ) ; }
Set the scale for an IAtomContainer . It calculates the average bond length of the model and calculates the multiplication factor to transform this to the bond length that is set in the RendererModel .
28,009
private static double estimatedBondLength ( IAtomContainer container ) { if ( container . getBondCount ( ) > 0 ) throw new IllegalArgumentException ( "structure has at least one bond - disconnected scaling not need" ) ; if ( container . getAtomCount ( ) < 2 ) throw new IllegalArgumentException ( "structure must have at least two atoms" ) ; int nAtoms = container . getAtomCount ( ) ; double minDistance = Integer . MAX_VALUE ; for ( int i = 0 ; i < nAtoms ; i ++ ) for ( int j = i + 1 ; j < nAtoms ; j ++ ) minDistance = min ( container . getAtom ( i ) . getPoint2d ( ) . distance ( container . getAtom ( j ) . getPoint2d ( ) ) , minDistance ) ; return minDistance / 1.5 ; }
Determine an estimated bond length for disconnected structures . The distance between all atoms is measured and then the minimum distance is divided by 1 . 5 . This length is required for scaling renderings .
28,010
public void addResidue ( Residue residue ) { if ( residues == null ) residues = new ArrayList < Residue > ( ) ; if ( residues . contains ( residue ) ) { System . out . println ( "Residue: " + residue . getName ( ) + " already present in molecule: " + getID ( ) ) ; return ; } residues . add ( residue ) ; }
Add a Residue to the MDMolecule if not already present .
28,011
public void addChargeGroup ( ChargeGroup chargeGroup ) { if ( chargeGroups == null ) chargeGroups = new ArrayList < ChargeGroup > ( ) ; if ( chargeGroups . contains ( chargeGroup ) ) { System . out . println ( "Charge group: " + chargeGroup . getNumber ( ) + " already present in molecule: " + getID ( ) ) ; return ; } chargeGroups . add ( chargeGroup ) ; }
Add a ChargeGroup to the MDMolecule if not already present .
28,012
public void setOutputWriter ( Writer writer ) { if ( writer instanceof PrintWriter ) { this . out = ( PrintWriter ) writer ; } else if ( writer == null ) { this . out = null ; } else { this . out = new PrintWriter ( writer ) ; } }
Overwrites the default writer to which the output is directed .
28,013
public boolean allSaturated ( IAtomContainer ac ) throws CDKException { logger . debug ( "Are all atoms saturated?" ) ; for ( int f = 0 ; f < ac . getAtomCount ( ) ; f ++ ) { if ( ! isSaturated ( ac . getAtom ( f ) , ac ) ) return false ; } return true ; }
Determines of all atoms on the AtomContainer have the right number the lone pair electrons .
28,014
public boolean isSaturated ( IAtom atom , IAtomContainer ac ) throws CDKException { createAtomTypeFactory ( ac . getBuilder ( ) ) ; IAtomType atomType = factory . getAtomType ( atom . getAtomTypeName ( ) ) ; int lpCount = ( Integer ) atomType . getProperty ( CDKConstants . LONE_PAIR_COUNT ) ; int foundLPCount = ac . getConnectedLonePairsCount ( atom ) ; return foundLPCount >= lpCount ; }
Checks if an Atom is saturated their lone pair electrons by comparing it with known AtomTypes .
28,015
public void saturate ( IAtomContainer atomContainer ) throws CDKException { logger . info ( "Saturating atomContainer by adjusting lone pair electrons..." ) ; boolean allSaturated = allSaturated ( atomContainer ) ; if ( ! allSaturated ) { for ( int i = 0 ; i < atomContainer . getAtomCount ( ) ; i ++ ) { saturate ( atomContainer . getAtom ( i ) , atomContainer ) ; } } }
Saturates a molecule by setting appropriate number lone pair electrons .
28,016
public void saturate ( IAtom atom , IAtomContainer ac ) throws CDKException { logger . info ( "Saturating atom by adjusting lone pair electrons..." ) ; IAtomType atomType = factory . getAtomType ( atom . getAtomTypeName ( ) ) ; int lpCount = ( Integer ) atomType . getProperty ( CDKConstants . LONE_PAIR_COUNT ) ; int missingLPs = lpCount - ac . getConnectedLonePairsCount ( atom ) ; for ( int j = 0 ; j < missingLPs ; j ++ ) { ILonePair lp = atom . getBuilder ( ) . newInstance ( ILonePair . class , atom ) ; ac . addLonePair ( lp ) ; } }
Saturates an IAtom by adding the appropriate number lone pairs .
28,017
public double calculatePositive ( IAtomContainer atomContainer , IAtom atom ) { if ( atom . getFormalCharge ( ) != 1 ) { return 0.0 ; } StructureResonanceGenerator gRI = new StructureResonanceGenerator ( ) ; List < IReactionProcess > reactionList = gRI . getReactions ( ) ; reactionList . add ( new HyperconjugationReaction ( ) ) ; gRI . setReactions ( reactionList ) ; IAtomContainerSet resonanceS = gRI . getStructures ( atomContainer ) ; IAtomContainerSet containerS = gRI . getContainers ( atomContainer ) ; if ( resonanceS . getAtomContainerCount ( ) < 2 ) return 0.0 ; final int positionStart = atomContainer . indexOf ( atom ) ; List < Double > result1 = new ArrayList < Double > ( ) ; List < Integer > distance1 = new ArrayList < Integer > ( ) ; resonanceS . removeAtomContainer ( 0 ) ; for ( Iterator < IAtomContainer > itA = resonanceS . atomContainers ( ) . iterator ( ) ; itA . hasNext ( ) ; ) { final IAtomContainer resonance = itA . next ( ) ; if ( resonance . getAtomCount ( ) < 2 ) continue ; final ShortestPaths shortestPaths = new ShortestPaths ( resonance , resonance . getAtom ( positionStart ) ) ; PiElectronegativity electronegativity = new PiElectronegativity ( ) ; for ( Iterator < IAtom > itAtoms = resonance . atoms ( ) . iterator ( ) ; itAtoms . hasNext ( ) ; ) { IAtom atomP = itAtoms . next ( ) ; IAtom atomR = atomContainer . getAtom ( resonance . indexOf ( atomP ) ) ; if ( containerS . getAtomContainer ( 0 ) . contains ( atomR ) ) { electronegativity . setMaxIterations ( 6 ) ; double result = electronegativity . calculatePiElectronegativity ( resonance , atomP ) ; result1 . add ( result ) ; int dis = shortestPaths . distanceTo ( atomP ) ; distance1 . add ( dis ) ; } } } double value = 0.0 ; double sum = 0.0 ; Iterator < Integer > itDist = distance1 . iterator ( ) ; for ( Iterator < Double > itElec = result1 . iterator ( ) ; itElec . hasNext ( ) ; ) { double suM = itElec . next ( ) ; if ( suM < 0 ) suM = - 1 * suM ; sum += suM * Math . pow ( 0.67 , itDist . next ( ) . intValue ( ) ) ; } value = sum ; return value ; }
calculate the stabilization of orbitals when they contain deficiency of charge .
28,018
public DescriptorValue calculate ( IAtomContainer container ) { int atomCount = 0 ; if ( container == null ) { return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new IntegerResult ( ( int ) Double . NaN ) , getDescriptorNames ( ) , new CDKException ( "The supplied AtomContainer was NULL" ) ) ; } if ( container . getAtomCount ( ) == 0 ) { return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new IntegerResult ( ( int ) Double . NaN ) , getDescriptorNames ( ) , new CDKException ( "The supplied AtomContainer did not have any atoms" ) ) ; } if ( elementName . equals ( "*" ) ) { for ( int i = 0 ; i < container . getAtomCount ( ) ; i ++ ) { Integer hcount = container . getAtom ( i ) . getImplicitHydrogenCount ( ) ; if ( hcount != CDKConstants . UNSET ) atomCount += hcount ; } atomCount += container . getAtomCount ( ) ; } else if ( elementName . equals ( "H" ) ) { for ( int i = 0 ; i < container . getAtomCount ( ) ; i ++ ) { if ( container . getAtom ( i ) . getSymbol ( ) . equals ( elementName ) ) { atomCount += 1 ; } else { Integer hcount = container . getAtom ( i ) . getImplicitHydrogenCount ( ) ; if ( hcount != CDKConstants . UNSET ) atomCount += hcount ; } } } else { for ( int i = 0 ; i < container . getAtomCount ( ) ; i ++ ) { if ( container . getAtom ( i ) . getSymbol ( ) . equals ( elementName ) ) { atomCount += 1 ; } } } return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new IntegerResult ( atomCount ) , getDescriptorNames ( ) ) ; }
this could be useful for other descriptors like polar surface area ...
28,019
private void createCode ( ) throws CDKException { List < TreeNode > sphereNodes = null ; TreeNode tn = null ; for ( int f = 0 ; f < atomContainer . getAtomCount ( ) ; f ++ ) { atomContainer . getAtom ( f ) . setFlag ( CDKConstants . VISITED , false ) ; } for ( int f = 0 ; f < maxSphere ; f ++ ) { sphereNodes = spheres [ maxSphere - f ] ; for ( int g = 0 ; g < sphereNodes . size ( ) ; g ++ ) { tn = sphereNodes . get ( g ) ; if ( tn . source != null ) { tn . source . ranking += tn . degree ; } } } for ( int f = 0 ; f < maxSphere ; f ++ ) { sphereNodes = spheres [ f ] ; calculateNodeScores ( sphereNodes ) ; sortNodesByScore ( sphereNodes ) ; } for ( int f = 0 ; f < maxSphere ; f ++ ) { sphereNodes = spheres [ f ] ; for ( int g = 0 ; g < sphereNodes . size ( ) ; g ++ ) { tn = ( TreeNode ) sphereNodes . get ( g ) ; tn . score += tn . ranking ; } sortNodesByScore ( sphereNodes ) ; } for ( int f = 0 ; f < maxSphere ; f ++ ) { sphereNodes = spheres [ f ] ; for ( int g = 0 ; g < sphereNodes . size ( ) ; g ++ ) { tn = ( TreeNode ) sphereNodes . get ( g ) ; String localscore = tn . score + "" ; while ( localscore . length ( ) < 6 ) { localscore = "0" + localscore ; } tn . stringscore = tn . source . stringscore + "" + localscore ; } sortNodesByScore ( sphereNodes ) ; } HOSECode . append ( centerCode ) ; for ( int f = 0 ; f < maxSphere ; f ++ ) { sphere = f + 1 ; sphereNodes = spheres [ f ] ; String s = getSphereCode ( sphereNodes ) ; HOSECode . append ( s ) ; } }
After recursively having established the spheres and assigning each node an appropriate score we now generate the complete HOSE code .
28,020
private String getSphereCode ( List < TreeNode > sphereNodes ) throws CDKException { if ( sphereNodes == null || sphereNodes . size ( ) < 1 ) { return sphereDelimiters [ sphere - 1 ] ; } TreeNode treeNode = null ; StringBuffer code = new StringBuffer ( ) ; IAtom branch = sphereNodes . get ( 0 ) . source . atom ; StringBuffer tempCode = null ; for ( int i = 0 ; i < sphereNodes . size ( ) ; i ++ ) { treeNode = sphereNodes . get ( i ) ; tempCode = new StringBuffer ( ) ; if ( ! treeNode . source . stopper && ! treeNode . source . atom . equals ( branch ) ) { branch = treeNode . source . atom ; code . append ( ',' ) ; } if ( ! treeNode . source . stopper && treeNode . source . atom . equals ( branch ) ) { if ( treeNode . bondType <= 4 ) { tempCode . append ( bondSymbols [ ( int ) treeNode . bondType ] ) ; } else { throw new CDKException ( "Unknown bond type" ) ; } if ( treeNode . atom != null && ! treeNode . atom . getFlag ( CDKConstants . VISITED ) ) { tempCode . append ( getElementSymbol ( treeNode . symbol ) ) ; } else if ( treeNode . atom != null && treeNode . atom . getFlag ( CDKConstants . VISITED ) ) { tempCode . append ( '&' ) ; treeNode . stopper = true ; } code . append ( tempCode + createChargeCode ( treeNode . atom ) ) ; treeNode . hSymbol = tempCode . toString ( ) ; } if ( treeNode . atom != null ) treeNode . atom . setFlag ( CDKConstants . VISITED , true ) ; if ( treeNode . source . stopper ) treeNode . stopper = true ; } code . append ( sphereDelimiters [ sphere - 1 ] ) ; return code . toString ( ) ; }
Generates the string code for a given sphere .
28,021
private double getElementRank ( String symbol ) { for ( int f = 0 ; f < rankedSymbols . length ; f ++ ) { if ( rankedSymbols [ f ] . equals ( symbol ) ) { return symbolRankings [ f ] ; } } IIsotope isotope = isotopeFac . getMajorIsotope ( symbol ) ; if ( isotope . getMassNumber ( ) != null ) { return ( ( double ) 800000 - isotope . getMassNumber ( ) ) ; } return 800000 ; }
Gets the element rank for a given element symbol as given in Bremser s publication .
28,022
private void calculateNodeScores ( List < TreeNode > sphereNodes ) throws CDKException { TreeNode treeNode = null ; for ( int i = 0 ; i < sphereNodes . size ( ) ; i ++ ) { treeNode = ( TreeNode ) sphereNodes . get ( i ) ; treeNode . score += getElementRank ( treeNode . symbol ) ; if ( treeNode . bondType <= 4 ) { treeNode . score += bondRankings [ ( int ) treeNode . bondType ] ; } else { throw new CDKException ( "Unknown bond type encountered in HOSECodeGenerator" ) ; } } }
Determines the ranking score for each node allowing for a sorting of nodes within one sphere .
28,023
private void fillUpSphereDelimiters ( ) { logger . debug ( "Sphere: " + sphere ) ; for ( int f = sphere ; f < 4 ; f ++ ) { HOSECode . append ( sphereDelimiters [ f ] ) ; } }
If we use less than four sphere this fills up the code with the missing delimiters such that we are compatible with Bremser s HOSE code table .
28,024
public double getBondLength ( ) { double epsilon = 1e-3 ; PharmacophoreAtom atom1 = ( PharmacophoreAtom ) getAtom ( 0 ) ; PharmacophoreAtom atom2 = ( PharmacophoreAtom ) getAtom ( 1 ) ; PharmacophoreAtom atom3 = ( PharmacophoreAtom ) getAtom ( 2 ) ; double a2 = atom3 . getPoint3d ( ) . distanceSquared ( atom1 . getPoint3d ( ) ) ; double b2 = atom3 . getPoint3d ( ) . distanceSquared ( atom2 . getPoint3d ( ) ) ; double c2 = atom2 . getPoint3d ( ) . distanceSquared ( atom1 . getPoint3d ( ) ) ; double cosangle = ( b2 + c2 - a2 ) / ( 2 * Math . sqrt ( b2 ) * Math . sqrt ( c2 ) ) ; if ( - 1.0 - epsilon < cosangle && - 1.0 + epsilon > cosangle ) return 180.0 ; if ( 1.0 - epsilon < cosangle && 1.0 + epsilon > cosangle ) return 0.0 ; return Math . acos ( cosangle ) * 180.0 / Math . PI ; }
Get the angle between the three pharmacophore groups that make up the constraint .
28,025
public static int getAtomCount ( IChemModel chemModel ) { int count = 0 ; ICrystal crystal = chemModel . getCrystal ( ) ; if ( crystal != null ) { count += crystal . getAtomCount ( ) ; } IAtomContainerSet moleculeSet = chemModel . getMoleculeSet ( ) ; if ( moleculeSet != null ) { count += MoleculeSetManipulator . getAtomCount ( moleculeSet ) ; } IReactionSet reactionSet = chemModel . getReactionSet ( ) ; if ( reactionSet != null ) { count += ReactionSetManipulator . getAtomCount ( reactionSet ) ; } return count ; }
Get the total number of atoms inside an IChemModel .
28,026
public static void removeAtomAndConnectedElectronContainers ( IChemModel chemModel , IAtom atom ) { ICrystal crystal = chemModel . getCrystal ( ) ; if ( crystal != null ) { if ( crystal . contains ( atom ) ) { crystal . removeAtom ( atom ) ; } return ; } IAtomContainerSet moleculeSet = chemModel . getMoleculeSet ( ) ; if ( moleculeSet != null ) { MoleculeSetManipulator . removeAtomAndConnectedElectronContainers ( moleculeSet , atom ) ; } IReactionSet reactionSet = chemModel . getReactionSet ( ) ; if ( reactionSet != null ) { ReactionSetManipulator . removeAtomAndConnectedElectronContainers ( reactionSet , atom ) ; } }
Remove an Atom and the connected ElectronContainers from all AtomContainers inside an IChemModel .
28,027
public static void removeElectronContainer ( IChemModel chemModel , IElectronContainer electrons ) { ICrystal crystal = chemModel . getCrystal ( ) ; if ( crystal != null ) { if ( crystal . contains ( electrons ) ) { crystal . removeElectronContainer ( electrons ) ; } return ; } IAtomContainerSet moleculeSet = chemModel . getMoleculeSet ( ) ; if ( moleculeSet != null ) { MoleculeSetManipulator . removeElectronContainer ( moleculeSet , electrons ) ; } IReactionSet reactionSet = chemModel . getReactionSet ( ) ; if ( reactionSet != null ) { ReactionSetManipulator . removeElectronContainer ( reactionSet , electrons ) ; } }
Remove an ElectronContainer from all AtomContainers inside an IChemModel .
28,028
public static IAtomContainer createNewMolecule ( IChemModel chemModel ) { IAtomContainer molecule = chemModel . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; if ( chemModel . getMoleculeSet ( ) != null ) { IAtomContainerSet moleculeSet = chemModel . getMoleculeSet ( ) ; for ( int i = 0 ; i < moleculeSet . getAtomContainerCount ( ) ; i ++ ) { if ( moleculeSet . getAtomContainer ( i ) . getAtomCount ( ) == 0 ) { moleculeSet . removeAtomContainer ( i ) ; i -- ; } } moleculeSet . addAtomContainer ( molecule ) ; } else { IAtomContainerSet moleculeSet = chemModel . getBuilder ( ) . newInstance ( IAtomContainerSet . class ) ; moleculeSet . addAtomContainer ( molecule ) ; chemModel . setMoleculeSet ( moleculeSet ) ; } return molecule ; }
Adds a new Molecule to the MoleculeSet inside a given ChemModel . Creates a MoleculeSet if none is contained .
28,029
public static IAtomContainer getRelevantAtomContainer ( IChemModel chemModel , IAtom atom ) { IAtomContainer result = null ; if ( chemModel . getMoleculeSet ( ) != null ) { IAtomContainerSet moleculeSet = chemModel . getMoleculeSet ( ) ; result = MoleculeSetManipulator . getRelevantAtomContainer ( moleculeSet , atom ) ; if ( result != null ) { return result ; } } if ( chemModel . getReactionSet ( ) != null ) { IReactionSet reactionSet = chemModel . getReactionSet ( ) ; return ReactionSetManipulator . getRelevantAtomContainer ( reactionSet , atom ) ; } if ( chemModel . getCrystal ( ) != null && chemModel . getCrystal ( ) . contains ( atom ) ) { return chemModel . getCrystal ( ) ; } if ( chemModel . getRingSet ( ) != null ) { return AtomContainerSetManipulator . getRelevantAtomContainer ( chemModel . getRingSet ( ) , atom ) ; } throw new IllegalArgumentException ( "The provided atom is not part of this IChemModel." ) ; }
This badly named methods tries to determine which AtomContainer in the ChemModel is best suited to contain added Atom s and Bond s .
28,030
public static IAtomContainer getRelevantAtomContainer ( IChemModel chemModel , IBond bond ) { IAtomContainer result = null ; if ( chemModel . getMoleculeSet ( ) != null ) { IAtomContainerSet moleculeSet = chemModel . getMoleculeSet ( ) ; result = MoleculeSetManipulator . getRelevantAtomContainer ( moleculeSet , bond ) ; if ( result != null ) { return result ; } } if ( chemModel . getReactionSet ( ) != null ) { IReactionSet reactionSet = chemModel . getReactionSet ( ) ; return ReactionSetManipulator . getRelevantAtomContainer ( reactionSet , bond ) ; } return null ; }
Retrieves the first IAtomContainer containing a given IBond from an IChemModel .
28,031
public static IReaction getRelevantReaction ( IChemModel chemModel , IAtom atom ) { IReaction reaction = null ; if ( chemModel . getReactionSet ( ) != null ) { IReactionSet reactionSet = chemModel . getReactionSet ( ) ; reaction = ReactionSetManipulator . getRelevantReaction ( reactionSet , atom ) ; } return reaction ; }
Retrieves the first IReaction containing a given IAtom from an IChemModel .
28,032
public static List < IAtomContainer > getAllAtomContainers ( IChemModel chemModel ) { IAtomContainerSet moleculeSet = chemModel . getBuilder ( ) . newInstance ( IAtomContainerSet . class ) ; if ( chemModel . getMoleculeSet ( ) != null ) { moleculeSet . add ( chemModel . getMoleculeSet ( ) ) ; } if ( chemModel . getReactionSet ( ) != null ) { moleculeSet . add ( ReactionSetManipulator . getAllMolecules ( chemModel . getReactionSet ( ) ) ) ; } return MoleculeSetManipulator . getAllAtomContainers ( moleculeSet ) ; }
Returns all the AtomContainer s of a ChemModel .
28,033
public static void setAtomProperties ( IChemModel chemModel , Object propKey , Object propVal ) { if ( chemModel . getMoleculeSet ( ) != null ) { MoleculeSetManipulator . setAtomProperties ( chemModel . getMoleculeSet ( ) , propKey , propVal ) ; } if ( chemModel . getReactionSet ( ) != null ) { ReactionSetManipulator . setAtomProperties ( chemModel . getReactionSet ( ) , propKey , propVal ) ; } if ( chemModel . getCrystal ( ) != null ) { AtomContainerManipulator . setAtomProperties ( chemModel . getCrystal ( ) , propKey , propVal ) ; } }
Sets the AtomProperties of all Atoms inside an IChemModel .
28,034
public static List < IChemObject > getAllChemObjects ( IChemModel chemModel ) { List < IChemObject > list = new ArrayList < IChemObject > ( ) ; ICrystal crystal = chemModel . getCrystal ( ) ; if ( crystal != null ) { list . add ( crystal ) ; } IAtomContainerSet moleculeSet = chemModel . getMoleculeSet ( ) ; if ( moleculeSet != null ) { list . add ( moleculeSet ) ; List < IChemObject > current = MoleculeSetManipulator . getAllChemObjects ( moleculeSet ) ; for ( IChemObject chemObject : current ) { if ( ! list . contains ( chemObject ) ) list . add ( chemObject ) ; } } IReactionSet reactionSet = chemModel . getReactionSet ( ) ; if ( reactionSet != null ) { list . add ( reactionSet ) ; List < IChemObject > current = ReactionSetManipulator . getAllChemObjects ( reactionSet ) ; for ( IChemObject chemObject : current ) { if ( ! list . contains ( chemObject ) ) list . add ( chemObject ) ; } } return list ; }
Retrieve a List of all ChemObject objects within an IChemModel .
28,035
public static double calculateAverageBondLength ( IReaction reaction ) { IAtomContainerSet reactants = reaction . getReactants ( ) ; double reactantAverage = 0.0 ; if ( reactants != null ) { reactantAverage = calculateAverageBondLength ( reactants ) / reactants . getAtomContainerCount ( ) ; } IAtomContainerSet products = reaction . getProducts ( ) ; double productAverage = 0.0 ; if ( products != null ) { productAverage = calculateAverageBondLength ( products ) / products . getAtomContainerCount ( ) ; } if ( productAverage == 0.0 && reactantAverage == 0.0 ) { return 1.0 ; } else { return ( productAverage + reactantAverage ) / 2.0 ; } }
Calculate the average bond length for the bonds in a reaction .
28,036
public static double calculateAverageBondLength ( IAtomContainerSet moleculeSet ) { double averageBondModelLength = 0.0 ; for ( IAtomContainer atomContainer : moleculeSet . atomContainers ( ) ) { averageBondModelLength += GeometryUtil . getBondLengthAverage ( atomContainer ) ; } return averageBondModelLength / moleculeSet . getAtomContainerCount ( ) ; }
Calculate the average bond length for the bonds in a molecule set .
28,037
public static double calculateAverageBondLength ( IChemModel model ) { IAtomContainerSet moleculeSet = model . getMoleculeSet ( ) ; if ( moleculeSet == null ) { IReactionSet reactionSet = model . getReactionSet ( ) ; if ( reactionSet != null ) { return calculateAverageBondLength ( reactionSet ) ; } return 0.0 ; } return calculateAverageBondLength ( moleculeSet ) ; }
Calculate the average bond length for the bonds in a chem model .
28,038
public static double calculateAverageBondLength ( IReactionSet reactionSet ) { double averageBondModelLength = 0.0 ; for ( IReaction reaction : reactionSet . reactions ( ) ) { averageBondModelLength += calculateAverageBondLength ( reaction ) ; } return averageBondModelLength / reactionSet . getReactionCount ( ) ; }
Calculate the average bond length for the bonds in a reaction set .
28,039
public Color getAtomColor ( IAtom atom , Color defaultColor ) { Color color = defaultColor ; String symbol = atom . getSymbol ( ) . toUpperCase ( ) ; if ( atom . getAtomicNumber ( ) != null && ATOM_COLORS_MASSNUM . containsKey ( atom . getAtomicNumber ( ) ) ) { color = ATOM_COLORS_MASSNUM . get ( atom . getAtomicNumber ( ) ) ; } else if ( ATOM_COLORS_SYMBOL . containsKey ( symbol ) ) { color = ATOM_COLORS_SYMBOL . get ( symbol ) ; } return new Color ( color . getRed ( ) , color . getGreen ( ) , color . getBlue ( ) ) ; }
Returns the font color for atom given atom .
28,040
public final String toSvgStr ( String units ) { if ( ! units . equals ( UNITS_MM ) && ! units . equals ( UNITS_PX ) ) throw new IllegalArgumentException ( "Units must be 'px' or 'mm'!" ) ; return toVecStr ( SVG_FMT , units ) ; }
Render the image to an SVG image .
28,041
double getPaddingValue ( double defaultPadding ) { double padding = model . get ( RendererModel . Padding . class ) ; if ( padding == AUTOMATIC ) padding = defaultPadding ; return padding ; }
Access the specified padding value or fallback to a provided default .
28,042
double getMarginValue ( final double defaultMargin ) { double margin = model . get ( BasicSceneGenerator . Margin . class ) ; if ( margin == AUTOMATIC ) margin = defaultMargin ; return margin ; }
Access the specified margin value or fallback to a provided default .
28,043
public final List < String > listFormats ( ) { final List < String > formats = new ArrayList < > ( ) ; formats . add ( SVG_FMT ) ; formats . add ( SVG_FMT . toUpperCase ( Locale . ROOT ) ) ; formats . add ( PS_FMT ) ; formats . add ( PS_FMT . toUpperCase ( Locale . ROOT ) ) ; formats . add ( EPS_FMT ) ; formats . add ( EPS_FMT . toUpperCase ( Locale . ROOT ) ) ; formats . add ( PDF_FMT ) ; formats . add ( PDF_FMT . toUpperCase ( Locale . ROOT ) ) ; formats . addAll ( Arrays . asList ( ImageIO . getWriterFormatNames ( ) ) ) ; return formats ; }
List the available formats that can be rendered .
28,044
public final void writeTo ( String fmt , String path ) throws IOException { writeTo ( fmt , new File ( replaceTildeWithHomeDir ( ensureSuffix ( path , fmt ) ) ) ) ; }
Write the depiction to the provided file path .
28,045
public final void writeTo ( String path ) throws IOException { final int i = path . lastIndexOf ( DOT ) ; if ( i < 0 || i + 1 == path . length ( ) ) throw new IOException ( "Cannot find suffix in provided path: " + path ) ; final String fmt = path . substring ( i + 1 ) ; writeTo ( fmt , path ) ; }
Write the depiction to the provided file path the format is determined by the path suffix .
28,046
private static String replaceTildeWithHomeDir ( String path ) { if ( path . startsWith ( "~/" ) ) return System . getProperty ( "user.home" ) + path . substring ( 1 ) ; return path ; }
Utility for resolving paths on unix systems that contain tilda for the home directory .
28,047
protected final void draw ( IDrawVisitor visitor , double zoom , Bounds bounds , Rectangle2D viewBounds ) { double modelScale = zoom * model . get ( BasicSceneGenerator . Scale . class ) ; double zoomToFit = Math . min ( viewBounds . getWidth ( ) / ( bounds . width ( ) * modelScale ) , viewBounds . getHeight ( ) / ( bounds . height ( ) * modelScale ) ) ; AffineTransform transform = new AffineTransform ( ) ; transform . translate ( viewBounds . getCenterX ( ) , viewBounds . getCenterY ( ) ) ; transform . scale ( modelScale , - modelScale ) ; if ( model . get ( BasicSceneGenerator . FitToScreen . class ) || zoomToFit < 1 ) transform . scale ( zoomToFit , zoomToFit ) ; transform . translate ( - ( bounds . minX + bounds . maxX ) / 2 , - ( bounds . minY + bounds . maxY ) / 2 ) ; AWTFontManager fontManager = new AWTFontManager ( ) ; fontManager . setFontForZoom ( zoomToFit ) ; visitor . setRendererModel ( model ) ; visitor . setFontManager ( fontManager ) ; visitor . setTransform ( transform ) ; visitor . visit ( bounds . root ( ) ) ; }
Low - level draw method used by other rendering methods .
28,048
public List < IAtomType > readAtomTypes ( IChemObjectBuilder builder ) throws IOException { List < IAtomType > atomTypes ; if ( ins == null ) { try { ins = this . getClass ( ) . getClassLoader ( ) . getResourceAsStream ( configFile ) ; } catch ( Exception exc ) { logger . error ( exc . getMessage ( ) ) ; logger . debug ( exc ) ; throw new IOException ( "There was a problem getting a stream for " + configFile + " with getClass.getClassLoader.getResourceAsStream" ) ; } if ( ins == null ) { try { ins = this . getClass ( ) . getResourceAsStream ( configFile ) ; } catch ( Exception exc ) { logger . error ( exc . getMessage ( ) ) ; logger . debug ( exc ) ; throw new IOException ( "There was a problem getting a stream for " + configFile + " with getClass.getResourceAsStream" ) ; } } } if ( ins == null ) throw new IOException ( "There was a problem getting an input stream" ) ; AtomTypeReader reader = new AtomTypeReader ( new InputStreamReader ( ins ) ) ; atomTypes = reader . readAtomTypes ( builder ) ; for ( IAtomType atomType : atomTypes ) { if ( atomType == null ) { logger . debug ( "Expecting an object but found null!" ) ; } } return atomTypes ; }
Reads the atom types from the CDK based atom type list .
28,049
public void add ( IRenderingElement element ) { if ( element != null ) { if ( element . getClass ( ) . equals ( ElementGroup . class ) ) elements . addAll ( ( ( ElementGroup ) element ) . elements ) ; else elements . add ( element ) ; } }
Add a new element to the group .
28,050
public int getBondOrderSum ( ) { int sum = 0 ; for ( int i = 0 ; i < getBondCount ( ) ; i ++ ) { IBond . Order order = getBond ( i ) . getOrder ( ) ; if ( order != null ) { sum += order . numeric ( ) ; } } return sum ; }
Returns the sum of all bond orders in the ring .
28,051
public void process ( RootDoc root ) throws IOException { out . println ( "<XMI xmi.version=\"1.1\" >" ) ; out . println ( " <XMI.header>" ) ; out . println ( " <XMI.metamodel href=\"/vol/acfiles7/egonw/SourceForge/CDK/cdk/reports/javadoc/test2.xmi\" version=\"1.1\" name=\"UML\" />" ) ; out . println ( " <XMI.model href=\"/vol/acfiles7/egonw/SourceForge/CDK/cdk/reports/javadoc/test2.xmi\" version=\"1\" name=\"/vol/acfiles7/egonw/SourceForge/CDK/cdk/reports/javadoc/test2.xmi\" />" ) ; out . println ( " </XMI.header>" ) ; out . println ( " <XMI.content>" ) ; out . println ( " <docsettings viewid=\"-1\" documentation=\"\" uniqueid=\"1\" />" ) ; out . println ( " <umlobjects>" ) ; generateUMLClass ( root . specifiedPackages ( ) ) ; out . println ( " </umlobjects>" ) ; out . println ( " <diagrams/>" ) ; out . println ( " <listview>" ) ; out . println ( " <listitem open=\"1\" type=\"800\" id=\"-1\" label=\"Views\" >" ) ; generateLogicalView ( root . specifiedPackages ( ) ) ; out . println ( " <listitem open=\"1\" type=\"802\" id=\"-1\" label=\"Use Case View\" />" ) ; out . println ( " </listitem>" ) ; out . println ( " </listview>" ) ; out . println ( " </XMI.content>" ) ; out . println ( "</XMI>" ) ; }
Method that serializes RootDoc objects containing the information from the Java source code .
28,052
public static boolean start ( RootDoc root ) { try { String filename = "classes.xmi" ; PrintWriter out = new PrintWriter ( ( Writer ) new FileWriter ( filename ) ) ; XMIDoclet doclet = new XMIDoclet ( out ) ; doclet . process ( root ) ; out . flush ( ) ; return true ; } catch ( Exception e ) { System . err . println ( e . toString ( ) ) ; return false ; } }
Method that must be implemented by JavaDoc Doclets .
28,053
public static List < IRingSet > partitionRings ( IRingSet ringSet ) { List < IRingSet > ringSets = new ArrayList < IRingSet > ( ) ; if ( ringSet . getAtomContainerCount ( ) == 0 ) return ringSets ; IRing ring = ( IRing ) ringSet . getAtomContainer ( 0 ) ; if ( ring == null ) return ringSets ; IRingSet rs = ring . getBuilder ( ) . newInstance ( IRingSet . class ) ; for ( int f = 0 ; f < ringSet . getAtomContainerCount ( ) ; f ++ ) { rs . addAtomContainer ( ringSet . getAtomContainer ( f ) ) ; } do { ring = ( IRing ) rs . getAtomContainer ( 0 ) ; IRingSet newRs = ring . getBuilder ( ) . newInstance ( IRingSet . class ) ; newRs . addAtomContainer ( ring ) ; ringSets . add ( walkRingSystem ( rs , ring , newRs ) ) ; } while ( rs . getAtomContainerCount ( ) > 0 ) ; return ringSets ; }
Partitions a RingSet into RingSets of connected rings . Rings which share an Atom a Bond or three or more atoms with at least on other ring in the RingSet are considered connected . Thus molecules such as azulene and indole will return a List with 1 element .
28,054
public static IAtomContainer convertToAtomContainer ( IRingSet ringSet ) { IRing ring = ( IRing ) ringSet . getAtomContainer ( 0 ) ; if ( ring == null ) return null ; IAtomContainer ac = ring . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; for ( int i = 0 ; i < ringSet . getAtomContainerCount ( ) ; i ++ ) { ring = ( IRing ) ringSet . getAtomContainer ( i ) ; for ( int r = 0 ; r < ring . getBondCount ( ) ; r ++ ) { IBond bond = ring . getBond ( r ) ; if ( ! ac . contains ( bond ) ) { for ( int j = 0 ; j < bond . getAtomCount ( ) ; j ++ ) { ac . addAtom ( bond . getAtom ( j ) ) ; } ac . addBond ( bond ) ; } } } return ac ; }
Converts a RingSet to an AtomContainer .
28,055
private static IRingSet walkRingSystem ( IRingSet rs , IRing ring , IRingSet newRs ) { IRing tempRing ; IRingSet tempRings = rs . getConnectedRings ( ring ) ; rs . removeAtomContainer ( ring ) ; for ( IAtomContainer container : tempRings . atomContainers ( ) ) { tempRing = ( IRing ) container ; if ( ! newRs . contains ( tempRing ) ) { newRs . addAtomContainer ( tempRing ) ; newRs . add ( walkRingSystem ( rs , tempRing , newRs ) ) ; } } return newRs ; }
Perform a walk in the given RingSet starting at a given Ring and recursively searching for other Rings connected to this ring . By doing this it finds all rings in the RingSet connected to the start ring putting them in newRs and removing them from rs .
28,056
public DescriptorValue calculate ( IAtom atom , IAtomContainer container ) { double value ; String originalAtomtypeName = atom . getAtomTypeName ( ) ; Integer originalNeighborCount = atom . getFormalNeighbourCount ( ) ; Integer originalValency = atom . getValency ( ) ; Double originalBondOrderSum = atom . getBondOrderSum ( ) ; Order originalMaxBondOrder = atom . getMaxBondOrder ( ) ; IAtomType . Hybridization originalHybridization = atom . getHybridization ( ) ; if ( ! isCachedAtomContainer ( container ) ) { try { AtomContainerManipulator . percieveAtomTypesAndConfigureAtoms ( container ) ; LonePairElectronChecker lpcheck = new LonePairElectronChecker ( ) ; lpcheck . saturate ( container ) ; } catch ( CDKException e ) { return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( Double . NaN ) , NAMES , e ) ; } } value = db . extractIP ( container , atom ) ; atom . setAtomTypeName ( originalAtomtypeName ) ; atom . setFormalNeighbourCount ( originalNeighborCount ) ; atom . setValency ( originalValency ) ; atom . setHybridization ( originalHybridization ) ; atom . setMaxBondOrder ( originalMaxBondOrder ) ; atom . setBondOrderSum ( originalBondOrderSum ) ; return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( value ) , NAMES ) ; }
This method calculates the ionization potential of an atom .
28,057
private boolean familyHalogen ( IAtom atom ) { String symbol = atom . getSymbol ( ) ; return symbol . equals ( "F" ) || symbol . equals ( "Cl" ) || symbol . equals ( "Br" ) || symbol . equals ( "I" ) ; }
Looking if the Atom belongs to the halogen family .
28,058
private static List < String > extractInfo ( String str ) { int beg = 0 ; int end = 0 ; int len = str . length ( ) ; List < String > parts = new ArrayList < > ( ) ; while ( end < len && ! Character . isSpaceChar ( str . charAt ( end ) ) ) end ++ ; parts . add ( str . substring ( beg , end ) ) ; while ( end < len && Character . isSpaceChar ( str . charAt ( end ) ) ) end ++ ; beg = end ; while ( end < len && ! Character . isSpaceChar ( str . charAt ( end ) ) ) end ++ ; parts . add ( str . substring ( beg , end ) ) ; return parts ; }
Extract the information from a line which contains HOSE_ID & energy .
28,059
public Double getExactMass ( ) { double totalMass = 0.0 ; for ( IAtom atom : fragment . atoms ( ) ) { totalMass += atom . getExactMass ( ) ; } return totalMass ; }
The exact mass of an FragmentAtom is defined as the sum of exact masses of the IAtom s in the fragment .
28,060
public String getSymbol ( ) { if ( atomicNumber == null ) return null ; if ( atomicNumber == 0 ) return "R" ; return Elements . ofNumber ( atomicNumber ) . symbol ( ) ; }
Returns the element symbol of this element .
28,061
public boolean compare ( Object object ) { if ( ! ( object instanceof Element ) ) { return false ; } if ( ! super . compare ( object ) ) { return false ; } Element elem = ( Element ) object ; return Objects . equal ( atomicNumber , elem . atomicNumber ) ; }
Compares an Element with this Element .
28,062
protected int compatibilityGraphNodes ( ) throws IOException { compGraphNodes . clear ( ) ; List < IAtom > basicAtomVecA = null ; List < IAtom > basicAtomVecB = null ; IAtomContainer reactant = source ; IAtomContainer product = target ; basicAtomVecA = reduceAtomSet ( reactant ) ; basicAtomVecB = reduceAtomSet ( product ) ; List < List < Integer > > labelListMolA = labelAtoms ( reactant ) ; List < List < Integer > > labelListMolB = labelAtoms ( product ) ; int molANodes = 0 ; int countNodes = 1 ; for ( List < Integer > labelA : labelListMolA ) { int molBNodes = 0 ; for ( List < Integer > labelB : labelListMolB ) { if ( labelA . equals ( labelB ) ) { compGraphNodes . add ( reactant . indexOf ( basicAtomVecA . get ( molANodes ) ) ) ; compGraphNodes . add ( product . indexOf ( basicAtomVecB . get ( molBNodes ) ) ) ; compGraphNodes . add ( countNodes ++ ) ; } molBNodes ++ ; } molANodes ++ ; } return 0 ; }
Generate Compatibility Graph Nodes
28,063
protected int compatibilityGraph ( ) throws IOException { int compGraphNodesListSize = compGraphNodes . size ( ) ; cEdges = new ArrayList < Integer > ( ) ; dEdges = new ArrayList < Integer > ( ) ; for ( int a = 0 ; a < compGraphNodesListSize ; a += 3 ) { int indexA = compGraphNodes . get ( a ) ; int indexAPlus1 = compGraphNodes . get ( a + 1 ) ; for ( int b = a + 3 ; b < compGraphNodesListSize ; b += 3 ) { int indexB = compGraphNodes . get ( b ) ; int indexBPlus1 = compGraphNodes . get ( b + 1 ) ; if ( a != b && indexA != indexB && indexAPlus1 != indexBPlus1 ) { IBond reactantBond = null ; IBond productBond = null ; reactantBond = source . getBond ( source . getAtom ( indexA ) , source . getAtom ( indexB ) ) ; productBond = target . getBond ( target . getAtom ( indexAPlus1 ) , target . getAtom ( indexBPlus1 ) ) ; if ( reactantBond != null && productBond != null ) { addEdges ( reactantBond , productBond , a , b ) ; } } } } cEdgesSize = cEdges . size ( ) ; dEdgesSize = dEdges . size ( ) ; return 0 ; }
Generate Compatibility Graph Nodes Bond Insensitive
28,064
protected Integer compatibilityGraphNodesIfCEdgeIsZero ( ) throws IOException { int countNodes = 1 ; List < String > map = new ArrayList < String > ( ) ; compGraphNodesCZero = new ArrayList < Integer > ( ) ; LabelContainer labelContainer = LabelContainer . getInstance ( ) ; compGraphNodes . clear ( ) ; for ( int i = 0 ; i < source . getAtomCount ( ) ; i ++ ) { for ( int j = 0 ; j < target . getAtomCount ( ) ; j ++ ) { IAtom atom1 = source . getAtom ( i ) ; IAtom atom2 = target . getAtom ( j ) ; if ( atom1 . getSymbol ( ) . equalsIgnoreCase ( atom2 . getSymbol ( ) ) && ( ! map . contains ( i + "_" + j ) ) ) { compGraphNodesCZero . add ( i ) ; compGraphNodesCZero . add ( j ) ; compGraphNodesCZero . add ( labelContainer . getLabelID ( atom1 . getSymbol ( ) ) ) ; compGraphNodesCZero . add ( countNodes ) ; compGraphNodes . add ( i ) ; compGraphNodes . add ( j ) ; compGraphNodes . add ( countNodes ++ ) ; map . add ( i + "_" + j ) ; } } } map . clear ( ) ; return countNodes ; }
compGraphNodesCZero is used to build up of the edges of the compatibility graph
28,065
protected int compatibilityGraphCEdgeZero ( ) throws IOException { int compGraphNodesCZeroListSize = compGraphNodesCZero . size ( ) ; cEdges = new ArrayList < Integer > ( ) ; dEdges = new ArrayList < Integer > ( ) ; for ( int a = 0 ; a < compGraphNodesCZeroListSize ; a += 4 ) { int indexA = compGraphNodesCZero . get ( a ) ; int indexAPlus1 = compGraphNodesCZero . get ( a + 1 ) ; for ( int b = a + 4 ; b < compGraphNodesCZeroListSize ; b += 4 ) { int indexB = compGraphNodesCZero . get ( b ) ; int indexBPlus1 = compGraphNodesCZero . get ( b + 1 ) ; if ( ( a != b ) && ( indexA != indexB ) && ( indexAPlus1 != indexBPlus1 ) ) { IBond reactantBond = null ; IBond productBond = null ; reactantBond = source . getBond ( source . getAtom ( indexA ) , source . getAtom ( indexB ) ) ; productBond = target . getBond ( target . getAtom ( indexAPlus1 ) , target . getAtom ( indexBPlus1 ) ) ; if ( reactantBond != null && productBond != null ) { addCZeroEdges ( reactantBond , productBond , a , b ) ; } } } } cEdgesSize = cEdges . size ( ) ; dEdgesSize = dEdges . size ( ) ; return 0 ; }
compatibilityGraphCEdgeZero is used to build up of the edges of the compatibility graph BIS
28,066
public static double evalSimpleIndex ( IAtomContainer atomContainer , List < List < Integer > > fragLists ) { double sum = 0 ; for ( List < Integer > fragList : fragLists ) { double prod = 1.0 ; for ( Integer atomSerial : fragList ) { IAtom atom = atomContainer . getAtom ( atomSerial ) ; int nconnected = atomContainer . getConnectedBondsCount ( atom ) ; prod = prod * nconnected ; } if ( prod != 0 ) sum += 1.0 / Math . sqrt ( prod ) ; } return sum ; }
Evaluates the simple chi index for a set of fragments .
28,067
public static double evalValenceIndex ( IAtomContainer atomContainer , List < List < Integer > > fragList ) throws CDKException { try { IsotopeFactory ifac = Isotopes . getInstance ( ) ; ifac . configureAtoms ( atomContainer ) ; } catch ( IOException e ) { throw new CDKException ( "IO problem occurred when using the CDK atom config\n" + e . getMessage ( ) , e ) ; } double sum = 0 ; for ( List < Integer > aFragList : fragList ) { List < Integer > frag = aFragList ; double prod = 1.0 ; for ( Object aFrag : frag ) { int atomSerial = ( Integer ) aFrag ; IAtom atom = atomContainer . getAtom ( atomSerial ) ; String sym = atom . getSymbol ( ) ; if ( sym . equals ( "S" ) ) { double tmp = deltavSulphur ( atom , atomContainer ) ; if ( tmp != - 1 ) { prod = prod * tmp ; continue ; } } if ( sym . equals ( "P" ) ) { double tmp = deltavPhosphorous ( atom , atomContainer ) ; if ( tmp != - 1 ) { prod = prod * tmp ; continue ; } } int z = atom . getAtomicNumber ( ) ; int zv = getValenceElectronCount ( atom ) ; int hsupp = atom . getImplicitHydrogenCount ( ) ; double deltav = ( double ) ( zv - hsupp ) / ( double ) ( z - zv - 1 ) ; prod = prod * deltav ; } if ( prod != 0 ) sum += 1.0 / Math . sqrt ( prod ) ; } return sum ; }
Evaluates the valence corrected chi index for a set of fragments .
28,068
protected static double deltavSulphur ( IAtom atom , IAtomContainer atomContainer ) { if ( ! atom . getSymbol ( ) . equals ( "S" ) ) return - 1 ; List < IAtom > connected = atomContainer . getConnectedAtomsList ( atom ) ; for ( IAtom connectedAtom : connected ) { if ( connectedAtom . getSymbol ( ) . equals ( "S" ) && atomContainer . getBond ( atom , connectedAtom ) . getOrder ( ) == IBond . Order . SINGLE ) return .89 ; } int count = 0 ; for ( IAtom connectedAtom : connected ) { if ( connectedAtom . getSymbol ( ) . equals ( "O" ) && atomContainer . getBond ( atom , connectedAtom ) . getOrder ( ) == IBond . Order . DOUBLE ) count ++ ; } if ( count == 1 ) return 1.33 ; else if ( count == 2 ) return 2.67 ; return - 1 ; }
Evaluates the empirical delt V for some S environments .
28,069
private static double deltavPhosphorous ( IAtom atom , IAtomContainer atomContainer ) { if ( ! atom . getSymbol ( ) . equals ( "P" ) ) return - 1 ; List < IAtom > connected = atomContainer . getConnectedAtomsList ( atom ) ; int conditions = 0 ; if ( connected . size ( ) == 4 ) conditions ++ ; for ( IAtom connectedAtom : connected ) { if ( connectedAtom . getSymbol ( ) . equals ( "O" ) && atomContainer . getBond ( atom , connectedAtom ) . getOrder ( ) == IBond . Order . DOUBLE ) conditions ++ ; if ( atomContainer . getBond ( atom , connectedAtom ) . getOrder ( ) == IBond . Order . SINGLE ) conditions ++ ; } if ( conditions == 5 ) return 2.22 ; return - 1 ; }
Checks whether the P atom is in a PO environment .
28,070
private static List < List < Integer > > getUniqueBondSubgraphs ( List < List < RMap > > subgraphs , IAtomContainer ac ) { List < List < Integer > > bondList = new ArrayList < List < Integer > > ( ) ; for ( List < RMap > subgraph : subgraphs ) { List < RMap > current = subgraph ; List < Integer > ids = new ArrayList < Integer > ( ) ; for ( RMap aCurrent : current ) { RMap rmap = ( RMap ) aCurrent ; ids . add ( rmap . getId1 ( ) ) ; } Collections . sort ( ids ) ; bondList . add ( ids ) ; } HashSet < List < Integer > > hs = new HashSet < List < Integer > > ( bondList ) ; bondList = new ArrayList < List < Integer > > ( hs ) ; List < List < Integer > > paths = new ArrayList < List < Integer > > ( ) ; for ( List < Integer > aBondList1 : bondList ) { List < Integer > aBondList = aBondList1 ; List < Integer > tmp = new ArrayList < Integer > ( ) ; for ( Object anABondList : aBondList ) { int bondNumber = ( Integer ) anABondList ; for ( IAtom atom : ac . getBond ( bondNumber ) . atoms ( ) ) { Integer atomInt = ac . indexOf ( atom ) ; if ( ! tmp . contains ( atomInt ) ) tmp . add ( atomInt ) ; } } paths . add ( tmp ) ; } return paths ; }
Converts a set of bond mappings to a unique set of atom paths .
28,071
public Iterable < IChemSequence > chemSequences ( ) { return new Iterable < IChemSequence > ( ) { public Iterator < IChemSequence > iterator ( ) { return new ChemSequenceIterator ( ) ; } } ; }
Returns the Iterable to ChemSequences of this container .
28,072
protected void growChemSequenceArray ( ) { growArraySize = chemSequences . length ; IChemSequence [ ] newchemSequences = new ChemSequence [ chemSequences . length + growArraySize ] ; System . arraycopy ( chemSequences , 0 , newchemSequences , 0 , chemSequences . length ) ; chemSequences = newchemSequences ; }
Grows the ChemSequence array by a given size .
28,073
public int compare ( String o1 , String o2 ) { if ( C_ELEMENT_SYMBOL . equals ( o1 ) ) { if ( C_ELEMENT_SYMBOL . equals ( o2 ) ) { return 0 ; } else { return - 1 ; } } else if ( H_ELEMENT_SYMBOL . equals ( o1 ) ) { if ( C_ELEMENT_SYMBOL . equals ( o2 ) ) { return 1 ; } else if ( H_ELEMENT_SYMBOL . equals ( o2 ) ) { return 0 ; } else { return - 1 ; } } else { if ( C_ELEMENT_SYMBOL . equals ( o2 ) || H_ELEMENT_SYMBOL . equals ( o2 ) ) { return 1 ; } else { return ( ( String ) o1 ) . compareTo ( ( String ) o2 ) ; } } }
Returns a negative if o1 comes before o2 in a molecular formula returns zero if they are identical and positive if o1 comes after o2 in the formula .
28,074
private Rectangle2D transformedBounds ( Shape shape ) { Rectangle2D rectangle2D = shape . getBounds2D ( ) ; Point2D minPoint = new Point2D . Double ( rectangle2D . getMinX ( ) , rectangle2D . getMinY ( ) ) ; Point2D maxPoint = new Point2D . Double ( rectangle2D . getMaxX ( ) , rectangle2D . getMaxY ( ) ) ; transform . transform ( minPoint , minPoint ) ; transform . transform ( maxPoint , maxPoint ) ; double minX = Math . min ( minPoint . getX ( ) , maxPoint . getX ( ) ) ; double maxX = Math . max ( minPoint . getX ( ) , maxPoint . getX ( ) ) ; double minY = Math . min ( minPoint . getY ( ) , maxPoint . getY ( ) ) ; double maxY = Math . max ( minPoint . getY ( ) , maxPoint . getY ( ) ) ; return new Rectangle2D . Double ( minX , minY , maxX - minX , maxY - minY ) ; }
Access the bounds of a shape that have been transformed .
28,075
Point2D getCenter ( ) { final Rectangle2D bounds = getBounds ( ) ; return new Point2D . Double ( bounds . getCenterX ( ) , bounds . getCenterY ( ) ) ; }
Access the transformed center of the whole outline .
28,076
private Point2D getGlyphCenter ( final int index ) { if ( text . length ( ) == 1 ) return getCenter ( ) ; final Shape glyph = glyphs . getGlyphOutline ( index ) ; final Rectangle2D glyphBounds = transformedBounds ( glyph ) ; return new Point2D . Double ( glyphBounds . getCenterX ( ) , glyphBounds . getCenterY ( ) ) ; }
Determines the transformed centre of a specified glyph .
28,077
TextOutline transform ( AffineTransform nextTransform ) { final AffineTransform combinedTransform = new AffineTransform ( ) ; combinedTransform . concatenate ( nextTransform ) ; combinedTransform . concatenate ( transform ) ; return new TextOutline ( text , glyphs , outline , combinedTransform ) ; }
Add a transformation to the outline .
28,078
public void addListener ( IChemObjectListener col ) { List < IChemObjectListener > listeners = lazyChemObjectListeners ( ) ; if ( ! listeners . contains ( col ) ) { listeners . add ( col ) ; } }
Use this to add yourself to this IChemObject as a listener . In order to do so you must implement the ChemObjectListener Interface .
28,079
public void removeListener ( IChemObjectListener col ) { if ( chemObjectListeners == null ) { return ; } List < IChemObjectListener > listeners = lazyChemObjectListeners ( ) ; if ( listeners . contains ( col ) ) { listeners . remove ( col ) ; } }
Use this to remove a ChemObjectListener from the ListenerList of this IChemObject . It will then not be notified of change in this object anymore .
28,080
public void notifyChanged ( ) { if ( getNotification ( ) && getListenerCount ( ) > 0 ) { List < IChemObjectListener > listeners = lazyChemObjectListeners ( ) ; for ( Object listener : listeners ) { ( ( IChemObjectListener ) listener ) . stateChanged ( new QueryChemObjectChangeEvent ( this ) ) ; } } }
This should be triggered by an method that changes the content of an object to that the registered listeners can react to it .
28,081
private Map < Object , Object > lazyProperties ( ) { if ( properties == null ) { properties = new HashMap < Object , Object > ( ) ; } return properties ; }
Lazy creation of properties hash .
28,082
public void setProperty ( Object description , Object property ) { lazyProperties ( ) . put ( description , property ) ; notifyChanged ( ) ; }
Sets a property for a IChemObject .
28,083
public < T > T getProperty ( Object description ) { @ SuppressWarnings ( "unchecked" ) T value = ( T ) lazyProperties ( ) . get ( description ) ; return value ; }
Returns a property for the IChemObject .
28,084
public IChemFormat [ ] findChemFormats ( int features ) { if ( formats == null ) loadFormats ( ) ; Iterator < IChemFormat > iter = formats . iterator ( ) ; List < IChemFormat > matches = new ArrayList < IChemFormat > ( ) ; while ( iter . hasNext ( ) ) { IChemFormat format = ( IChemFormat ) iter . next ( ) ; if ( ( format . getSupportedDataFeatures ( ) & features ) == features ) matches . add ( format ) ; } return ( IChemFormat [ ] ) matches . toArray ( new IChemFormat [ matches . size ( ) ] ) ; }
Finds IChemFormats that provide a container for serialization for the given features . The syntax of the integer is explained in the DataFeatures class .
28,085
public IChemObjectWriter createWriter ( IChemFormat format ) { if ( format != null ) { String writerClassName = format . getWriterClassName ( ) ; if ( writerClassName != null ) { try { if ( registeredReaders . containsKey ( writerClassName ) ) { Class < IChemObjectWriter > writer = registeredReaders . get ( writerClassName ) ; if ( writer != null ) return writer . newInstance ( ) ; } return ( IChemObjectWriter ) this . getClass ( ) . getClassLoader ( ) . loadClass ( writerClassName ) . newInstance ( ) ; } catch ( ClassNotFoundException exception ) { logger . error ( "Could not find this ChemObjectWriter: " , writerClassName ) ; logger . debug ( exception ) ; } catch ( InstantiationException | IllegalAccessException exception ) { logger . error ( "Could not create this ChemObjectWriter: " , writerClassName ) ; logger . debug ( exception ) ; } } else { logger . warn ( "ChemFormat is recognized, but no writer is available." ) ; } } else { logger . warn ( "ChemFormat is not recognized." ) ; } return null ; }
Creates a new IChemObjectWriter based on the given IChemFormat .
28,086
public DescriptorValue calculate ( IAtom atom , IAtomContainer ac ) { double polarizability ; try { String originalAtomtypeName = atom . getAtomTypeName ( ) ; Integer originalNeighborCount = atom . getFormalNeighbourCount ( ) ; Integer originalHCount = atom . getImplicitHydrogenCount ( ) ; Integer originalValency = atom . getValency ( ) ; IAtomType . Hybridization originalHybridization = atom . getHybridization ( ) ; boolean originalFlag = atom . getFlag ( CDKConstants . VISITED ) ; Double originalBondOrderSum = atom . getBondOrderSum ( ) ; Order originalMaxBondOrder = atom . getMaxBondOrder ( ) ; polarizability = pol . calculateGHEffectiveAtomPolarizability ( ac , atom , 100 , true ) ; atom . setAtomTypeName ( originalAtomtypeName ) ; atom . setFormalNeighbourCount ( originalNeighborCount ) ; atom . setValency ( originalValency ) ; atom . setImplicitHydrogenCount ( originalHCount ) ; atom . setFlag ( CDKConstants . VISITED , originalFlag ) ; atom . setHybridization ( originalHybridization ) ; atom . setMaxBondOrder ( originalMaxBondOrder ) ; atom . setBondOrderSum ( originalBondOrderSum ) ; return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( polarizability ) , getDescriptorNames ( ) ) ; } catch ( Exception ex1 ) { return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new DoubleResult ( Double . NaN ) , getDescriptorNames ( ) , ex1 ) ; } }
The method calculates the Effective Atom Polarizability of a given atom It is needed to call the addExplicitHydrogensToSatisfyValency method from the class tools . HydrogenAdder .
28,087
public List < IAtomType > readAtomTypes ( IChemObjectBuilder builder ) throws IOException { List < IAtomType > atomTypes ; if ( ins == null ) throw new IOException ( "There was a problem getting an input stream" ) ; OWLAtomTypeReader reader = new OWLAtomTypeReader ( new InputStreamReader ( ins ) ) ; atomTypes = reader . readAtomTypes ( builder ) ; for ( IAtomType atomType : atomTypes ) { if ( atomType == null ) { logger . debug ( "Expecting an object but found null!" ) ; } } return atomTypes ; }
Reads the atom types from the OWL based atom type list .
28,088
public static boolean isIsomorph ( IAtomContainer sourceGraph , IAtomContainer targetGraph , boolean shouldMatchBonds ) throws CDKException { if ( sourceGraph instanceof IQueryAtomContainer ) { throw new CDKException ( "The first IAtomContainer must not be an IQueryAtomContainer" ) ; } if ( targetGraph . getAtomCount ( ) != sourceGraph . getAtomCount ( ) ) { return false ; } if ( targetGraph . getAtomCount ( ) == 1 ) { IAtom atom = sourceGraph . getAtom ( 0 ) ; IAtom atom2 = targetGraph . getAtom ( 0 ) ; if ( atom instanceof IQueryAtom ) { IQueryAtom qAtom = ( IQueryAtom ) atom ; return qAtom . matches ( targetGraph . getAtom ( 0 ) ) ; } else if ( atom2 instanceof IQueryAtom ) { IQueryAtom qAtom = ( IQueryAtom ) atom2 ; return qAtom . matches ( sourceGraph . getAtom ( 0 ) ) ; } else { String atomSymbol = atom2 . getSymbol ( ) ; return sourceGraph . getAtom ( 0 ) . getSymbol ( ) . equals ( atomSymbol ) ; } } return ( getIsomorphMap ( sourceGraph , targetGraph , shouldMatchBonds ) != null ) ; }
Tests if sourceGraph and targetGraph are isomorph .
28,089
public static List < CDKRMap > getIsomorphMap ( IAtomContainer sourceGraph , IAtomContainer targetGraph , boolean shouldMatchBonds ) throws CDKException { if ( sourceGraph instanceof IQueryAtomContainer ) { throw new CDKException ( "The first IAtomContainer must not be an IQueryAtomContainer" ) ; } List < CDKRMap > result = null ; List < List < CDKRMap > > rMapsList = search ( sourceGraph , targetGraph , getBitSet ( sourceGraph ) , getBitSet ( targetGraph ) , false , false , shouldMatchBonds ) ; if ( ! rMapsList . isEmpty ( ) ) { result = rMapsList . get ( 0 ) ; } return result ; }
Returns the first isomorph mapping found or null .
28,090
public static List < CDKRMap > getIsomorphAtomsMap ( IAtomContainer sourceGraph , IAtomContainer targetGraph , boolean shouldMatchBonds ) throws CDKException { if ( sourceGraph instanceof IQueryAtomContainer ) { throw new CDKException ( "The first IAtomContainer must not be an IQueryAtomContainer" ) ; } List < CDKRMap > list = checkSingleAtomCases ( sourceGraph , targetGraph ) ; if ( list == null ) { return makeAtomsMapOfBondsMap ( CDKMCS . getIsomorphMap ( sourceGraph , targetGraph , shouldMatchBonds ) , sourceGraph , targetGraph ) ; } else if ( list . isEmpty ( ) ) { return null ; } else { return list ; } }
Returns the first isomorph atom mapping found for targetGraph in sourceGraph .
28,091
public static List < List < CDKRMap > > getIsomorphMaps ( IAtomContainer sourceGraph , IAtomContainer targetGraph , boolean shouldMatchBonds ) throws CDKException { return search ( sourceGraph , targetGraph , getBitSet ( sourceGraph ) , getBitSet ( targetGraph ) , true , true , shouldMatchBonds ) ; }
Returns all the isomorph mappings found between two atom containers .
28,092
public static List < List < CDKRMap > > getSubgraphMaps ( IAtomContainer sourceGraph , IAtomContainer targetGraph , boolean shouldMatchBonds ) throws CDKException { return search ( sourceGraph , targetGraph , new BitSet ( ) , getBitSet ( targetGraph ) , true , true , shouldMatchBonds ) ; }
Returns all the subgraph bondA1 mappings found for targetGraph in sourceGraph . This is an ArrayList of ArrayLists of CDKRMap objects .
28,093
public static List < CDKRMap > getSubgraphMap ( IAtomContainer sourceGraph , IAtomContainer targetGraph , boolean shouldMatchBonds ) throws CDKException { List < CDKRMap > result = null ; List < List < CDKRMap > > rMapsList = search ( sourceGraph , targetGraph , new BitSet ( ) , getBitSet ( targetGraph ) , false , false , shouldMatchBonds ) ; if ( ! rMapsList . isEmpty ( ) ) { result = rMapsList . get ( 0 ) ; } return result ; }
Returns the first subgraph bondA1 mapping found for targetGraph in sourceGraph .
28,094
public static List < List < CDKRMap > > getSubgraphAtomsMaps ( IAtomContainer sourceGraph , IAtomContainer targetGraph , boolean shouldMatchBonds ) throws CDKException { List < CDKRMap > list = checkSingleAtomCases ( sourceGraph , targetGraph ) ; if ( list == null ) { return makeAtomsMapsOfBondsMaps ( CDKMCS . getSubgraphMaps ( sourceGraph , targetGraph , shouldMatchBonds ) , sourceGraph , targetGraph ) ; } else { List < List < CDKRMap > > atomsMap = new ArrayList < List < CDKRMap > > ( ) ; atomsMap . add ( list ) ; return atomsMap ; } }
Returns all subgraph atom mappings found for targetGraph in sourceGraph . This is an ArrayList of ArrayLists of CDKRMap objects .
28,095
public static List < CDKRMap > getSubgraphAtomsMap ( IAtomContainer sourceGraph , IAtomContainer targetGraph , boolean shouldMatchBonds ) throws CDKException { List < CDKRMap > list = checkSingleAtomCases ( sourceGraph , targetGraph ) ; if ( list == null ) { return makeAtomsMapOfBondsMap ( CDKMCS . getSubgraphMap ( sourceGraph , targetGraph , shouldMatchBonds ) , sourceGraph , targetGraph ) ; } else if ( list . isEmpty ( ) ) { return null ; } else { return list ; } }
Returns the first subgraph atom mapping found for targetGraph in sourceGraph .
28,096
public static boolean isSubgraph ( IAtomContainer sourceGraph , IAtomContainer targetGraph , boolean shouldMatchBonds ) throws CDKException { if ( sourceGraph instanceof IQueryAtomContainer ) { throw new CDKException ( "The first IAtomContainer must not be an IQueryAtomContainer" ) ; } if ( targetGraph . getAtomCount ( ) > sourceGraph . getAtomCount ( ) ) { return false ; } if ( targetGraph . getAtomCount ( ) == 1 ) { IAtom atom = targetGraph . getAtom ( 0 ) ; for ( int i = 0 ; i < sourceGraph . getAtomCount ( ) ; i ++ ) { IAtom atom2 = sourceGraph . getAtom ( i ) ; if ( atom instanceof IQueryAtom ) { IQueryAtom qAtom = ( IQueryAtom ) atom ; if ( qAtom . matches ( atom2 ) ) { return true ; } } else if ( atom2 instanceof IQueryAtom ) { IQueryAtom qAtom = ( IQueryAtom ) atom2 ; if ( qAtom . matches ( atom ) ) { return true ; } } else { if ( atom2 . getSymbol ( ) . equals ( atom . getSymbol ( ) ) ) { return true ; } } } return false ; } if ( ! testSubgraphHeuristics ( sourceGraph , targetGraph ) ) { return false ; } return ( getSubgraphMap ( sourceGraph , targetGraph , shouldMatchBonds ) != null ) ; }
Tests if targetGraph atom subgraph of sourceGraph .
28,097
public static List < IAtomContainer > getOverlaps ( IAtomContainer sourceGraph , IAtomContainer targetGraph , boolean shouldMatchBonds ) throws CDKException { List < List < CDKRMap > > rMapsList = search ( sourceGraph , targetGraph , new BitSet ( ) , new BitSet ( ) , true , false , shouldMatchBonds ) ; ArrayList < IAtomContainer > graphList = projectList ( rMapsList , sourceGraph , ID1 ) ; return getMaximum ( graphList , shouldMatchBonds ) ; }
Returns all the maximal common substructure between 2 atom containers .
28,098
public static IAtomContainer project ( List < CDKRMap > rMapList , IAtomContainer graph , int key ) { IAtomContainer atomContainer = graph . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; Map < IAtom , IAtom > table = new HashMap < IAtom , IAtom > ( ) ; IAtom atom1 ; IAtom atom2 ; IAtom atom ; IBond bond ; for ( Iterator < CDKRMap > i = rMapList . iterator ( ) ; i . hasNext ( ) ; ) { CDKRMap rMap = i . next ( ) ; if ( key == CDKMCS . ID1 ) { bond = graph . getBond ( rMap . getId1 ( ) ) ; } else { bond = graph . getBond ( rMap . getId2 ( ) ) ; } atom = bond . getBegin ( ) ; atom1 = table . get ( atom ) ; if ( atom1 == null ) { try { atom1 = ( IAtom ) atom . clone ( ) ; } catch ( CloneNotSupportedException e ) { e . printStackTrace ( ) ; } atomContainer . addAtom ( atom1 ) ; table . put ( atom , atom1 ) ; } atom = bond . getEnd ( ) ; atom2 = table . get ( atom ) ; if ( atom2 == null ) { try { atom2 = ( IAtom ) atom . clone ( ) ; } catch ( CloneNotSupportedException e ) { e . printStackTrace ( ) ; } atomContainer . addAtom ( atom2 ) ; table . put ( atom , atom2 ) ; } IBond newBond = graph . getBuilder ( ) . newInstance ( IBond . class , atom1 , atom2 , bond . getOrder ( ) ) ; newBond . setFlag ( CDKConstants . ISAROMATIC , bond . getFlag ( CDKConstants . ISAROMATIC ) ) ; atomContainer . addBond ( newBond ) ; } return atomContainer ; }
Projects atom list of CDKRMap on atom molecule .
28,099
public static ArrayList < IAtomContainer > projectList ( List < List < CDKRMap > > rMapsList , IAtomContainer graph , int key ) { ArrayList < IAtomContainer > graphList = new ArrayList < IAtomContainer > ( ) ; for ( List < CDKRMap > rMapList : rMapsList ) { IAtomContainer atomContainer = project ( rMapList , graph , key ) ; graphList . add ( atomContainer ) ; } return graphList ; }
Projects atom list of RMapsList on atom molecule .