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 ...
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 . ...
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 ] ; f...
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 = co...
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 . ...
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 . HYD...
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 . setImplicitHydrogen...
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 ; }...
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 . setC...
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 ...
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 ( ) ; atom...
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 ( ) ...
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 ] = fo...
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...
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 . getStr...
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 ( ) - ...
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 , f...
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 ) ) ; } ...
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 ( out...
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 . get...
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 ) ; Integ...
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...
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 (...
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...
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 ( at...
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 placem...
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 ...
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...
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 ( ) ) ) ;...
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 ( ) ;...
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 . maxBo...
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 . getCharg...
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 [ ] non...
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 ( makeBond...
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 ( targetMolFileNa...
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 ty...
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 n...
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...
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 ] [...
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 ( ) ) { ringS...
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 ( ) ; } e...
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 ) ; ...
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 , IBo...
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 ( TowardsRingCenterProportio...
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 ( ) ; } ...
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 eleme...
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 . r...
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 ] ...
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 ) ; StringTok...
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 { t...
Reads the command on this line . If the line is continued on the next that part is added .