/// <summary> /// Get all combinatorial chemical isotopes given a structure. /// </summary> /// <param name="molFor">The IMolecularFormula to start</param> /// <returns>A IsotopePattern object containing the different combinations</returns> public IsotopePattern GetIsotopes(IMolecularFormula molFor) { if (builder == null) { try { isoFactory = CDK.IsotopeFactory; builder = molFor.Builder; } catch (Exception e) { Console.WriteLine(e.StackTrace); } } var mf = MolecularFormulaManipulator.GetString(molFor, true); var molecularFormula = MolecularFormulaManipulator.GetMajorIsotopeMolecularFormula(mf, builder); IsotopePattern abundance_Mass = null; foreach (var isos in molecularFormula.Isotopes) { var elementSymbol = isos.Symbol; var atomCount = molecularFormula.GetCount(isos); // Generate possible isotope containers for the current atom's // these will then me 'multiplied' with the existing patten var additional = new List <IsotopeContainer>(); foreach (var isotope in isoFactory.GetIsotopes(elementSymbol)) { double mass = isotope.ExactMass.Value; double abundance = isotope.Abundance.Value; if (abundance <= 0.000000001) { continue; } IsotopeContainer container = new IsotopeContainer(mass, abundance); if (storeFormula) { container.Formula = AsFormula(isotope); } additional.Add(container); } for (int i = 0; i < atomCount; i++) { abundance_Mass = CalculateAbundanceAndMass(abundance_Mass, additional); } } var isoP = IsotopePatternManipulator.SortAndNormalizedByIntensity(abundance_Mass); isoP = CleanAbundance(isoP, minIntensity); var isoPattern = IsotopePatternManipulator.SortByMass(isoP); return(isoPattern); }
public MolecularFormulaCheckerTest() : base() { try { ifac = BODRIsotopeFactory.Instance; } catch (IOException e) { Console.Error.WriteLine(e.StackTrace); } }
public static void Main(string[] args) { { #region IsotopeFactory f = XMLIsotopeFactory.Instance; ChemicalElement e1 = f.GetElement("C"); ChemicalElement e2 = f.GetElement(12); #endregion } { #region AtomicNumber IAtom element = new Atom("C"); IsotopeFactory f = XMLIsotopeFactory.Instance; f.Configure(element); #endregion } }
/// <summary> /// Get the major isotope mass number for an element /// </summary> /// <param name="atomicNumber"></param> /// <returns></returns> public static int GetMajorIsotopeMassNumber(int atomicNumber) { int mass = 0; IsotopeFactory factory = XMLIsotopeFactory.Instance; IIsotope major = factory.GetMajorIsotope(atomicNumber); if (major.MassNumber != null) { return((int)major.MassNumber); } else { return(0); } }
/// <summary> Method that saturates an atom in a molecule by adding explicit hydrogens. /// /// </summary> /// <param name="atom"> Atom to saturate /// </param> /// <param name="container">AtomContainer containing the atom /// </param> /// <param name="count"> Number of hydrogens to add /// </param> /// <param name="totalContainer">In case you have a container containing multiple structures, this is the total container, whereas container is a partial structure /// /// </param> /// <cdk.keyword> hydrogen, adding </cdk.keyword> /// <cdk.keyword> explicit hydrogen </cdk.keyword> public virtual IAtomContainer addExplicitHydrogensToSatisfyValency(IAtomContainer container, IAtom atom, int count, IAtomContainer totalContainer) { //boolean create2DCoordinates = GeometryTools.has2DCoordinates(container); IIsotope isotope = IsotopeFactory.getInstance(container.Builder).getMajorIsotope("H"); atom.setHydrogenCount(0); IAtomContainer changedAtomsAndBonds = container.Builder.newAtomContainer(); for (int i = 1; i <= count; i++) { IAtom hydrogen = container.Builder.newAtom("H"); IsotopeFactory.getInstance(container.Builder).configure(hydrogen, isotope); totalContainer.addAtom(hydrogen); IBond newBond = container.Builder.newBond((IAtom)atom, hydrogen, 1.0); totalContainer.addBond(newBond); changedAtomsAndBonds.addAtom(hydrogen); changedAtomsAndBonds.addBond(newBond); } return(changedAtomsAndBonds); }
/// <summary> /// /// </summary> /// <param name="builder"></param> /// <exception cref="System.IO.IOException">if there is error in getting the <see cref="IsotopeFactory"/></exception> public PubChemXMLHelper(IChemObjectBuilder builder) { this.builder = builder; factory = CDK.IsotopeFactory; }
/// <summary> Writes a Molecule to an OutputStream in MDL sdf format. /// /// </summary> /// <param name="container"> Molecule that is written to an OutputStream /// </param> /// <param name="isVisible">Should a certain atom be written to mdl? /// </param> public virtual void writeMolecule(IMolecule container, bool[] isVisible) { System.String line = ""; // taking care of the $$$$ signs: // we do not write such a sign at the end of the first molecule, thus we have to write on BEFORE the second molecule if (moleculeNumber == 2) { writer.Write("$$$$"); //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'" writer.WriteLine(); } // write header block // lines get shortened to 80 chars, that's in the spec System.String title = (System.String)container.getProperty(CDKConstants.TITLE); if (title == null) { title = ""; } if (title.Length > 80) { title = title.Substring(0, (80) - (0)); } writer.Write(title + "\n"); /* From CTX spec * This line has the format: * IIPPPPPPPPMMDDYYHHmmddSSssssssssssEEEEEEEEEEEERRRRRR * (FORTRAN: A2<--A8--><---A10-->A2I2<--F10.5-><---F12.5--><-I6-> ) * User's first and last initials (l), program name (P), * date/time (M/D/Y,H:m), dimensional codes (d), scaling factors (S, s), * energy (E) if modeling program input, internal registry number (R) * if input through MDL form. * A blank line can be substituted for line 2. */ writer.Write(" CDK "); //UPGRADE_ISSUE: Constructor 'java.text.SimpleDateFormat.SimpleDateFormat' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javatextSimpleDateFormat'" //UPGRADE_TODO: The equivalent in .NET for method 'java.util.Calendar.getTime' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" System.TimeZone generatedAux3 = System.TimeZone.CurrentTimeZone; //writer.Write(SupportClass.FormatDateTime(new SimpleDateFormat("M/d/y,H:m", new System.Globalization.CultureInfo("en-US")), SupportClass.CalendarManager.manager.GetDateTime(new System.Globalization.GregorianCalendar()))); writer.Write('\n'); System.String comment = (System.String)container.getProperty(CDKConstants.REMARK); if (comment == null) { comment = ""; } if (comment.Length > 80) { comment = comment.Substring(0, (80) - (0)); } writer.Write(comment + "\n"); // write Counts line int upToWhichAtom = 0; for (int i = 0; i < isVisible.Length; i++) { if (isVisible[i]) { upToWhichAtom++; } } line += formatMDLInt(upToWhichAtom, 3); int numberOfBonds = 0; if (upToWhichAtom < container.AtomCount) { for (int i = 0; i < container.getBondCount(); i++) { if (isVisible[container.getAtomNumber(container.getBondAt(i).getAtoms()[0])] && isVisible[container.getAtomNumber(container.getBondAt(i).getAtoms()[1])]) { numberOfBonds++; } } } else { numberOfBonds = container.getBondCount(); } line += formatMDLInt(numberOfBonds, 3); line += " 0 0 0 0 0 0 0 0999 V2000\n"; writer.Write(line); // write Atom block IAtom[] atoms = container.Atoms; for (int f = 0; f < atoms.Length; f++) { if (isVisible[f]) { IAtom atom = atoms[f]; line = ""; if (atom.getPoint3d() != null) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" line += formatMDLFloat((float)atom.X3d); //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" line += formatMDLFloat((float)atom.Y3d); //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" line += (formatMDLFloat((float)atom.Z3d) + " "); } else if (atom.getPoint2d() != null) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" line += formatMDLFloat((float)atom.X2d); //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" line += formatMDLFloat((float)atom.Y2d); line += " 0.0000 "; } else { // if no coordinates available, then output a number // of zeros line += formatMDLFloat((float)0.0); line += formatMDLFloat((float)0.0); line += (formatMDLFloat((float)0.0) + " "); } if (container.getAtomAt(f) is IPseudoAtom) { line += formatMDLString(((IPseudoAtom)container.getAtomAt(f)).Label, 3); } else { line += formatMDLString(container.getAtomAt(f).Symbol, 3); } line += " 0 0 0 0 0 0 0 0 0 0 0 0"; writer.Write(line); //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'" writer.WriteLine(); } } // write Bond block IBond[] bonds = container.Bonds; for (int g = 0; g < bonds.Length; g++) { if (upToWhichAtom == container.AtomCount || (isVisible[container.getAtomNumber(container.getBondAt(g).getAtoms()[0])] && isVisible[container.getAtomNumber(container.getBondAt(g).getAtoms()[1])])) { IBond bond = bonds[g]; if (bond.getAtoms().Length != 2) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" //logger.warn("Skipping bond with more/less than two atoms: " + bond); } else { if (bond.Stereo == CDKConstants.STEREO_BOND_UP_INV || bond.Stereo == CDKConstants.STEREO_BOND_DOWN_INV) { // turn around atom coding to correct for inv stereo line = formatMDLInt(container.getAtomNumber(bond.getAtomAt(1)) + 1, 3); line += formatMDLInt(container.getAtomNumber(bond.getAtomAt(0)) + 1, 3); } else { line = formatMDLInt(container.getAtomNumber(bond.getAtomAt(0)) + 1, 3); line += formatMDLInt(container.getAtomNumber(bond.getAtomAt(1)) + 1, 3); } //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" line += formatMDLInt((int)bond.Order, 3); line += " "; switch (bond.Stereo) { case CDKConstants.STEREO_BOND_UP: line += "1"; break; case CDKConstants.STEREO_BOND_UP_INV: line += "1"; break; case CDKConstants.STEREO_BOND_DOWN: line += "6"; break; case CDKConstants.STEREO_BOND_DOWN_INV: line += "6"; break; default: line += "0"; break; } line += " 0 0 0 "; writer.Write(line); //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'" writer.WriteLine(); } } } // write formal atomic charges for (int i = 0; i < atoms.Length; i++) { IAtom atom = atoms[i]; int charge = atom.getFormalCharge(); if (charge != 0) { writer.Write("M CHG 1 "); writer.Write(formatMDLInt(i + 1, 3)); writer.Write(" "); writer.Write(formatMDLInt(charge, 3)); //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'" writer.WriteLine(); } } // write formal isotope information for (int i = 0; i < atoms.Length; i++) { IAtom atom = atoms[i]; if (!(atom is IPseudoAtom)) { int atomicMass = atom.MassNumber; int majorMass = IsotopeFactory.getInstance(atom.Builder).getMajorIsotope(atom.Symbol).MassNumber; if (atomicMass != 0 && atomicMass != majorMass) { writer.Write("M ISO 1 "); writer.Write(formatMDLInt(i + 1, 3)); writer.Write(" "); writer.Write(formatMDLInt(atomicMass, 3)); //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'" writer.WriteLine(); } } } // close molecule writer.Write("M END"); //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'" writer.WriteLine(); //write sdfields, if any if (sdFields != null) { //UPGRADE_TODO: Method 'java.util.Map.keySet' was converted to 'CSGraphT.SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilMapkeySet'" CSGraphT.SupportClass.SetSupport set_Renamed = new CSGraphT.SupportClass.HashSetSupport(sdFields.Keys); System.Collections.IEnumerator iterator = set_Renamed.GetEnumerator(); //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'" while (iterator.MoveNext()) { //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'" System.Object element = iterator.Current; writer.Write("> <" + ((System.String)element) + ">"); //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'" writer.WriteLine(); //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" writer.Write(sdFields[element].ToString()); //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'" writer.WriteLine(); //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'" writer.WriteLine(); } } // taking care of the $$$$ signs: // we write such a sign at the end of all except the first molecule if (moleculeNumber != 1) { writer.Write("$$$$"); //UPGRADE_TODO: Method 'java.io.BufferedWriter.newLine' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'" writer.WriteLine(); } moleculeNumber++; writer.Flush(); }
private IChemModel readChemModel(IChemModel model) { int[] atoms = new int[1]; double[] atomxs = new double[1]; double[] atomys = new double[1]; double[] atomzs = new double[1]; double[] atomcharges = new double[1]; int[] bondatomid1 = new int[1]; int[] bondatomid2 = new int[1]; int[] bondorder = new int[1]; int numberOfAtoms = 0; int numberOfBonds = 0; try { System.String line = input.ReadLine(); while (line != null) { SupportClass.Tokenizer st = new SupportClass.Tokenizer(line); System.String command = st.NextToken(); if ("!Header".Equals(command)) { //logger.warn("Ignoring header"); } else if ("!Info".Equals(command)) { //logger.warn("Ignoring info"); } else if ("!Atoms".Equals(command)) { //logger.info("Reading atom block"); // determine number of atoms to read try { numberOfAtoms = System.Int32.Parse(st.NextToken()); //logger.debug(" #atoms: " + numberOfAtoms); atoms = new int[numberOfAtoms]; atomxs = new double[numberOfAtoms]; atomys = new double[numberOfAtoms]; atomzs = new double[numberOfAtoms]; atomcharges = new double[numberOfAtoms]; for (int i = 0; i < numberOfAtoms; i++) { line = input.ReadLine(); SupportClass.Tokenizer atomInfoFields = new SupportClass.Tokenizer(line); int atomID = System.Int32.Parse(atomInfoFields.NextToken()); atoms[atomID] = System.Int32.Parse(atomInfoFields.NextToken()); //logger.debug("Set atomic number of atom (" + atomID + ") to: " + atoms[atomID]); } } catch (System.Exception exception) { //logger.error("Error while reading Atoms block"); //logger.debug(exception); } } else if ("!Bonds".Equals(command)) { //logger.info("Reading bond block"); try { // determine number of bonds to read numberOfBonds = System.Int32.Parse(st.NextToken()); bondatomid1 = new int[numberOfAtoms]; bondatomid2 = new int[numberOfAtoms]; bondorder = new int[numberOfAtoms]; for (int i = 0; i < numberOfBonds; i++) { line = input.ReadLine(); SupportClass.Tokenizer bondInfoFields = new SupportClass.Tokenizer(line); bondatomid1[i] = System.Int32.Parse(bondInfoFields.NextToken()); bondatomid2[i] = System.Int32.Parse(bondInfoFields.NextToken()); System.String order = bondInfoFields.NextToken(); if ("D".Equals(order)) { bondorder[i] = 2; } else if ("S".Equals(order)) { bondorder[i] = 1; } else if ("T".Equals(order)) { bondorder[i] = 3; } else { // ignore order, i.e. set to single //logger.warn("Unrecognized bond order, using single bond instead. Found: " + order); bondorder[i] = 1; } } } catch (System.Exception exception) { //logger.error("Error while reading Bonds block"); //logger.debug(exception); } } else if ("!Coord".Equals(command)) { //logger.info("Reading coordinate block"); try { for (int i = 0; i < numberOfAtoms; i++) { line = input.ReadLine(); SupportClass.Tokenizer atomInfoFields = new SupportClass.Tokenizer(line); int atomID = System.Int32.Parse(atomInfoFields.NextToken()); double x = System.Double.Parse(atomInfoFields.NextToken()); double y = System.Double.Parse(atomInfoFields.NextToken()); double z = System.Double.Parse(atomInfoFields.NextToken()); atomxs[atomID] = x; atomys[atomID] = y; atomzs[atomID] = z; } } catch (System.Exception exception) { //logger.error("Error while reading Coord block"); //logger.debug(exception); } } else if ("!Charges".Equals(command)) { //logger.info("Reading charges block"); try { for (int i = 0; i < numberOfAtoms; i++) { line = input.ReadLine(); SupportClass.Tokenizer atomInfoFields = new SupportClass.Tokenizer(line); int atomID = System.Int32.Parse(atomInfoFields.NextToken()); double charge = System.Double.Parse(atomInfoFields.NextToken()); atomcharges[atomID] = charge; } } catch (System.Exception exception) { //logger.error("Error while reading Charges block"); //logger.debug(exception); } } else if ("!End".Equals(command)) { //logger.info("Found end of file"); // Store atoms IAtomContainer container = model.Builder.newAtomContainer(); for (int i = 0; i < numberOfAtoms; i++) { try { IAtom atom = model.Builder.newAtom(IsotopeFactory.getInstance(container.Builder).getElementSymbol(atoms[i])); atom.AtomicNumber = atoms[i]; atom.setPoint3d(new Point3d(atomxs[i], atomys[i], atomzs[i])); atom.setCharge(atomcharges[i]); container.addAtom(atom); //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" //logger.debug("Stored atom: " + atom); } catch (System.Exception exception) { //logger.error("Cannot create an atom with atomic number: " + atoms[i]); //logger.debug(exception); } } // Store bonds for (int i = 0; i < numberOfBonds; i++) { container.addBond(bondatomid1[i], bondatomid2[i], bondorder[i]); } ISetOfMolecules moleculeSet = model.Builder.newSetOfMolecules(); moleculeSet.addMolecule(model.Builder.newMolecule(container)); model.SetOfMolecules = moleculeSet; return(model); } else { //logger.warn("Skipping line: " + line); } line = input.ReadLine(); } } catch (System.Exception exception) { //logger.error("Error while reading file"); //logger.debug(exception); } // this should not happen, file is lacking !End command return(null); }
/// <summary> Reads a set of coordinates into ChemFrame. /// /// </summary> /// <param name="model">Description of the Parameter /// </param> /// <throws> IOException if an I/O error occurs </throws> /// <throws> CDKException Description of the Exception </throws> private void readCoordinates(IChemModel model) { ISetOfMolecules moleculeSet = model.Builder.newSetOfMolecules(); IMolecule molecule = model.Builder.newMolecule(); System.String line = input.ReadLine(); line = input.ReadLine(); line = input.ReadLine(); line = input.ReadLine(); while (input.Peek() != -1) { line = input.ReadLine(); if ((line == null) || (line.IndexOf("-----") >= 0)) { break; } int atomicNumber; System.IO.StringReader sr = new System.IO.StringReader(line); SupportClass.StreamTokenizerSupport token = new SupportClass.StreamTokenizerSupport(sr); token.NextToken(); // ignore first token if (token.NextToken() == SupportClass.StreamTokenizerSupport.TT_NUMBER) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" atomicNumber = (int)token.nval; if (atomicNumber == 0) { // Skip dummy atoms. Dummy atoms must be skipped // if frequencies are to be read because Gaussian // does not report dummy atoms in frequencies, and // the number of atoms is used for reading frequencies. continue; } } else { throw new CDKException("Error while reading coordinates: expected integer."); } token.NextToken(); // ignore third token double x; double y; double z; if (token.NextToken() == SupportClass.StreamTokenizerSupport.TT_NUMBER) { x = token.nval; } else { throw new System.IO.IOException("Error reading x coordinate"); } if (token.NextToken() == SupportClass.StreamTokenizerSupport.TT_NUMBER) { y = token.nval; } else { throw new System.IO.IOException("Error reading y coordinate"); } if (token.NextToken() == SupportClass.StreamTokenizerSupport.TT_NUMBER) { z = token.nval; } else { throw new System.IO.IOException("Error reading z coordinate"); } System.String symbol = "Du"; try { symbol = IsotopeFactory.getInstance(model.Builder).getElementSymbol(atomicNumber); } catch (System.Exception exception) { throw new CDKException("Could not determine element symbol!", exception); } IAtom atom = model.Builder.newAtom(symbol); atom.setPoint3d(new Point3d(x, y, z)); molecule.addAtom(atom); } /* * this is the place where we store the atomcount to * be used as a counter in the nmr reading */ atomCount = molecule.AtomCount; moleculeSet.addMolecule(molecule); model.SetOfMolecules = moleculeSet; }
/// <summary> Reads the atoms, coordinates and charges. /// /// <p>IMPORTANT: it does not support the atom list and its negation! /// </summary> public virtual void readAtomBlock(IAtomContainer readData) { bool foundEND = false; while (Ready && !foundEND) { System.String command = readCommand(); if ("END ATOM".Equals(command)) { // FIXME: should check wether 3D is really 2D foundEND = true; } else { //logger.debug("Parsing atom from: " + command); SupportClass.Tokenizer tokenizer = new SupportClass.Tokenizer(command); IAtom atom = readData.Builder.newAtom("C"); // parse the index try { System.String indexString = tokenizer.NextToken(); atom.ID = indexString; } catch (System.Exception exception) { System.String error = "Error while parsing atom index"; //logger.error(error); //logger.debug(exception); throw new CDKException(error, exception); } // parse the element System.String element = tokenizer.NextToken(); bool isElement = false; try { isElement = IsotopeFactory.getInstance(atom.Builder).isElement(element); } catch (System.Exception exception) { throw new CDKException("Could not determine if element exists!", exception); } if (isPseudoAtom(element)) { atom = readData.Builder.newPseudoAtom(atom); } else if (isElement) { atom.Symbol = element; } else { System.String error = "Cannot parse element of type: " + element; //logger.error(error); throw new CDKException("(Possible CDK bug) " + error); } // parse atom coordinates (in Angstrom) try { System.String xString = tokenizer.NextToken(); System.String yString = tokenizer.NextToken(); System.String zString = tokenizer.NextToken(); double x = System.Double.Parse(xString); double y = System.Double.Parse(yString); double z = System.Double.Parse(zString); atom.setPoint3d(new Point3d(x, y, z)); atom.setPoint2d(new Point2d(x, y)); // FIXME: dirty! } catch (System.Exception exception) { System.String error = "Error while parsing atom coordinates"; //logger.error(error); //logger.debug(exception); throw new CDKException(error, exception); } // atom-atom mapping System.String mapping = tokenizer.NextToken(); if (!mapping.Equals("0")) { //logger.warn("Skipping atom-atom mapping: " + mapping); } // else: default 0 is no mapping defined // the rest are key value things if (command.IndexOf("=") != -1) { System.Collections.Hashtable options = parseOptions(exhaustStringTokenizer(tokenizer)); System.Collections.IEnumerator keys = options.Keys.GetEnumerator(); //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'" while (keys.MoveNext()) { //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'" System.String key = (System.String)keys.Current; System.String value_Renamed = (System.String)options[key]; try { if (key.Equals("CHG")) { int charge = System.Int32.Parse(value_Renamed); if (charge != 0) { // zero is no charge specified atom.setFormalCharge(charge); } } else { //logger.warn("Not parsing key: " + key); } } catch (System.Exception exception) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" System.String error = "Error while parsing key/value " + key + "=" + value_Renamed + ": " + exception.Message; //logger.error(error); //logger.debug(exception); throw new CDKException(error, exception); } } } // store atom readData.addAtom(atom); //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" //logger.debug("Added atom: " + atom); } } }
/// <summary> /// Gets the paulingElectronegativities attribute of the /// InductivePartialCharges object. /// </summary> /// <param name="ac">AtomContainer</param> /// <param name="modified">if true, some values are modified by following the reference</param> /// <returns>The pauling electronegativities</returns> public double[] GetPaulingElectronegativities(IAtomContainer ac, bool modified) { var paulingElectronegativities = new double[ac.Atoms.Count]; string symbol = null; int atomicNumber = 0; try { ifac = CDK.IsotopeFactory; for (int i = 0; i < ac.Atoms.Count; i++) { var atom = ac.Atoms[i]; symbol = ac.Atoms[i].Symbol; var element = ifac.GetElement(symbol); atomicNumber = element.AtomicNumber; if (modified) { switch (atom.AtomicNumber) { case AtomicNumbers.Cl: paulingElectronegativities[i] = 3.28; break; case AtomicNumbers.Br: paulingElectronegativities[i] = 3.13; break; case AtomicNumbers.I: paulingElectronegativities[i] = 2.93; break; case AtomicNumbers.H: paulingElectronegativities[i] = 2.10; break; case AtomicNumbers.C: if (ac.GetMaximumBondOrder(atom) == BondOrder.Single) { // Csp3 paulingElectronegativities[i] = 2.20; } else if (ac.GetMaximumBondOrder(atom) == BondOrder.Double) { paulingElectronegativities[i] = 2.31; } else { paulingElectronegativities[i] = 3.15; } break; case AtomicNumbers.O: if (ac.GetMaximumBondOrder(atom) == BondOrder.Single) { // Osp3 paulingElectronegativities[i] = 3.20; } else if (ac.GetMaximumBondOrder(atom) != BondOrder.Single) { paulingElectronegativities[i] = 4.34; } break; case AtomicNumbers.Si: paulingElectronegativities[i] = 1.99; break; case AtomicNumbers.S: paulingElectronegativities[i] = 2.74; break; case AtomicNumbers.N: paulingElectronegativities[i] = 2.59; break; default: paulingElectronegativities[i] = pauling[atomicNumber]; break; } } else { paulingElectronegativities[i] = pauling[atomicNumber]; } } return(paulingElectronegativities); } catch (Exception ex1) { Debug.WriteLine(ex1); throw new CDKException($"Problems with IsotopeFactory due to {ex1.Message}", ex1); } }
/// <summary> Read a Molecule from a file in MDL sd format /// /// </summary> /// <returns> The Molecule that was read from the MDL file. /// </returns> private IMolecule readMolecule(IMolecule molecule) { //logger.debug("Reading new molecule"); int linecount = 0; int atoms = 0; int bonds = 0; int atom1 = 0; int atom2 = 0; int order = 0; int stereo = 0; int RGroupCounter = 1; int Rnumber = 0; System.String[] rGroup = null; double x = 0.0; double y = 0.0; double z = 0.0; double totalZ = 0.0; //int[][] conMat = new int[0][0]; //String help; IBond bond; IAtom atom; System.String line = ""; try { //logger.info("Reading header"); line = input.ReadLine(); linecount++; if (line == null) { return(null); } //logger.debug("Line " + linecount + ": " + line); if (line.StartsWith("$$$$")) { //logger.debug("File is empty, returning empty molecule"); return(molecule); } if (line.Length > 0) { molecule.setProperty(CDKConstants.TITLE, line); } line = input.ReadLine(); linecount++; //logger.debug("Line " + linecount + ": " + line); line = input.ReadLine(); linecount++; //logger.debug("Line " + linecount + ": " + line); if (line.Length > 0) { molecule.setProperty(CDKConstants.REMARK, line); } //logger.info("Reading rest of file"); line = input.ReadLine(); linecount++; //logger.debug("Line " + linecount + ": " + line); atoms = System.Int32.Parse(line.Substring(0, (3) - (0)).Trim()); //logger.debug("Atomcount: " + atoms); bonds = System.Int32.Parse(line.Substring(3, (6) - (3)).Trim()); //logger.debug("Bondcount: " + bonds); // read ATOM block //logger.info("Reading atom block"); for (int f = 0; f < atoms; f++) { line = input.ReadLine(); linecount++; //UPGRADE_TODO: The differences in the format of parameters for constructor 'java.lang.Double.Double' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" x = System.Double.Parse(line.Substring(0, (10) - (0)).Trim()); //UPGRADE_TODO: The differences in the format of parameters for constructor 'java.lang.Double.Double' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" y = System.Double.Parse(line.Substring(10, (20) - (10)).Trim()); //UPGRADE_TODO: The differences in the format of parameters for constructor 'java.lang.Double.Double' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" z = System.Double.Parse(line.Substring(20, (30) - (20)).Trim()); totalZ += System.Math.Abs(z); // *all* values should be zero, not just the sum //logger.debug("Coordinates: " + x + "; " + y + "; " + z); System.String element = line.Substring(31, (34) - (31)).Trim(); //logger.debug("Atom type: ", element); if (IsotopeFactory.getInstance(molecule.Builder).isElement(element)) { atom = IsotopeFactory.getInstance(molecule.Builder).configure(molecule.Builder.newAtom(element)); } else { //logger.debug("Atom ", element, " is not an regular element. Creating a PseudoAtom."); //check if the element is R rGroup = element.Split(new char[] { '^', 'R' }); // ???? if (rGroup.Length > 1) { try { Rnumber = System.Int32.Parse(rGroup[(rGroup.Length - 1)]); RGroupCounter = Rnumber; } catch (System.Exception ex) { Rnumber = RGroupCounter; RGroupCounter++; } element = "R" + Rnumber; } atom = molecule.Builder.newPseudoAtom(element); } // store as 3D for now, convert to 2D (if totalZ == 0.0) later atom.setPoint3d(new Point3d(x, y, z)); // parse further fields System.String massDiffString = line.Substring(34, (36) - (34)).Trim(); //logger.debug("Mass difference: ", massDiffString); if (!(atom is IPseudoAtom)) { try { int massDiff = System.Int32.Parse(massDiffString); if (massDiff != 0) { IIsotope major = IsotopeFactory.getInstance(molecule.Builder).getMajorIsotope(element); atom.AtomicNumber = major.AtomicNumber + massDiff; } } catch (System.Exception exception) { //logger.error("Could not parse mass difference field"); } } else { //logger.error("Cannot set mass difference for a non-element!"); } System.String chargeCodeString = line.Substring(36, (39) - (36)).Trim(); //logger.debug("Atom charge code: ", chargeCodeString); int chargeCode = System.Int32.Parse(chargeCodeString); if (chargeCode == 0) { // uncharged species } else if (chargeCode == 1) { atom.setFormalCharge(+3); } else if (chargeCode == 2) { atom.setFormalCharge(+2); } else if (chargeCode == 3) { atom.setFormalCharge(+1); } else if (chargeCode == 4) { } else if (chargeCode == 5) { atom.setFormalCharge(-1); } else if (chargeCode == 6) { atom.setFormalCharge(-2); } else if (chargeCode == 7) { atom.setFormalCharge(-3); } try { // read the mmm field as position 61-63 System.String reactionAtomIDString = line.Substring(60, (63) - (60)).Trim(); //logger.debug("Parsing mapping id: ", reactionAtomIDString); try { int reactionAtomID = System.Int32.Parse(reactionAtomIDString); if (reactionAtomID != 0) { atom.ID = reactionAtomIDString; } } catch (System.Exception exception) { //logger.error("Mapping number ", reactionAtomIDString, " is not an integer."); //logger.debug(exception); } } catch (System.Exception exception) { // older mol files don't have all these fields... //logger.warn("A few fields are missing. Older MDL MOL file?"); } molecule.addAtom(atom); } // convert to 2D, if totalZ == 0 if (totalZ == 0.0 && !forceReadAs3DCoords.Set) { //logger.info("Total 3D Z is 0.0, interpreting it as a 2D structure"); IAtom[] atomsToUpdate = molecule.Atoms; for (int f = 0; f < atomsToUpdate.Length; f++) { IAtom atomToUpdate = atomsToUpdate[f]; Point3d p3d = atomToUpdate.getPoint3d(); atomToUpdate.setPoint2d(new Point2d(p3d.x, p3d.y)); atomToUpdate.setPoint3d(null); } } // read BOND block //logger.info("Reading bond block"); for (int f = 0; f < bonds; f++) { line = input.ReadLine(); linecount++; atom1 = System.Int32.Parse(line.Substring(0, (3) - (0)).Trim()); atom2 = System.Int32.Parse(line.Substring(3, (6) - (3)).Trim()); order = System.Int32.Parse(line.Substring(6, (9) - (6)).Trim()); if (line.Length > 12) { stereo = System.Int32.Parse(line.Substring(9, (12) - (9)).Trim()); } else { //logger.warn("Missing expected stereo field at line: " + line); } //if (//logger.DebugEnabled) //{ // //logger.debug("Bond: " + atom1 + " - " + atom2 + "; order " + order); //} if (stereo == 1) { // MDL up bond stereo = CDKConstants.STEREO_BOND_UP; } else if (stereo == 6) { // MDL down bond stereo = CDKConstants.STEREO_BOND_DOWN; } else if (stereo == 4) { //MDL bond undefined stereo = CDKConstants.STEREO_BOND_UNDEFINED; } // interpret CTfile's special bond orders IAtom a1 = molecule.getAtomAt(atom1 - 1); IAtom a2 = molecule.getAtomAt(atom2 - 1); if (order == 4) { // aromatic bond bond = molecule.Builder.newBond(a1, a2, CDKConstants.BONDORDER_AROMATIC, stereo); // mark both atoms and the bond as aromatic bond.setFlag(CDKConstants.ISAROMATIC, true); a1.setFlag(CDKConstants.ISAROMATIC, true); a2.setFlag(CDKConstants.ISAROMATIC, true); molecule.addBond(bond); } else { bond = molecule.Builder.newBond(a1, a2, (double)order, stereo); molecule.addBond(bond); } } // read PROPERTY block //logger.info("Reading property block"); while (true) { line = input.ReadLine(); linecount++; if (line == null) { throw new CDKException("The expected property block is missing!"); } if (line.StartsWith("M END")) { break; } bool lineRead = false; if (line.StartsWith("M CHG")) { // FIXME: if this is encountered for the first time, all // atom charges should be set to zero first! int infoCount = System.Int32.Parse(line.Substring(6, (9) - (6)).Trim()); SupportClass.Tokenizer st = new SupportClass.Tokenizer(line.Substring(9)); for (int i = 1; i <= infoCount; i++) { System.String token = st.NextToken(); int atomNumber = System.Int32.Parse(token.Trim()); token = st.NextToken(); int charge = System.Int32.Parse(token.Trim()); molecule.getAtomAt(atomNumber - 1).setFormalCharge(charge); } } else if (line.StartsWith("M ISO")) { try { System.String countString = line.Substring(6, (9) - (6)).Trim(); int infoCount = System.Int32.Parse(countString); SupportClass.Tokenizer st = new SupportClass.Tokenizer(line.Substring(9)); for (int i = 1; i <= infoCount; i++) { int atomNumber = System.Int32.Parse(st.NextToken().Trim()); int absMass = System.Int32.Parse(st.NextToken().Trim()); if (absMass != 0) { IAtom isotope = molecule.getAtomAt(atomNumber - 1); isotope.MassNumber = absMass; } } } catch (System.FormatException exception) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" System.String error = "Error (" + exception.Message + ") while parsing line " + linecount + ": " + line + " in property block."; //logger.error(error); throw new CDKException("NumberFormatException in isotope information on line: " + line, exception); } } else if (line.StartsWith("M RAD")) { try { System.String countString = line.Substring(6, (9) - (6)).Trim(); int infoCount = System.Int32.Parse(countString); SupportClass.Tokenizer st = new SupportClass.Tokenizer(line.Substring(9)); for (int i = 1; i <= infoCount; i++) { int atomNumber = System.Int32.Parse(st.NextToken().Trim()); int spinMultiplicity = System.Int32.Parse(st.NextToken().Trim()); if (spinMultiplicity > 1) { IAtom radical = molecule.getAtomAt(atomNumber - 1); for (int j = 2; j <= spinMultiplicity; j++) { // 2 means doublet -> one unpaired electron // 3 means triplet -> two unpaired electron molecule.addElectronContainer(molecule.Builder.newSingleElectron(radical)); } } } } catch (System.FormatException exception) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" System.String error = "Error (" + exception.Message + ") while parsing line " + linecount + ": " + line + " in property block."; //logger.error(error); throw new CDKException("NumberFormatException in radical information on line: " + line, exception); } } else if (line.StartsWith("G ")) { try { System.String atomNumberString = line.Substring(3, (6) - (3)).Trim(); int atomNumber = System.Int32.Parse(atomNumberString); //String whatIsThisString = line.substring(6,9).trim(); System.String atomName = input.ReadLine(); // convert Atom into a PseudoAtom IAtom prevAtom = molecule.getAtomAt(atomNumber - 1); IPseudoAtom pseudoAtom = molecule.Builder.newPseudoAtom(atomName); if (prevAtom.getPoint2d() != null) { pseudoAtom.setPoint2d(prevAtom.getPoint2d()); } if (prevAtom.getPoint3d() != null) { pseudoAtom.setPoint3d(prevAtom.getPoint3d()); } AtomContainerManipulator.replaceAtomByAtom(molecule, prevAtom, pseudoAtom); } catch (System.FormatException exception) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" System.String error = "Error (" + exception.ToString() + ") while parsing line " + linecount + ": " + line + " in property block."; //logger.error(error); throw new CDKException("NumberFormatException in group information on line: " + line, exception); } } if (!lineRead) { //logger.warn("Skipping line in property block: ", line); } } } catch (CDKException exception) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" System.String error = "Error while parsing line " + linecount + ": " + line + " -> " + exception.Message; //logger.error(error); //logger.debug(exception); throw exception; } catch (System.Exception exception) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" System.String error = "Error while parsing line " + linecount + ": " + line + " -> " + exception.Message; //logger.error(error); //logger.debug(exception); throw new CDKException(error, exception); } return(molecule); }
private IChemSequence readChemSequence(IChemSequence sequence) { IChemModel chemModel = sequence.Builder.newChemModel(); ICrystal crystal = null; // Get the info line (first token of the first line) //UPGRADE_ISSUE: Method 'java.io.BufferedReader.mark' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaioBufferedReadermark_int'" //inputBuffer.mark(255); //long pos = inputBuffer.BaseStream.Position; info = nextVASPToken(false); //System.out.println(info); //UPGRADE_ISSUE: Method 'java.io.BufferedReader.reset' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaioBufferedReaderreset'" //inputBuffer.reset(); // Get the number of different atom "NCLASS=X" //UPGRADE_ISSUE: Method 'java.io.BufferedReader.mark' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaioBufferedReadermark_int'" //inputBuffer.mark(255); nextVASPTokenFollowing("NCLASS"); ntype = System.Int32.Parse(fieldVal); //System.out.println("NCLASS= " + ntype); //UPGRADE_ISSUE: Method 'java.io.BufferedReader.reset' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaioBufferedReaderreset'" //inputBuffer.reset(); // Get the different atom names anames = new System.String[ntype]; nextVASPTokenFollowing("ATOM"); for (int i = 0; i < ntype; i++) { anames[i] = fieldVal; nextVASPToken(false); } // Get the number of atom of each type int[] natom_type = new int[ntype]; natom = 0; for (int i = 0; i < ntype; i++) { natom_type[i] = System.Int32.Parse(fieldVal); nextVASPToken(false); natom = natom + natom_type[i]; } // Get the representation type of the primitive vectors // only "Direct" is recognize now. representation = fieldVal; if (representation.Equals("Direct")) { //logger.info("Direct representation"); // DO NOTHING } else { throw new CDKException("This VASP file is not supported. Please contact the Jmol developpers"); } while (nextVASPToken(false) != null) { //logger.debug("New crystal started..."); crystal = sequence.Builder.newCrystal(); chemModel = sequence.Builder.newChemModel(); // Get acell for (int i = 0; i < 3; i++) { acell[i] = FortranFormat.atof(fieldVal); // all the same FIX? } // Get primitive vectors for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { nextVASPToken(false); rprim[i][j] = FortranFormat.atof(fieldVal); } } // Get atomic position int[] atomType = new int[natom]; double[][] xred = new double[natom][]; for (int i2 = 0; i2 < natom; i2++) { xred[i2] = new double[3]; } int atomIndex = 0; for (int i = 0; i < ntype; i++) { for (int j = 0; j < natom_type[i]; j++) { try { atomType[atomIndex] = IsotopeFactory.getInstance(sequence.Builder).getElement(anames[i]).AtomicNumber; } catch (System.Exception exception) { throw new CDKException("Could not determine atomic number!", exception); } //logger.debug("aname: " + anames[i]); //logger.debug("atomType: " + atomType[atomIndex]); nextVASPToken(false); xred[atomIndex][0] = FortranFormat.atof(fieldVal); nextVASPToken(false); xred[atomIndex][1] = FortranFormat.atof(fieldVal); nextVASPToken(false); xred[atomIndex][2] = FortranFormat.atof(fieldVal); atomIndex = atomIndex + 1; // FIXME: store atom } } crystal.A = new Vector3d(rprim[0][0] * acell[0], rprim[0][1] * acell[0], rprim[0][2] * acell[0]); crystal.B = new Vector3d(rprim[1][0] * acell[1], rprim[1][1] * acell[1], rprim[1][2] * acell[1]); crystal.C = new Vector3d(rprim[2][0] * acell[2], rprim[2][1] * acell[2], rprim[2][2] * acell[2]); for (int i = 0; i < atomType.Length; i++) { System.String symbol = "Du"; try { symbol = IsotopeFactory.getInstance(sequence.Builder).getElement(atomType[i]).Symbol; } catch (System.Exception exception) { throw new CDKException("Could not determine element symbol!", exception); } IAtom atom = sequence.Builder.newAtom(symbol); atom.AtomicNumber = atomType[i]; // convert fractional to cartesian double[] frac = new double[3]; frac[0] = xred[i][0]; frac[1] = xred[i][1]; frac[2] = xred[i][2]; atom.setFractionalPoint3d(new Point3d(frac[0], frac[1], frac[2])); crystal.addAtom(atom); } crystal.setProperty(CDKConstants.REMARK, info); chemModel.Crystal = crystal; //logger.info("New Frame set!"); sequence.addChemModel(chemModel); } //end while return(sequence); }