idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
28,500 | public IMolecularFormula addIsotope ( IIsotope isotope , int count ) { if ( count == 0 ) return this ; boolean flag = false ; for ( IIsotope thisIsotope : isotopes ( ) ) { if ( isTheSame ( thisIsotope , isotope ) ) { isotopes . put ( thisIsotope , isotopes . get ( thisIsotope ) + count ) ; flag = true ; break ; } } if ( ! flag ) { isotopes . put ( isotope , count ) ; } return this ; } | Adds an Isotope to this MolecularFormula in a number of occurrences . |
28,501 | public boolean contains ( IIsotope isotope ) { for ( IIsotope thisIsotope : isotopes ( ) ) { if ( isTheSame ( thisIsotope , isotope ) ) { return true ; } } return false ; } | True if the MolecularFormula contains the given IIsotope object and not the instance . The method looks for other isotopes which has the same symbol natural abundance and exact mass . |
28,502 | public int getIsotopeCount ( IIsotope isotope ) { return ! contains ( isotope ) ? 0 : isotopes . get ( getIsotope ( isotope ) ) ; } | Checks a set of Nodes for the occurrence of the isotope in the IMolecularFormula from a particular isotope . It returns 0 if the does not exist . |
28,503 | private Map < Object , Object > lazyProperties ( ) { if ( properties == null ) { properties = new Hashtable < Object , Object > ( ) ; } return properties ; } | Lazy creation of properties hash . I should integrate into ChemObject . |
28,504 | public void writeMolecule ( IAtomContainer mol ) throws IOException { customizeJob ( ) ; if ( proccount . getSettingValue ( ) > 1 ) { writer . write ( "%nprocl=" + proccount . getSettingValue ( ) ) ; writer . write ( '\n' ) ; } if ( ! memory . getSetting ( ) . equals ( "unset" ) ) { writer . write ( "%Mem=" + memory . getSetting ( ) ) ; writer . write ( '\n' ) ; } if ( usecheckpoint . isSet ( ) ) { if ( mol . getID ( ) != null && mol . getID ( ) . length ( ) > 0 ) { writer . write ( "%chk=" + mol . getID ( ) + ".chk" ) ; } else { writer . write ( "%chk=" + System . currentTimeMillis ( ) + ".chk" ) ; } writer . write ( '\n' ) ; } writer . write ( "# " + method . getSetting ( ) + "/" + basis . getSetting ( ) + " " ) ; String commandString = command . getSetting ( ) ; if ( commandString . equals ( "energy calculation" ) ) { } else if ( commandString . equals ( "geometry optimization" ) ) { writer . write ( "opt" ) ; } else if ( commandString . equals ( "IR frequency calculation" ) ) { writer . write ( "freq" ) ; } else if ( commandString . equals ( "IR frequency calculation (with Raman)" ) ) { writer . write ( "freq=noraman" ) ; } else { writer . write ( commandString ) ; } writer . write ( '\n' ) ; writer . write ( '\n' ) ; writer . write ( comment . getSetting ( ) ) ; writer . write ( '\n' ) ; writer . write ( '\n' ) ; writer . write ( "0 " ) ; if ( shell . isSet ( ) ) { writer . write ( "0" ) ; } else { writer . write ( "1" ) ; } writer . write ( '\n' ) ; Iterator < IAtom > atoms = mol . atoms ( ) . iterator ( ) ; while ( atoms . hasNext ( ) ) { IAtom a = atoms . next ( ) ; String st = a . getSymbol ( ) ; st = st + " 0 " ; Point3d p3 = a . getPoint3d ( ) ; if ( p3 != null ) { st = st + new Double ( p3 . x ) . toString ( ) + " " + new Double ( p3 . y ) . toString ( ) + " " + new Double ( p3 . z ) . toString ( ) ; } writer . write ( st , 0 , st . length ( ) ) ; writer . write ( '\n' ) ; } writer . write ( '\n' ) ; } | Writes a molecule for input for Gaussian . |
28,505 | public static IAtomContainer extractSubstructure ( IAtomContainer atomContainer , int ... atomIndices ) throws CloneNotSupportedException { IAtomContainer substructure = ( IAtomContainer ) atomContainer . clone ( ) ; int numberOfAtoms = substructure . getAtomCount ( ) ; IAtom [ ] atoms = new IAtom [ numberOfAtoms ] ; for ( int atomIndex = 0 ; atomIndex < numberOfAtoms ; atomIndex ++ ) { atoms [ atomIndex ] = substructure . getAtom ( atomIndex ) ; } Arrays . sort ( atomIndices ) ; for ( int index = 0 ; index < numberOfAtoms ; index ++ ) { if ( Arrays . binarySearch ( atomIndices , index ) < 0 ) { IAtom atom = atoms [ index ] ; substructure . removeAtom ( atom ) ; } } return substructure ; } | Extract a substructure from an atom container in the form of a new cloned atom container with only the atoms with indices in atomIndices and bonds that connect these atoms . |
28,506 | public static IAtom getAtomById ( IAtomContainer ac , String id ) throws CDKException { for ( int i = 0 ; i < ac . getAtomCount ( ) ; i ++ ) { if ( ac . getAtom ( i ) . getID ( ) != null && ac . getAtom ( i ) . getID ( ) . equals ( id ) ) return ac . getAtom ( i ) ; } throw new CDKException ( "no suc atom" ) ; } | Returns an atom in an atomcontainer identified by id |
28,507 | public static boolean replaceAtomByAtom ( final IAtomContainer container , final IAtom oldAtom , final IAtom newAtom ) { if ( oldAtom == null ) throw new NullPointerException ( "Atom to be replaced was null!" ) ; if ( newAtom == null ) throw new NullPointerException ( "Replacement atom was null!" ) ; final int idx = container . indexOf ( oldAtom ) ; if ( idx < 0 ) return false ; container . setAtom ( idx , newAtom ) ; List < Sgroup > sgrougs = container . getProperty ( CDKConstants . CTAB_SGROUPS ) ; if ( sgrougs != null ) { boolean updated = false ; List < Sgroup > replaced = new ArrayList < > ( ) ; for ( Sgroup org : sgrougs ) { if ( org . getAtoms ( ) . contains ( oldAtom ) ) { updated = true ; Sgroup cpy = new Sgroup ( ) ; for ( IAtom atom : org . getAtoms ( ) ) { if ( ! oldAtom . equals ( atom ) ) cpy . addAtom ( atom ) ; else cpy . addAtom ( newAtom ) ; } for ( IBond bond : org . getBonds ( ) ) cpy . addBond ( bond ) ; for ( Sgroup parent : org . getParents ( ) ) cpy . addParent ( parent ) ; for ( SgroupKey key : org . getAttributeKeys ( ) ) cpy . putValue ( key , org . getValue ( key ) ) ; replaced . add ( cpy ) ; } else { replaced . add ( org ) ; } } if ( updated ) { container . setProperty ( CDKConstants . CTAB_SGROUPS , Collections . unmodifiableList ( replaced ) ) ; } } return true ; } | Substitute one atom in a container for another adjusting bonds single electrons lone pairs and stereochemistry as required . |
28,508 | public static double getTotalCharge ( IAtomContainer atomContainer ) { double charge = 0.0 ; for ( IAtom atom : atomContainer . atoms ( ) ) { Double thisCharge = atom . getCharge ( ) ; if ( thisCharge != CDKConstants . UNSET ) charge += thisCharge ; } return charge ; } | Get the summed charge of all atoms in an AtomContainer |
28,509 | public static double getTotalNaturalAbundance ( IAtomContainer atomContainer ) { try { Isotopes isotopes = Isotopes . getInstance ( ) ; double abundance = 1.0 ; double hAbundance = isotopes . getMajorIsotope ( 1 ) . getNaturalAbundance ( ) ; int nImplH = 0 ; for ( IAtom atom : atomContainer . atoms ( ) ) { if ( atom . getImplicitHydrogenCount ( ) == null ) throw new IllegalArgumentException ( "an atom had with unknown (null) implicit hydrogens" ) ; abundance *= atom . getNaturalAbundance ( ) ; for ( int h = 0 ; h < atom . getImplicitHydrogenCount ( ) ; h ++ ) abundance *= hAbundance ; nImplH += atom . getImplicitHydrogenCount ( ) ; } return abundance / Math . pow ( 100 , nImplH + atomContainer . getAtomCount ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( "Isotopes definitions could not be loaded" , e ) ; } } | Get the summed natural abundance of all atoms in an AtomContainer |
28,510 | public static int getTotalFormalCharge ( IAtomContainer atomContainer ) { int chargeP = getTotalNegativeFormalCharge ( atomContainer ) ; int chargeN = getTotalPositiveFormalCharge ( atomContainer ) ; return chargeP + chargeN ; } | Get the total formal charge on a molecule . |
28,511 | public static int getTotalNegativeFormalCharge ( IAtomContainer atomContainer ) { int charge = 0 ; for ( int i = 0 ; i < atomContainer . getAtomCount ( ) ; i ++ ) { int chargeI = atomContainer . getAtom ( i ) . getFormalCharge ( ) ; if ( chargeI < 0 ) charge += chargeI ; } return charge ; } | Get the total formal negative charge on a molecule . |
28,512 | public static int countExplicitHydrogens ( IAtomContainer atomContainer , IAtom atom ) { if ( atomContainer == null || atom == null ) throw new IllegalArgumentException ( "null container or atom provided" ) ; int hCount = 0 ; for ( IAtom connected : atomContainer . getConnectedAtomsList ( atom ) ) { if ( Elements . HYDROGEN . getSymbol ( ) . equals ( connected . getSymbol ( ) ) ) { hCount ++ ; } } return hCount ; } | Count explicit hydrogens . |
28,513 | private static void incrementImplHydrogenCount ( final IAtom atom ) { Integer hCount = atom . getImplicitHydrogenCount ( ) ; if ( hCount == null ) { if ( ! ( atom instanceof IPseudoAtom ) ) throw new IllegalArgumentException ( "a non-pseudo atom had an unset hydrogen count" ) ; hCount = 0 ; } atom . setImplicitHydrogenCount ( hCount + 1 ) ; } | Increment the implicit hydrogen count of the provided atom . If the atom was a non - pseudo atom and had an unset hydrogen count an exception is thrown . |
28,514 | private static IAtom findSingleBond ( IAtomContainer container , IAtom atom , IAtom exclude ) { for ( IBond bond : container . getConnectedBondsList ( atom ) ) { if ( bond . getOrder ( ) != Order . SINGLE ) continue ; IAtom neighbor = bond . getOther ( atom ) ; if ( ! neighbor . equals ( exclude ) ) return neighbor ; } return null ; } | Finds an neighbor connected to atom which is connected by a single bond and is not exclude . |
28,515 | public static void unregisterAtomListeners ( IAtomContainer container ) { for ( IAtom atom : container . atoms ( ) ) atom . removeListener ( container ) ; } | A method to remove AtomListeners . AtomListeners are used to detect changes in Atom objects within this AtomContainer and to notifiy registered Listeners in the event of a change . If an object looses interest in such changes it should unregister with this AtomContainer in order to improve performance of this class . |
28,516 | public static IAtom [ ] getAtomArray ( IAtomContainer container ) { IAtom [ ] ret = new IAtom [ container . getAtomCount ( ) ] ; for ( int i = 0 ; i < ret . length ; ++ i ) ret [ i ] = container . getAtom ( i ) ; return ret ; } | Constructs an array of Atom objects from an AtomContainer . |
28,517 | public static void clearAtomConfigurations ( IAtomContainer container ) { for ( IAtom atom : container . atoms ( ) ) { atom . setAtomTypeName ( ( String ) CDKConstants . UNSET ) ; atom . setMaxBondOrder ( ( IBond . Order ) CDKConstants . UNSET ) ; atom . setBondOrderSum ( ( Double ) CDKConstants . UNSET ) ; atom . setCovalentRadius ( ( Double ) CDKConstants . UNSET ) ; atom . setValency ( ( Integer ) CDKConstants . UNSET ) ; atom . setFormalCharge ( ( Integer ) CDKConstants . UNSET ) ; atom . setHybridization ( ( IAtomType . Hybridization ) CDKConstants . UNSET ) ; atom . setFormalNeighbourCount ( ( Integer ) CDKConstants . UNSET ) ; atom . setFlag ( CDKConstants . IS_HYDROGENBOND_ACCEPTOR , false ) ; atom . setFlag ( CDKConstants . IS_HYDROGENBOND_DONOR , false ) ; atom . setProperty ( CDKConstants . CHEMICAL_GROUP_CONSTANT , CDKConstants . UNSET ) ; atom . setFlag ( CDKConstants . ISAROMATIC , false ) ; atom . setProperty ( "org.openscience.cdk.renderer.color" , CDKConstants . UNSET ) ; atom . setExactMass ( ( Double ) CDKConstants . UNSET ) ; } } | This method will reset all atom configuration to UNSET . |
28,518 | public static IAtomContainer createAllCarbonAllSingleNonAromaticBondAtomContainer ( IAtomContainer atomContainer ) throws CloneNotSupportedException { IAtomContainer query = ( IAtomContainer ) atomContainer . clone ( ) ; for ( int i = 0 ; i < query . getBondCount ( ) ; i ++ ) { query . getBond ( i ) . setOrder ( IBond . Order . SINGLE ) ; query . getBond ( i ) . setFlag ( CDKConstants . ISAROMATIC , false ) ; query . getBond ( i ) . setFlag ( CDKConstants . SINGLE_OR_DOUBLE , false ) ; query . getBond ( i ) . getBegin ( ) . setSymbol ( "C" ) ; query . getBond ( i ) . getBegin ( ) . setHybridization ( null ) ; query . getBond ( i ) . getEnd ( ) . setSymbol ( "C" ) ; query . getBond ( i ) . getEnd ( ) . setHybridization ( null ) ; query . getBond ( i ) . getBegin ( ) . setFlag ( CDKConstants . ISAROMATIC , false ) ; query . getBond ( i ) . getEnd ( ) . setFlag ( CDKConstants . ISAROMATIC , false ) ; } return query ; } | Generates a cloned atomcontainer with all atoms being carbon all bonds being single non - aromatic |
28,519 | public static IAtomContainer anonymise ( IAtomContainer src ) { IChemObjectBuilder builder = src . getBuilder ( ) ; IAtom [ ] atoms = new IAtom [ src . getAtomCount ( ) ] ; IBond [ ] bonds = new IBond [ src . getBondCount ( ) ] ; for ( int i = 0 ; i < atoms . length ; i ++ ) { atoms [ i ] = builder . newAtom ( ) ; atoms [ i ] . setAtomicNumber ( 6 ) ; atoms [ i ] . setSymbol ( "C" ) ; atoms [ i ] . setImplicitHydrogenCount ( 0 ) ; IAtom srcAtom = src . getAtom ( i ) ; if ( srcAtom . getPoint2d ( ) != null ) atoms [ i ] . setPoint2d ( new Point2d ( srcAtom . getPoint2d ( ) ) ) ; if ( srcAtom . getPoint3d ( ) != null ) atoms [ i ] . setPoint3d ( new Point3d ( srcAtom . getPoint3d ( ) ) ) ; } for ( int i = 0 ; i < bonds . length ; i ++ ) { IBond bond = src . getBond ( i ) ; int u = src . indexOf ( bond . getBegin ( ) ) ; int v = src . indexOf ( bond . getEnd ( ) ) ; bonds [ i ] = builder . newInstance ( IBond . class , atoms [ u ] , atoms [ v ] ) ; } IAtomContainer dest = builder . newInstance ( IAtomContainer . class , 0 , 0 , 0 , 0 ) ; dest . setAtoms ( atoms ) ; dest . setBonds ( bonds ) ; return dest ; } | Anonymise the provided container to single - bonded carbon atoms . No information other then the connectivity from the original container is retrained . |
28,520 | public static double getBondOrderSum ( IAtomContainer container , IAtom atom ) { double count = 0 ; for ( IBond bond : container . getConnectedBondsList ( atom ) ) { IBond . Order order = bond . getOrder ( ) ; if ( order != null ) { count += order . numeric ( ) ; } } return count ; } | Returns the sum of the bond order equivalents for a given IAtom . It considers single bonds as 1 . 0 double bonds as 2 . 0 triple bonds as 3 . 0 and quadruple bonds as 4 . 0 . |
28,521 | public int [ ] [ ] paths ( ) { final int [ ] [ ] paths = new int [ size ( ) ] [ ] ; for ( int i = 0 ; i < paths . length ; i ++ ) paths [ i ] = essential . get ( i ) . path ( ) ; return paths ; } | The paths for each essential cycle . |
28,522 | private List < List < Cycle > > groupByLength ( final RelevantCycles relevant ) { LinkedList < List < Cycle > > cyclesByLength = new LinkedList < List < Cycle > > ( ) ; for ( int [ ] path : relevant . paths ( ) ) { if ( cyclesByLength . isEmpty ( ) || path . length > cyclesByLength . getLast ( ) . get ( 0 ) . path ( ) . length ) { cyclesByLength . add ( new ArrayList < Cycle > ( ) ) ; } cyclesByLength . getLast ( ) . add ( new MyCycle ( path ) ) ; } return cyclesByLength ; } | Reconstruct all relevant cycles and group then by length . |
28,523 | private List < Cycle > membersOfBasis ( final List < Cycle > cycles ) { int start = basis . size ( ) ; for ( final Cycle c : cycles ) { if ( basis . isIndependent ( c ) ) basis . add ( c ) ; } return basis . members ( ) . subList ( start , basis . size ( ) ) ; } | For a list of equal length cycles return those which are members of the minimum cycle basis . |
28,524 | public boolean compare ( Object object ) { if ( object instanceof IQueryBond ) { QueryBond queryBond = ( QueryBond ) object ; for ( IAtom atom : atoms ) { if ( ! queryBond . contains ( atom ) ) { return false ; } } return true ; } return false ; } | Compares a query bond with this query bond . |
28,525 | public void makeUnion ( int elementX , int elementY ) { int xRoot = getRoot ( elementX ) ; int yRoot = getRoot ( elementY ) ; if ( xRoot == yRoot ) { return ; } if ( forest [ xRoot ] < forest [ yRoot ] ) { forest [ yRoot ] = forest [ yRoot ] + forest [ xRoot ] ; forest [ xRoot ] = yRoot ; } else { forest [ xRoot ] = forest [ xRoot ] + forest [ yRoot ] ; forest [ yRoot ] = xRoot ; } } | Union these two elements - in other words put them in the same set . |
28,526 | public int [ ] [ ] getSets ( ) { int n = 0 ; for ( int i = 0 ; i < forest . length ; i ++ ) { if ( forest [ i ] < 0 ) { n ++ ; } } int [ ] [ ] sets = new int [ n ] [ ] ; int currentSet = 0 ; for ( int i = 0 ; i < forest . length ; i ++ ) { if ( forest [ i ] < 0 ) { int setSize = 1 - forest [ i ] - 1 ; sets [ currentSet ] = new int [ setSize ] ; int currentIndex = 0 ; for ( int element = 0 ; element < forest . length ; element ++ ) { if ( getRoot ( element ) == i ) { sets [ currentSet ] [ currentIndex ] = element ; currentIndex ++ ; } } currentSet ++ ; } } return sets ; } | Retrieve the sets as 2D - array of ints . |
28,527 | public void addAtom ( IAtom oAtom , IStrand oStrand ) { int atomCount = super . getAtomCount ( ) ; super . addAtom ( oAtom ) ; if ( atomCount != super . getAtomCount ( ) && oStrand != null ) { oStrand . addAtom ( oAtom ) ; if ( ! strands . containsKey ( oStrand . getStrandName ( ) ) ) { strands . put ( oStrand . getStrandName ( ) , oStrand ) ; } } } | Adds the atom oAtom to a specified Strand whereas the Monomer is unspecified . Hence the atom will be added to a Monomer of type UNKNOWN in the specified Strand . |
28,528 | public int getMonomerCount ( ) { Iterator < String > keys = strands . keySet ( ) . iterator ( ) ; int number = 0 ; if ( ! keys . hasNext ( ) ) return super . getMonomerCount ( ) ; while ( keys . hasNext ( ) ) { Strand tmp = ( Strand ) strands . get ( keys . next ( ) ) ; number += ( tmp . getMonomers ( ) ) . size ( ) - 1 ; } return number ; } | Returns the number of monomers present in BioPolymer . |
28,529 | public void removeStrand ( String name ) { if ( strands . containsKey ( name ) ) { Strand strand = ( Strand ) strands . get ( name ) ; this . remove ( strand ) ; strands . remove ( name ) ; } } | Removes a particular strand specified by its name . |
28,530 | public static IRenderingElement embedText ( Font font , String text , Color color , double scale ) { final String [ ] lines = text . split ( "\n" ) ; ElementGroup group = new ElementGroup ( ) ; double yOffset = 0 ; double lineHeight = 1.4d ; for ( String line : lines ) { TextOutline outline = new TextOutline ( line , font ) . resize ( scale , - scale ) ; Point2D center = outline . getCenter ( ) ; outline = outline . translate ( - center . getX ( ) , - ( center . getY ( ) + yOffset ) ) ; yOffset += lineHeight * outline . getBounds ( ) . getHeight ( ) ; group . add ( GeneralPath . shapeOf ( outline . getOutline ( ) , color ) ) ; Rectangle2D logicalBounds = outline . getLogicalBounds ( ) ; group . add ( new Bounds ( logicalBounds . getMinX ( ) , logicalBounds . getMinY ( ) , logicalBounds . getMaxX ( ) , logicalBounds . getMaxY ( ) ) ) ; } return group ; } | Make an embedded text label for display in a CDK renderer . If a piece of text contains newlines they are centred aligned below each other with a line height of 1 . 4 . |
28,531 | static Color getColorProperty ( IChemObject object , String key ) { Object value = object . getProperty ( key ) ; if ( value instanceof Color ) return ( Color ) value ; if ( value != null ) throw new IllegalArgumentException ( key + " property should be a java.awt.Color" ) ; return null ; } | Safely access a chem object color property for a chem object . |
28,532 | private static IRenderingElement recolor ( IRenderingElement element , Color color ) { if ( element instanceof ElementGroup ) { ElementGroup orgGroup = ( ElementGroup ) element ; ElementGroup newGroup = new ElementGroup ( ) ; for ( IRenderingElement child : orgGroup ) { newGroup . add ( recolor ( child , color ) ) ; } return newGroup ; } else if ( element instanceof LineElement ) { LineElement lineElement = ( LineElement ) element ; return new LineElement ( lineElement . firstPointX , lineElement . firstPointY , lineElement . secondPointX , lineElement . secondPointY , lineElement . width , color ) ; } else if ( element instanceof GeneralPath ) { return ( ( GeneralPath ) element ) . recolor ( color ) ; } throw new IllegalArgumentException ( "Cannot highlight rendering element, " + element . getClass ( ) ) ; } | Recolor a rendering element after it has been generated . Since rendering elements are immutable the input element remains unmodified . |
28,533 | static IRenderingElement outerGlow ( IRenderingElement element , Color color , double glowWidth , double stroke ) { if ( element instanceof ElementGroup ) { ElementGroup orgGroup = ( ElementGroup ) element ; ElementGroup newGroup = new ElementGroup ( ) ; for ( IRenderingElement child : orgGroup ) { newGroup . add ( outerGlow ( child , color , glowWidth , stroke ) ) ; } return newGroup ; } else if ( element instanceof LineElement ) { LineElement lineElement = ( LineElement ) element ; return new LineElement ( lineElement . firstPointX , lineElement . firstPointY , lineElement . secondPointX , lineElement . secondPointY , stroke + ( 2 * ( glowWidth * stroke ) ) , color ) ; } else if ( element instanceof GeneralPath ) { GeneralPath org = ( GeneralPath ) element ; if ( org . fill ) { return org . outline ( 2 * ( glowWidth * stroke ) ) . recolor ( color ) ; } else { return org . outline ( stroke + ( 2 * ( glowWidth * stroke ) ) ) . recolor ( color ) ; } } throw new IllegalArgumentException ( "Cannot generate glow for rendering element, " + element . getClass ( ) ) ; } | Generate an outer glow for the provided rendering element . The glow is defined by the glow width and the stroke size . |
28,534 | static boolean isPlainBond ( IBond bond ) { return bond . getOrder ( ) == IBond . Order . SINGLE && ( bond . getStereo ( ) == IBond . Stereo . NONE || bond . getStereo ( ) == null ) ; } | A plain bond is a non - stereo sigma bond that is displayed simply as a line . |
28,535 | static boolean isWedged ( IBond bond ) { return ( bond . getStereo ( ) == IBond . Stereo . UP || bond . getStereo ( ) == IBond . Stereo . DOWN || bond . getStereo ( ) == IBond . Stereo . UP_INVERTED || bond . getStereo ( ) == IBond . Stereo . DOWN_INVERTED ) ; } | A bond is wedge if it points up or down . |
28,536 | static void unhide ( IChemObject chemobj ) { chemobj . setProperty ( HIDDEN , false ) ; chemobj . setProperty ( HIDDEN_FULLY , false ) ; } | Unhide the specified chemobj . |
28,537 | public static double method1 ( ICountFingerprint fp1 , ICountFingerprint fp2 ) { long xy = 0 , x = 0 , y = 0 ; for ( int i = 0 ; i < fp1 . numOfPopulatedbins ( ) ; i ++ ) { int hash = fp1 . getHash ( i ) ; for ( int j = 0 ; j < fp2 . numOfPopulatedbins ( ) ; j ++ ) { if ( hash == fp2 . getHash ( j ) ) { xy += fp1 . getCount ( i ) * fp2 . getCount ( j ) ; } } x += fp1 . getCount ( i ) * fp1 . getCount ( i ) ; } for ( int j = 0 ; j < fp2 . numOfPopulatedbins ( ) ; j ++ ) { y += fp2 . getCount ( j ) * fp2 . getCount ( j ) ; } return ( ( double ) xy / ( x + y - xy ) ) ; } | Calculates Tanimoto distance for two count fingerprints using method 1 . |
28,538 | public static float calculate ( Map < String , Integer > features1 , Map < String , Integer > features2 ) { TreeSet < String > keys = new TreeSet < String > ( features1 . keySet ( ) ) ; keys . addAll ( features2 . keySet ( ) ) ; float sum = 0.0f ; for ( String key : keys ) { Integer c1 = features1 . get ( key ) ; Integer c2 = features2 . get ( key ) ; c1 = c1 == null ? 0 : c1 ; c2 = c2 == null ? 0 : c2 ; sum += 1.0 - Math . abs ( c1 - c2 ) / ( c1 + c2 ) ; } return sum / keys . size ( ) ; } | Evaluate the LINGO similarity between two key value sty ; e fingerprints . |
28,539 | public void setParameters ( Object [ ] params ) throws CDKException { if ( params . length > 2 ) throw new CDKException ( "ToleranceRangeRule expects only two parameter" ) ; if ( ! ( params [ 0 ] instanceof Double ) ) throw new CDKException ( "The parameter 0 must be of type Double" ) ; if ( ! ( params [ 1 ] instanceof Double ) ) throw new CDKException ( "The parameter 1 must be of type Double" ) ; mass = ( Double ) params [ 0 ] ; tolerance = ( Double ) params [ 1 ] ; } | Sets the parameters attribute of the ToleranceRangeRule object . |
28,540 | public Object [ ] getParameters ( ) { Object [ ] params = new Object [ 2 ] ; params [ 0 ] = mass ; params [ 1 ] = tolerance ; return params ; } | Gets the parameters attribute of the ToleranceRangeRule object . |
28,541 | public double validate ( IMolecularFormula formula ) throws CDKException { logger . info ( "Start validation of " , formula ) ; double totalExactMass = MolecularFormulaManipulator . getTotalExactMass ( formula ) ; if ( Math . abs ( totalExactMass - mass ) > tolerance ) return 0.0 ; else return 1.0 ; } | Validate the Tolerance Range of this IMolecularFormula . |
28,542 | public void addNode ( RNode newNode ) { graph . add ( newNode ) ; graphBitSet . set ( graph . size ( ) - 1 ) ; } | Adds a new node to the RGraph . |
28,543 | private void parseRec ( BitSet traversed , BitSet extension , BitSet forbidden ) { BitSet newTraversed = null ; BitSet newExtension = null ; BitSet newForbidden = null ; BitSet potentialNode = null ; if ( this . timeout > - 1 && ( System . currentTimeMillis ( ) - this . start ) > this . timeout ) { stop = true ; } if ( extension . isEmpty ( ) ) { solution ( traversed ) ; } else { potentialNode = ( ( BitSet ) graphBitSet . clone ( ) ) ; potentialNode . andNot ( forbidden ) ; potentialNode . or ( traversed ) ; if ( mustContinue ( potentialNode ) ) { nbIteration ++ ; for ( int x = extension . nextSetBit ( 0 ) ; x >= 0 && ! stop ; x = extension . nextSetBit ( x + 1 ) ) { newForbidden = ( BitSet ) forbidden . clone ( ) ; newForbidden . or ( ( ( RNode ) graph . get ( x ) ) . forbidden ) ; if ( traversed . isEmpty ( ) ) { newExtension = ( BitSet ) ( ( ( RNode ) graph . get ( x ) ) . extension . clone ( ) ) ; } else { newExtension = ( BitSet ) extension . clone ( ) ; newExtension . or ( ( ( RNode ) graph . get ( x ) ) . extension ) ; } newExtension . andNot ( newForbidden ) ; newTraversed = ( BitSet ) traversed . clone ( ) ; newTraversed . set ( x ) ; forbidden . set ( x ) ; parseRec ( newTraversed , newExtension , newForbidden ) ; } } } } | Parsing of the RGraph . This is the recursive method to perform a query . The method will recursively parse the RGraph thru connected nodes and visiting the RGraph using allowed adjacency relationship . |
28,544 | private BitSet buildB ( BitSet c1 , BitSet c2 ) { this . c1 = c1 ; this . c2 = c2 ; BitSet bs = new BitSet ( ) ; for ( Iterator < RNode > i = graph . iterator ( ) ; i . hasNext ( ) ; ) { RNode rn = i . next ( ) ; if ( ( c1 . get ( rn . rMap . id1 ) || c1 . isEmpty ( ) ) && ( c2 . get ( rn . rMap . id2 ) || c2 . isEmpty ( ) ) ) { bs . set ( graph . indexOf ( rn ) ) ; } } return bs ; } | Builds the initial extension set . This is the set of node that may be used as seed for the RGraph parsing . This set depends on the constrains defined by the user . |
28,545 | public BitSet projectG1 ( BitSet set ) { BitSet projection = new BitSet ( firstGraphSize ) ; RNode xNode = null ; for ( int x = set . nextSetBit ( 0 ) ; x >= 0 ; x = set . nextSetBit ( x + 1 ) ) { xNode = ( RNode ) graph . get ( x ) ; projection . set ( xNode . rMap . id1 ) ; } return projection ; } | Projects a RGraph bitset on the source graph G1 . |
28,546 | public BitSet projectG2 ( BitSet set ) { BitSet projection = new BitSet ( secondGraphSize ) ; RNode xNode = null ; for ( int x = set . nextSetBit ( 0 ) ; x >= 0 ; x = set . nextSetBit ( x + 1 ) ) { xNode = ( RNode ) graph . get ( x ) ; projection . set ( xNode . rMap . id2 ) ; } return projection ; } | Projects a RGraph bitset on the source graph G2 . |
28,547 | private boolean isContainedIn ( BitSet A , BitSet B ) { boolean result = false ; if ( A . isEmpty ( ) ) { return true ; } BitSet setA = ( BitSet ) A . clone ( ) ; setA . and ( B ) ; if ( setA . equals ( A ) ) { result = true ; } return result ; } | Test if set A is contained in set B . |
28,548 | private static int electronsForAtomType ( IAtom atom ) { Integer electrons = TYPES . get ( atom . getAtomTypeName ( ) ) ; if ( electrons != null ) return electrons ; try { IAtomType atomType = AtomTypeFactory . getInstance ( "org/openscience/cdk/dict/data/cdk-atom-types.owl" , atom . getBuilder ( ) ) . getAtomType ( atom . getAtomTypeName ( ) ) ; electrons = atomType . getProperty ( CDKConstants . PI_BOND_COUNT ) ; return electrons != null ? electrons : 0 ; } catch ( NoSuchAtomTypeException e ) { throw new IllegalArgumentException ( e ) ; } } | The number of contributed electrons for the atom type of the specified atom type . |
28,549 | public static IBitFingerprint makeBitFingerprint ( final Map < String , Integer > features , int len ) { return makeBitFingerprint ( features , len , 1 ) ; } | Convert a mapping of features and their counts to a binary fingerprint . A single bit is set for each pattern . |
28,550 | private boolean matchAtoms ( Match match ) { IAtom atom = match . getTargetAtom ( ) ; if ( match . getQueryNode ( ) . countNeighbors ( ) > target . countNeighbors ( atom ) ) { return false ; } return match . getQueryNode ( ) . getAtomMatcher ( ) . matches ( target , atom ) ; } | This function is updated by Asad to include more matches |
28,551 | public static int [ ] [ ] getMatrix ( IAtomContainer container ) { int [ ] [ ] conMat = AdjacencyMatrix . getMatrix ( container ) ; int [ ] [ ] topolDistance = PathTools . computeFloydAPSP ( conMat ) ; return topolDistance ; } | Returns the topological matrix for the given AtomContainer . |
28,552 | public void placeHydrogens2D ( final IAtomContainer container , final double bondLength ) { logger . debug ( "placing hydrogens on all atoms" ) ; for ( IAtom atom : container . atoms ( ) ) { if ( atom . getPoint2d ( ) != null ) { placeHydrogens2D ( container , atom , bondLength ) ; } } logger . debug ( "hydrogen placement complete" ) ; } | Place all hydrogens connected to atoms which have already been laid out . |
28,553 | public void placeHydrogens2D ( IAtomContainer container , IAtom atom ) { double bondLength = GeometryUtil . getBondLengthAverage ( container ) ; placeHydrogens2D ( container , atom , bondLength ) ; } | Place hydrogens connected to the given atom using the average bond length in the container . |
28,554 | private static boolean getSystemProp ( final String key , final boolean defaultValue ) { String val = System . getProperty ( key ) ; if ( val == null ) val = System . getenv ( key ) ; if ( val == null ) { return defaultValue ; } else if ( val . isEmpty ( ) ) { return true ; } else { switch ( val . toLowerCase ( Locale . ROOT ) ) { case "t" : case "true" : case "1" : return true ; case "f" : case "false" : case "0" : return false ; default : throw new IllegalArgumentException ( "Invalid value, expected true/false: " + val ) ; } } } | an error rather than return false . The default can also be specified . |
28,555 | public static String getDuration ( long diff ) { GregorianCalendar calendar = new GregorianCalendar ( ) ; calendar . setTime ( new Date ( diff ) ) ; StringBuffer s = new StringBuffer ( ) ; if ( calendar . get ( Calendar . HOUR ) > 1 ) { s . append ( "hours: " + ( calendar . get ( Calendar . HOUR ) - 1 ) + ", " ) ; } if ( calendar . get ( Calendar . MINUTE ) > 0 ) { s . append ( "minutes: " + ( calendar . get ( Calendar . MINUTE ) ) + ", " ) ; } if ( calendar . get ( Calendar . SECOND ) > 0 ) { s . append ( "seconds: " + ( calendar . get ( Calendar . SECOND ) ) + ", " ) ; } if ( calendar . get ( Calendar . MILLISECOND ) > 1 ) { s . append ( "milliseconds: " + ( calendar . get ( Calendar . MILLISECOND ) ) + ", " ) ; } s . append ( "total milliseconds: " + diff ) ; return s . toString ( ) ; } | Returns a String reporting the time passed during a given number of milliseconds . |
28,556 | public static String printInt2D ( int [ ] [ ] contab ) { String line = "" ; for ( int f = 0 ; f < contab . length ; f ++ ) { for ( int g = 0 ; g < contab . length ; g ++ ) { line += contab [ f ] [ g ] + " " ; } line += "\n" ; } return line ; } | Returns a string representation of a 2D int matrix for printing or listing to the console . |
28,557 | static Vector2d newUnitVector ( final Tuple2d from , final Tuple2d to ) { final Vector2d vector = new Vector2d ( to . x - from . x , to . y - from . y ) ; vector . normalize ( ) ; return vector ; } | Create a unit vector between two points . |
28,558 | static Vector2d newUnitVector ( final IAtom atom , final IBond bond ) { return newUnitVector ( atom . getPoint2d ( ) , bond . getOther ( atom ) . getPoint2d ( ) ) ; } | Create a unit vector for a bond with the start point being the specified atom . |
28,559 | static List < Vector2d > newUnitVectors ( final IAtom fromAtom , final List < IAtom > toAtoms ) { final List < Vector2d > unitVectors = new ArrayList < Vector2d > ( toAtoms . size ( ) ) ; for ( final IAtom toAtom : toAtoms ) { unitVectors . add ( newUnitVector ( fromAtom . getPoint2d ( ) , toAtom . getPoint2d ( ) ) ) ; } return unitVectors ; } | Create unit vectors from one atom to all other provided atoms . |
28,560 | static Point2d midpoint ( Point2d a , Point2d b ) { return new Point2d ( ( a . x + b . x ) / 2 , ( a . y + b . y ) / 2 ) ; } | Midpoint of a line described by two points a and b . |
28,561 | static Vector2d scale ( final Tuple2d vector , final double factor ) { final Vector2d cpy = new Vector2d ( vector ) ; cpy . scale ( factor ) ; return cpy ; } | Scale a vector by a given factor the input vector is not modified . |
28,562 | static Vector2d sum ( final Tuple2d a , final Tuple2d b ) { return new Vector2d ( a . x + b . x , a . y + b . y ) ; } | Sum the components of two vectors the input is not modified . |
28,563 | static Point2d intersection ( final Tuple2d p1 , final Tuple2d d1 , final Tuple2d p2 , final Tuple2d d2 ) { final Vector2d p1End = sum ( p1 , d1 ) ; final Vector2d p2End = sum ( p2 , d2 ) ; return intersection ( p1 . x , p1 . y , p1End . x , p1End . y , p2 . x , p2 . y , p2End . x , p2End . y ) ; } | Calculate the intersection of two vectors given their starting positions . |
28,564 | static double adjacentLength ( Vector2d hypotenuse , Vector2d adjacent , double oppositeLength ) { return Math . tan ( hypotenuse . angle ( adjacent ) ) * oppositeLength ; } | Given vectors for the hypotenuse and adjacent side of a right angled triangle and the length of the opposite side determine how long the adjacent side size . |
28,565 | static Vector2d average ( final Collection < Vector2d > vectors ) { final Vector2d average = new Vector2d ( 0 , 0 ) ; for ( final Vector2d vector : vectors ) { average . add ( vector ) ; } average . scale ( 1d / vectors . size ( ) ) ; return average ; } | Average a collection of vectors . |
28,566 | static Vector2d getNearestVector ( final Vector2d reference , final List < Vector2d > vectors ) { if ( vectors . isEmpty ( ) ) throw new IllegalArgumentException ( "No vectors provided" ) ; Vector2d closest = vectors . get ( 0 ) ; double maxProd = reference . dot ( closest ) ; for ( int i = 1 ; i < vectors . size ( ) ; i ++ ) { double newProd = reference . dot ( vectors . get ( i ) ) ; if ( newProd > maxProd ) { maxProd = newProd ; closest = vectors . get ( i ) ; } } return closest ; } | Given a list of unit vectors find the vector which is nearest to a provided reference . |
28,567 | static Vector2d getNearestVector ( Vector2d reference , IAtom fromAtom , List < IBond > bonds ) { final List < IAtom > toAtoms = new ArrayList < IAtom > ( ) ; for ( IBond bond : bonds ) { toAtoms . add ( bond . getOther ( fromAtom ) ) ; } return getNearestVector ( reference , newUnitVectors ( fromAtom , toAtoms ) ) ; } | Given a list of bonds find the bond which is nearest to a provided reference and return the vector for this bond . |
28,568 | static double [ ] extents ( final List < Vector2d > vectors ) { final int n = vectors . size ( ) ; final double [ ] extents = new double [ n ] ; for ( int i = 0 ; i < n ; i ++ ) extents [ i ] = VecmathUtil . extent ( vectors . get ( i ) ) ; return extents ; } | Obtain the extents for a list of vectors . |
28,569 | public boolean compare ( Object object ) { if ( ! ( object instanceof IAtomType ) ) { return false ; } if ( ! super . compare ( object ) ) { return false ; } AtomType type = ( AtomType ) object ; return Objects . equal ( getAtomTypeName ( ) , type . getAtomTypeName ( ) ) && Objects . equal ( maxBondOrder , type . maxBondOrder ) && Objects . equal ( bondOrderSum , type . bondOrderSum ) ; } | Compares a atom type with this atom type . |
28,570 | public IMolecularFormula add ( IMolecularFormula formula ) { for ( IIsotope newIsotope : formula . isotopes ( ) ) { addIsotope ( newIsotope , formula . getIsotopeCount ( newIsotope ) ) ; } if ( formula . getCharge ( ) != null ) { if ( charge != null ) charge += formula . getCharge ( ) ; else charge = formula . getCharge ( ) ; } return this ; } | Adds an molecularFormula to this MolecularFormula . |
28,571 | final void add ( final Cycle cycle ) { basis . add ( cycle ) ; edgesOfBasis . or ( cycle . edgeVector ( ) ) ; } | Add a cycle to the basis . |
28,572 | public static long [ ] getMorganNumbers ( IAtomContainer molecule ) { int order = molecule . getAtomCount ( ) ; long [ ] currentInvariants = new long [ order ] ; long [ ] previousInvariants = new long [ order ] ; int [ ] [ ] graph = new int [ order ] [ INITIAL_DEGREE ] ; int [ ] degree = new int [ order ] ; int [ ] nonHydrogens = new int [ order ] ; for ( int v = 0 ; v < order ; v ++ ) nonHydrogens [ v ] = "H" . equals ( molecule . getAtom ( v ) . getSymbol ( ) ) ? 0 : 1 ; for ( IBond bond : molecule . bonds ( ) ) { int u = molecule . indexOf ( bond . getBegin ( ) ) ; int v = molecule . indexOf ( bond . getEnd ( ) ) ; graph [ u ] = Ints . ensureCapacity ( graph [ u ] , degree [ u ] + 1 , INITIAL_DEGREE ) ; graph [ v ] = Ints . ensureCapacity ( graph [ v ] , degree [ v ] + 1 , INITIAL_DEGREE ) ; graph [ u ] [ degree [ u ] ++ ] = v ; graph [ v ] [ degree [ v ] ++ ] = u ; currentInvariants [ u ] += nonHydrogens [ v ] ; currentInvariants [ v ] += nonHydrogens [ u ] ; } for ( int i = 0 ; i < order ; i ++ ) { System . arraycopy ( currentInvariants , 0 , previousInvariants , 0 , order ) ; for ( int u = 0 ; u < order ; u ++ ) { currentInvariants [ u ] = 0 ; int [ ] neighbors = graph [ u ] ; for ( int j = 0 ; j < degree [ u ] ; j ++ ) { int v = neighbors [ j ] ; currentInvariants [ u ] += previousInvariants [ v ] * nonHydrogens [ v ] ; } } } return currentInvariants ; } | Makes an array containing the morgan numbers of the atoms of atomContainer . These number are the extended connectivity values and not the lexicographic smallest labelling on the graph . |
28,573 | public static List < Map < IBond , IBond > > makeBondMapsOfAtomMaps ( IAtomContainer ac1 , IAtomContainer ac2 , List < Map < IAtom , IAtom > > mappings ) { List < Map < IBond , IBond > > bondMaps = new ArrayList < Map < IBond , IBond > > ( ) ; for ( Map < IAtom , IAtom > mapping : mappings ) { bondMaps . add ( makeBondMapOfAtomMap ( ac1 , ac2 , mapping ) ) ; } return bondMaps ; } | Returns bond maps between source and target molecules based on the atoms |
28,574 | public void init ( String sourceMolFileName , String targetMolFileName , boolean removeHydrogen , boolean cleanAndConfigureMolecule ) throws CDKException { this . removeHydrogen = removeHydrogen ; init ( new MolHandler ( sourceMolFileName , cleanAndConfigureMolecule , removeHydrogen ) , new MolHandler ( targetMolFileName , cleanAndConfigureMolecule , removeHydrogen ) ) ; } | Initialize the query and targetAtomCount mol via mol files |
28,575 | final SMARTSAtomInvariants invariants ( final IAtom atom ) { final SMARTSAtomInvariants inv = atom . getProperty ( SMARTSAtomInvariants . KEY ) ; if ( inv == null ) throw new NullPointerException ( "Missing SMARTSAtomInvariants - please compute these values before matching." ) ; return inv ; } | Access the atom invariants for this atom . If the invariants have not been set an exception is thrown . |
28,576 | public void write ( IChemObject object ) throws UnsupportedChemObjectException { if ( object instanceof ICrystal ) { writeCrystal ( ( ICrystal ) object ) ; } else if ( object instanceof IChemSequence ) { writeChemSequence ( ( IChemSequence ) object ) ; } else { throw new UnsupportedChemObjectException ( "This object type is not supported." ) ; } } | Serializes the IChemObject to CrystClust format and redirects it to the output Writer . |
28,577 | private void writeCrystal ( ICrystal crystal ) { String sg = crystal . getSpaceGroup ( ) ; if ( "P 2_1 2_1 2_1" . equals ( sg ) ) { writeln ( "P 21 21 21 (1)" ) ; } else { writeln ( "P 1 (1)" ) ; } writeVector3d ( crystal . getA ( ) ) ; writeVector3d ( crystal . getB ( ) ) ; writeVector3d ( crystal . getC ( ) ) ; int noatoms = crystal . getAtomCount ( ) ; write ( Integer . toString ( noatoms ) ) ; writeln ( "" ) ; if ( sg . equals ( "P1" ) ) { writeln ( "1" ) ; } else { writeln ( "1" ) ; } for ( int i = 0 ; i < noatoms ; i ++ ) { IAtom atom = crystal . getAtom ( i ) ; write ( atom . getSymbol ( ) ) ; write ( ":" ) ; writeln ( Double . toString ( atom . getCharge ( ) ) ) ; writeln ( Double . toString ( atom . getPoint3d ( ) . x ) ) ; writeln ( Double . toString ( atom . getPoint3d ( ) . y ) ) ; writeln ( Double . toString ( atom . getPoint3d ( ) . z ) ) ; } } | Writes a single frame to the Writer . |
28,578 | public GeneralPath recolor ( Color newColor ) { return new GeneralPath ( elements , newColor , winding , stroke , fill ) ; } | Recolor the path with the specified color . |
28,579 | public static GeneralPath shapeOf ( Shape shape , Color color ) { List < PathElement > elements = new ArrayList < PathElement > ( ) ; PathIterator pathIt = shape . getPathIterator ( new AffineTransform ( ) ) ; double [ ] data = new double [ 6 ] ; while ( ! pathIt . isDone ( ) ) { switch ( pathIt . currentSegment ( data ) ) { case PathIterator . SEG_MOVETO : elements . add ( new MoveTo ( data ) ) ; break ; case PathIterator . SEG_LINETO : elements . add ( new LineTo ( data ) ) ; break ; case PathIterator . SEG_CLOSE : elements . add ( new Close ( ) ) ; break ; case PathIterator . SEG_QUADTO : elements . add ( new QuadTo ( data ) ) ; break ; case PathIterator . SEG_CUBICTO : elements . add ( new CubicTo ( data ) ) ; break ; } pathIt . next ( ) ; } return new GeneralPath ( elements , color , pathIt . getWindingRule ( ) , 0d , true ) ; } | Create a filled path of the specified Java 2D Shape and color . |
28,580 | long [ ] combine ( long [ ] [ ] perturbed ) { int n = perturbed . length ; int m = perturbed [ 0 ] . length ; long [ ] combined = new long [ n ] ; long [ ] rotated = new long [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { Arrays . sort ( perturbed [ i ] ) ; for ( int j = 0 ; j < m ; j ++ ) { if ( j > 0 && perturbed [ i ] [ j ] == perturbed [ i ] [ j - 1 ] ) { combined [ i ] ^= rotated [ j ] = rotate ( rotated [ j - 1 ] ) ; } else { combined [ i ] ^= rotated [ j ] = perturbed [ i ] [ j ] ; } } } return combined ; } | Combines the values in an n x m matrix into a single array of size n . This process scans the rows and xors all unique values in the row together . If a duplicate value is found it is rotated using a pseudorandom number generator . |
28,581 | protected IRingSet getRingSet ( IAtomContainer atomContainer ) { IRingSet ringSet = atomContainer . getBuilder ( ) . newInstance ( IRingSet . class ) ; try { IAtomContainerSet molecules = ConnectivityChecker . partitionIntoMolecules ( atomContainer ) ; for ( IAtomContainer mol : molecules . atomContainers ( ) ) { ringSet . add ( Cycles . sssr ( mol ) . toRingSet ( ) ) ; } return ringSet ; } catch ( Exception exception ) { logger . warn ( "Could not partition molecule: " + exception . getMessage ( ) ) ; logger . debug ( exception ) ; return ringSet ; } } | Determine the ring set for this atom container . |
28,582 | public Color getColorForBond ( IBond bond , RendererModel model ) { if ( this . overrideColor != null ) { return overrideColor ; } Color color = model . getParameter ( ColorHash . class ) . getValue ( ) . get ( bond ) ; if ( color == null ) { return model . getParameter ( DefaultBondColor . class ) . getValue ( ) ; } else { return color ; } } | Determine the color of a bond returning either the default color the override color or whatever is in the color hash for that bond . |
28,583 | public double getWidthForBond ( IBond bond , RendererModel model ) { double scale = model . getParameter ( Scale . class ) . getValue ( ) ; if ( this . overrideBondWidth != - 1 ) { return this . overrideBondWidth / scale ; } else { return model . getParameter ( BondWidth . class ) . getValue ( ) / scale ; } } | Determine the width of a bond returning either the width defined in the model or the override width . Note that this will be scaled to the space of the model . |
28,584 | public IRenderingElement generateBondElement ( IBond bond , IBond . Order type , RendererModel model ) { if ( bond . getAtomCount ( ) > 2 ) return null ; Point2d point1 = bond . getBegin ( ) . getPoint2d ( ) ; Point2d point2 = bond . getEnd ( ) . getPoint2d ( ) ; Color color = this . getColorForBond ( bond , model ) ; double bondWidth = this . getWidthForBond ( bond , model ) ; double bondDistance = ( Double ) model . get ( BondDistance . class ) / model . getParameter ( Scale . class ) . getValue ( ) ; if ( type == IBond . Order . SINGLE ) { return new LineElement ( point1 . x , point1 . y , point2 . x , point2 . y , bondWidth , color ) ; } else { ElementGroup group = new ElementGroup ( ) ; switch ( type ) { case DOUBLE : createLines ( point1 , point2 , bondWidth , bondDistance , color , group ) ; break ; case TRIPLE : createLines ( point1 , point2 , bondWidth , bondDistance * 2 , color , group ) ; group . add ( new LineElement ( point1 . x , point1 . y , point2 . x , point2 . y , bondWidth , color ) ) ; break ; case QUADRUPLE : createLines ( point1 , point2 , bondWidth , bondDistance , color , group ) ; createLines ( point1 , point2 , bondWidth , bondDistance * 4 , color , group ) ; default : break ; } return group ; } } | Generate a LineElement or an ElementGroup of LineElements for this bond . This version should be used if you want to override the type - for example for ring double bonds . |
28,585 | public IRenderingElement generateRingElements ( IBond bond , IRing ring , RendererModel model ) { if ( isSingle ( bond ) && isStereoBond ( bond ) ) { return generateStereoElement ( bond , model ) ; } else if ( isDouble ( bond ) ) { ElementGroup pair = new ElementGroup ( ) ; pair . add ( generateBondElement ( bond , IBond . Order . SINGLE , model ) ) ; pair . add ( generateInnerElement ( bond , ring , model ) ) ; return pair ; } else { return generateBondElement ( bond , model ) ; } } | Generate ring elements such as inner - ring bonds or ring stereo elements . |
28,586 | public LineElement generateInnerElement ( IBond bond , IRing ring , RendererModel model ) { Point2d center = GeometryUtil . get2DCenter ( ring ) ; Point2d a = bond . getBegin ( ) . getPoint2d ( ) ; Point2d b = bond . getEnd ( ) . getPoint2d ( ) ; double distanceFactor = model . getParameter ( TowardsRingCenterProportion . class ) . getValue ( ) ; double ringDistance = distanceFactor * IDEAL_RINGSIZE / ring . getAtomCount ( ) ; if ( ringDistance < distanceFactor / MIN_RINGSIZE_FACTOR ) ringDistance = distanceFactor / MIN_RINGSIZE_FACTOR ; Point2d w = new Point2d ( ) ; w . interpolate ( a , center , ringDistance ) ; Point2d u = new Point2d ( ) ; u . interpolate ( b , center , ringDistance ) ; double alpha = 0.2 ; Point2d ww = new Point2d ( ) ; ww . interpolate ( w , u , alpha ) ; Point2d uu = new Point2d ( ) ; uu . interpolate ( u , w , alpha ) ; double width = getWidthForBond ( bond , model ) ; Color color = getColorForBond ( bond , model ) ; return new LineElement ( u . x , u . y , w . x , w . y , width , color ) ; } | Make the inner ring bond which is slightly shorter than the outer bond . |
28,587 | private boolean isStereoBond ( IBond bond ) { return bond . getStereo ( ) != IBond . Stereo . NONE && bond . getStereo ( ) != ( IBond . Stereo ) CDKConstants . UNSET && bond . getStereo ( ) != IBond . Stereo . E_Z_BY_COORDINATES ; } | Check to see if a bond is a stereo bond . |
28,588 | protected boolean bindsHydrogen ( IBond bond ) { for ( int i = 0 ; i < bond . getAtomCount ( ) ; i ++ ) { IAtom atom = bond . getAtom ( i ) ; if ( "H" . equals ( atom . getSymbol ( ) ) ) return true ; } return false ; } | Check to see if any of the atoms in this bond are hydrogen atoms . |
28,589 | public IRenderingElement generateBond ( IBond bond , RendererModel model ) { boolean showExplicitHydrogens = true ; if ( model . hasParameter ( BasicAtomGenerator . ShowExplicitHydrogens . class ) ) { showExplicitHydrogens = model . getParameter ( BasicAtomGenerator . ShowExplicitHydrogens . class ) . getValue ( ) ; } if ( ! showExplicitHydrogens && bindsHydrogen ( bond ) ) { return null ; } if ( isStereoBond ( bond ) ) { return generateStereoElement ( bond , model ) ; } else { return generateBondElement ( bond , model ) ; } } | Generate stereo or bond elements for this bond . |
28,590 | public static IMolecularFormula getMaxOccurrenceElements ( IMolecularFormulaSet mfSet ) { IMolecularFormula molecularFormula = mfSet . getBuilder ( ) . newInstance ( IMolecularFormula . class ) ; for ( IMolecularFormula mf : mfSet . molecularFormulas ( ) ) { for ( IIsotope isotope : mf . isotopes ( ) ) { IElement element = mfSet . getBuilder ( ) . newInstance ( IElement . class , isotope ) ; int occur_new = MolecularFormulaManipulator . getElementCount ( mf , element ) ; if ( ! MolecularFormulaManipulator . containsElement ( molecularFormula , element ) ) { molecularFormula . addIsotope ( mfSet . getBuilder ( ) . newInstance ( IIsotope . class , element ) , occur_new ) ; } else { int occur_old = MolecularFormulaManipulator . getElementCount ( molecularFormula , element ) ; if ( occur_new > occur_old ) { MolecularFormulaManipulator . removeElement ( molecularFormula , element ) ; molecularFormula . addIsotope ( mfSet . getBuilder ( ) . newInstance ( IIsotope . class , element ) , occur_new ) ; } } } } return molecularFormula ; } | Extract from a set of MolecularFormula the maximum occurrence of each element found and put the element and occurrence in a new IMolecularFormula . |
28,591 | private static boolean validCorrelation ( IMolecularFormula formulaMin , IMolecularFormula formulamax ) { for ( IElement element : MolecularFormulaManipulator . elements ( formulaMin ) ) { if ( ! MolecularFormulaManipulator . containsElement ( formulamax , element ) ) return false ; } return true ; } | In the minimal IMolecularFormula must contain all those IElement found in the minimal IMolecularFormula . |
28,592 | public static boolean contains ( IMolecularFormulaSet formulaSet , IMolecularFormula formula ) { for ( IMolecularFormula fm : formulaSet . molecularFormulas ( ) ) { if ( MolecularFormulaManipulator . compare ( fm , formula ) ) { return true ; } } return false ; } | True if the IMolecularFormulaSet contains the given IMolecularFormula but not as object . It compare according contains the same number and type of Isotopes . It is not based on compare objects . |
28,593 | private void sort ( Matrix C , Vector E ) { int i , j ; double value ; boolean changed ; do { changed = false ; for ( i = 1 ; i < E . size ; i ++ ) if ( E . vector [ i - 1 ] > E . vector [ i ] ) { value = E . vector [ i ] ; E . vector [ i ] = E . vector [ i - 1 ] ; E . vector [ i - 1 ] = value ; for ( j = 0 ; j < C . rows ; j ++ ) { value = C . matrix [ j ] [ i ] ; C . matrix [ j ] [ i ] = C . matrix [ j ] [ i - 1 ] ; C . matrix [ j ] [ i - 1 ] = value ; } changed = true ; } } while ( changed ) ; } | Sorts the orbitals by their energies |
28,594 | private Matrix calculateT ( IBasis basis ) { int size = basis . getSize ( ) ; Matrix J = new Matrix ( size , size ) ; int i , j ; for ( i = 0 ; i < size ; i ++ ) for ( j = 0 ; j < size ; j ++ ) J . matrix [ i ] [ j ] = basis . calcJ ( j , i ) / 2 ; return J ; } | Calculates the matrix for the kinetic energy |
28,595 | private Matrix calculateV ( IBasis basis ) { int size = basis . getSize ( ) ; Matrix V = new Matrix ( size , size ) ; int i , j ; for ( i = 0 ; i < size ; i ++ ) for ( j = 0 ; j < size ; j ++ ) V . matrix [ i ] [ j ] = basis . calcV ( i , j ) ; return V ; } | Calculates the matrix for the potential matrix |
28,596 | public void addChemSequence ( IChemSequence chemSequence ) { if ( chemSequenceCount + 1 >= chemSequences . length ) { growChemSequenceArray ( ) ; } chemSequences [ chemSequenceCount ] = chemSequence ; chemSequenceCount ++ ; } | Adds a ChemSequence to this container . |
28,597 | public IAtomContainer containerFromPermutation ( int [ ] permutation ) { try { IAtomContainer permutedContainer = ( IAtomContainer ) atomContainer . clone ( ) ; IAtom [ ] atoms = new IAtom [ atomContainer . getAtomCount ( ) ] ; for ( int i = 0 ; i < atomContainer . getAtomCount ( ) ; i ++ ) { atoms [ permutation [ i ] ] = permutedContainer . getAtom ( i ) ; } permutedContainer . setAtoms ( atoms ) ; return permutedContainer ; } catch ( CloneNotSupportedException c ) { return null ; } } | Generate the atom container with this permutation of the atoms . |
28,598 | public void readSGroup ( IAtomContainer readData ) throws CDKException { boolean foundEND = false ; while ( isReady ( ) && ! foundEND ) { String command = readCommand ( readLine ( ) ) ; if ( "END SGROUP" . equals ( command ) ) { foundEND = true ; } else { logger . debug ( "Parsing Sgroup line: " + command ) ; StringTokenizer tokenizer = new StringTokenizer ( command ) ; String indexString = tokenizer . nextToken ( ) ; logger . warn ( "Skipping external index: " + indexString ) ; String type = tokenizer . nextToken ( ) ; String externalIndexString = tokenizer . nextToken ( ) ; logger . warn ( "Skipping external index: " + externalIndexString ) ; Map < String , String > options = new Hashtable < String , String > ( ) ; if ( command . indexOf ( '=' ) != - 1 ) { options = parseOptions ( exhaustStringTokenizer ( tokenizer ) ) ; } if ( type . startsWith ( "SUP" ) ) { Iterator < String > keys = options . keySet ( ) . iterator ( ) ; int atomID = - 1 ; String label = "" ; while ( keys . hasNext ( ) ) { String key = keys . next ( ) ; String value = options . get ( key ) ; try { if ( key . equals ( "ATOMS" ) ) { StringTokenizer atomsTokenizer = new StringTokenizer ( value ) ; Integer . parseInt ( atomsTokenizer . nextToken ( ) ) ; atomID = Integer . parseInt ( atomsTokenizer . nextToken ( ) ) ; } else if ( key . equals ( "LABEL" ) ) { label = value ; } else { logger . warn ( "Not parsing key: " + key ) ; } } catch ( Exception exception ) { String error = "Error while parsing key/value " + key + "=" + value + ": " + exception . getMessage ( ) ; logger . error ( error ) ; logger . debug ( exception ) ; throw new CDKException ( error , exception ) ; } if ( atomID != - 1 && label . length ( ) > 0 ) { IAtom original = readData . getAtom ( atomID - 1 ) ; IAtom replacement = original ; if ( ! ( original instanceof IPseudoAtom ) ) { replacement = readData . getBuilder ( ) . newInstance ( IPseudoAtom . class , original ) ; } ( ( IPseudoAtom ) replacement ) . setLabel ( label ) ; if ( ! replacement . equals ( original ) ) AtomContainerManipulator . replaceAtomByAtom ( readData , original , replacement ) ; } } } else { logger . warn ( "Skipping unrecognized SGROUP type: " + type ) ; } } } } | Reads labels . |
28,599 | private String readCommand ( String line ) throws CDKException { if ( line . startsWith ( "M V30 " ) ) { String command = line . substring ( 7 ) ; if ( command . endsWith ( "-" ) ) { command = command . substring ( 0 , command . length ( ) - 1 ) ; command += readCommand ( readLine ( ) ) ; } return command ; } else { throw new CDKException ( "Could not read MDL file: unexpected line: " + line ) ; } } | Reads the command on this line . If the line is continued on the next that part is added . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.