private static void ProcessChemFile(IChemFile chemFile, ISettings settings, FileUsage usage, MoleculeLoadingResults results, LoadingProgress progress) { MoleculeProcessingProgress molProcessing = new MoleculeProcessingProgress(progress); progress.MoveToNextProcess(molProcessing); // calc size int numModels = 0; for (int seq = 0; seq < chemFile.ChemSequenceCount; seq++) { IChemSequence chemSeq = chemFile.getChemSequence(seq); numModels += chemSeq.ChemModelCount; } float modelSz = 1.0f / (float)numModels; results.NumSequences = chemFile.ChemSequenceCount; for (int seq = 0; seq < chemFile.ChemSequenceCount; seq++) { IChemSequence chemSeq = chemFile.getChemSequence(seq); results.NumModels += chemSeq.ChemModelCount; for (int model = 0; model < chemSeq.ChemModelCount; model++) { ProcessChemModel(chemSeq.getChemModel(model), settings, usage, results, molProcessing, modelSz); } molProcessing.Log("Processed Sequence", LogItem.ItemLevel.Success); } molProcessing.Log("Processed File", LogItem.ItemLevel.Success); }
private IAtomContainer ReadCMLMolecule(string filename) { IAtomContainer mol = null; Debug.WriteLine($"Filename: {filename}"); var ins = ResourceLoader.GetAsStream(filename); var reader = new CMLReader(ins); IChemFile file = (IChemFile)reader.Read(builder.NewChemFile()); Assert.IsNotNull(file); Assert.AreEqual(1, file.Count); IChemSequence sequence = file[0]; Assert.IsNotNull(sequence); Assert.AreEqual(1, sequence.Count); IChemModel chemModel = sequence[0]; Assert.IsNotNull(chemModel); var moleculeSet = chemModel.MoleculeSet; Assert.IsNotNull(moleculeSet); Assert.AreEqual(1, moleculeSet.Count); mol = moleculeSet[0]; Assert.IsNotNull(mol); return(mol); }
/// <summary> Returns all the AtomContainer's of a ChemSequence.</summary> public static IAtomContainer[] getAllAtomContainers(IChemSequence sequence) { IChemModel[] models = sequence.ChemModels; int acCount = 0; System.Collections.ArrayList acArrays = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); for (int i = 0; i < models.Length; i++) { IAtomContainer[] modelContainers = ChemModelManipulator.getAllAtomContainers(models[i]); acArrays.Add(modelContainers); acCount += modelContainers.Length; } IAtomContainer[] containers = new IAtomContainer[acCount]; int arrayOffset = 0; //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'" for (System.Collections.IEnumerator acArraysElements = acArrays.GetEnumerator(); acArraysElements.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'" IAtomContainer[] modelContainers = (IAtomContainer[])acArraysElements.Current; Array.Copy(modelContainers, 0, containers, arrayOffset, modelContainers.Length); arrayOffset += modelContainers.Length; } return(containers); }
private IChemFile ReadChemFile(IChemFile file) { IChemSequence seq = ReadChemSequence(file.Builder.NewChemSequence()); file.Add(seq); return(file); }
/// <summary> Takes an object which subclasses IChemObject, e.g.Molecule, and will read /// this from from the Reader. If the specific implementation /// does not support a specific IChemObject it will throw an Exception. /// /// </summary> /// <param name="object">The object that subclasses IChemObject /// </param> /// <returns> The IChemObject read /// </returns> /// <exception cref="CDKException"> /// </exception> public override IChemObject read(IChemObject object_Renamed) { if (object_Renamed is IChemFile) { IChemFile file = (IChemFile)object_Renamed; IChemSequence sequence = file.Builder.newChemSequence(); IChemModel model = file.Builder.newChemModel(); ISetOfMolecules moleculeSet = file.Builder.newSetOfMolecules(); moleculeSet.addMolecule(readMolecule(model.Builder.newMolecule())); model.SetOfMolecules = moleculeSet; sequence.addChemModel(model); file.addChemSequence(sequence); return(file); } else if (object_Renamed is IChemModel) { IChemModel model = (IChemModel)object_Renamed; ISetOfMolecules moleculeSet = model.Builder.newSetOfMolecules(); moleculeSet.addMolecule(readMolecule(model.Builder.newMolecule())); model.SetOfMolecules = moleculeSet; return(model); } else { throw new CDKException("Only supported is ChemModel, and not " + object_Renamed.GetType().FullName + "."); } }
public override void StartDocument() { ChemFile = CDK.Builder.NewChemFile(); chemSequence = CDK.Builder.NewChemSequence(); chemModel = CDK.Builder.NewChemModel(); setOfMolecules = CDK.Builder.NewChemObjectSet <IAtomContainer>(); }
/// <summary>Creates from a PDB File a BioPolymer.</summary> private void ReadBioPolymer(string biopolymerFile) { try { // Read PDB file var fileReader = new StreamReader(biopolymerFile); ISimpleChemObjectReader reader = new ReaderFactory().CreateReader(fileReader); IChemFile chemFile = (IChemFile)reader.Read((IChemObject) new ChemFile()); // Get molecule from ChemFile IChemSequence chemSequence = chemFile[0]; IChemModel chemModel = chemSequence[0]; var setOfMolecules = chemModel.MoleculeSet; Protein = (IBioPolymer)setOfMolecules[0]; } catch (Exception exc) { if (exc is IOException || exc is CDKException) { Trace.TraceError("Could not read BioPolymer from file>" + biopolymerFile + " due to: " + exc.Message); Debug.WriteLine(exc); } else { throw; } } }
/// <summary> /// Takes an object which subclasses IChemObject, e.g.Molecule, and will read /// this (from file, database, Internet etc). If the specific implementation /// does not support a specific IChemObject it will throw an Exception. /// </summary> /// <param name="obj">The object that subclasses <see cref="IChemObject"/></param> /// <returns>The <see cref="IChemObject"/> read</returns> /// <exception cref="CDKException"></exception> public override T Read <T>(T obj) { if (obj is IReaction) { return((T)ReadReaction(obj.Builder)); } else if (obj is IReactionSet) { IReactionSet reactionSet = obj.Builder.NewReactionSet(); reactionSet.Add(ReadReaction(obj.Builder)); return((T)reactionSet); } else if (obj is IChemModel) { IChemModel model = obj.Builder.NewChemModel(); IReactionSet reactionSet = obj.Builder.NewReactionSet(); reactionSet.Add(ReadReaction(obj.Builder)); model.ReactionSet = reactionSet; return((T)model); } else if (obj is IChemFile) { IChemFile chemFile = obj.Builder.NewChemFile(); IChemSequence sequence = obj.Builder.NewChemSequence(); sequence.Add((IChemModel)Read(obj.Builder.NewChemModel())); chemFile.Add(sequence); return((T)chemFile); } else { throw new CDKException($"Only supported are Reaction and ChemModel, and not {obj.GetType().Name}."); } }
public void SetUp() { molecule1 = builder.NewAtomContainer(); atomInMol1 = builder.NewAtom("Cl"); molecule1.Atoms.Add(atomInMol1); molecule1.Atoms.Add(builder.NewAtom("Cl")); bondInMol1 = builder.NewBond(atomInMol1, molecule1.Atoms[1]); molecule1.Bonds.Add(bondInMol1); molecule2 = builder.NewAtomContainer(); atomInMol2 = builder.NewAtom("O"); atomInMol2.ImplicitHydrogenCount = 2; molecule2.Atoms.Add(atomInMol2); moleculeSet = builder.NewChemObjectSet <IAtomContainer>(); moleculeSet.Add(molecule1); moleculeSet.Add(molecule2); reaction = builder.NewReaction(); reaction.Reactants.Add(molecule1); reaction.Products.Add(molecule2); reactionSet = builder.NewReactionSet(); reactionSet.Add(reaction); chemModel = builder.NewChemModel(); chemModel.MoleculeSet = moleculeSet; chemModel.ReactionSet = reactionSet; chemSequence1 = builder.NewChemSequence(); chemSequence1.Add(chemModel); chemSequence2 = builder.NewChemSequence(); chemFile = builder.NewChemFile(); chemFile.Add(chemSequence1); chemFile.Add(chemSequence2); }
/// <summary> /// Adds a ChemSequence to this container. /// </summary> /// <param name="chemSequence">The chemSequence to be added to this container</param> /// <seealso cref="this[int]"/> public void Add(IChemSequence chemSequence) { chemSequence.Listeners.Add(this); chemSequences.Add(chemSequence); NotifyChanged(); }
private IChemFile readChemFile(IChemFile chemFile) { IChemSequence sequence = readChemSequence(chemFile.Builder.newChemSequence()); chemFile.addChemSequence(sequence); return(chemFile); }
public void Insert(int index, IChemSequence chemSequence) { chemSequence.Listeners.Add(this); chemSequences.Insert(index, chemSequence); NotifyChanged(); }
private IChemFile readChemFile(IChemFile file) { IChemSequence seq = readChemSequence(file.Builder.newChemSequence()); file.addChemSequence(seq); return(file); }
/// <summary> /// Convert a Molecule to CML and back to a Molecule again. /// Given that CML reading is working, the problem is with the CMLWriter. /// </summary> /// <param name="convertor"></param> /// <param name="mol"></param> /// <returns></returns> /// <seealso cref="CMLFragmentsTest"/> public static IAtomContainer RoundTripMolecule(Convertor convertor, IAtomContainer mol) { string cmlString = "<!-- failed -->"; var cmlDOM = convertor.CDKAtomContainerToCMLMolecule(mol); cmlString = cmlDOM.ToString(); Debug.WriteLine("CML string: ", cmlString); IChemFile file; using (var reader = new CMLReader(new MemoryStream(Encoding.UTF8.GetBytes(cmlString)))) { file = (IChemFile)reader.Read(builder.NewChemFile()); } Assert.IsNotNull(file); Assert.AreEqual(1, file.Count); IChemSequence sequence = file[0]; Assert.IsNotNull(sequence); Assert.AreEqual(1, sequence.Count); IChemModel chemModel = sequence[0]; Assert.IsNotNull(chemModel); var moleculeSet = chemModel.MoleculeSet; Assert.IsNotNull(moleculeSet); Assert.AreEqual(1, moleculeSet.Count); var roundTrippedMol = moleculeSet[0]; Assert.IsNotNull(roundTrippedMol); return(roundTrippedMol); }
public static IChemModel RoundTripChemModel(Convertor convertor, IChemModel model) { string cmlString = "<!-- failed -->"; var cmlDOM = convertor.CDKChemModelToCMLList(model); cmlString = cmlDOM.ToString(); Debug.WriteLine("CML string: ", cmlString); IChemFile file; using (var reader = new CMLReader(new MemoryStream(Encoding.UTF8.GetBytes(cmlString)))) { file = (IChemFile)reader.Read(model.Builder.NewChemFile()); } Assert.IsNotNull(file); Assert.AreEqual(1, file.Count); IChemSequence sequence = file[0]; Assert.IsNotNull(sequence); Assert.AreEqual(1, sequence.Count); IChemModel chemModel = sequence[0]; Assert.IsNotNull(chemModel); return(chemModel); }
public override void TestClone() { IChemSequence sequence = (IChemSequence)NewChemObject(); object clone = sequence.Clone(); Assert.IsTrue(clone is IChemSequence); }
public static IReaction RoundTripReaction(Convertor convertor, IReaction reaction) { string cmlString = "<!-- failed -->"; var cmlDOM = convertor.CDKReactionToCMLReaction(reaction); cmlString = cmlDOM.ToString(); IReaction roundTrippedReaction = null; Debug.WriteLine("CML string: ", cmlString); CMLReader reader = new CMLReader(new MemoryStream(Encoding.UTF8.GetBytes(cmlString))); IChemFile file = (IChemFile)reader.Read(builder.NewChemFile()); reader.Close(); Assert.IsNotNull(file); Assert.AreEqual(1, file.Count); IChemSequence sequence = file[0]; Assert.IsNotNull(sequence); Assert.AreEqual(1, sequence.Count); IChemModel chemModel = sequence[0]; Assert.IsNotNull(chemModel); IReactionSet reactionSet = chemModel.ReactionSet; Assert.IsNotNull(reactionSet); Assert.AreEqual(1, reactionSet.Count); roundTrippedReaction = reactionSet[0]; Assert.IsNotNull(roundTrippedReaction); return(roundTrippedReaction); }
/// <summary> Takes an object which subclasses IChemObject, e.g.Molecule, and will read /// this (from file, database, internet etc). If the specific implementation /// does not support a specific IChemObject it will throw an Exception. /// /// </summary> /// <param name="object"> The object that subclasses /// IChemObject /// </param> /// <returns> The IChemObject read /// </returns> /// <exception cref="CDKException"> /// </exception> public override IChemObject read(IChemObject object_Renamed) { if (object_Renamed is IReaction) { return((IChemObject)readReaction(object_Renamed.Builder)); } else if (object_Renamed is IChemModel) { IChemModel model = object_Renamed.Builder.newChemModel(); ISetOfReactions reactionSet = object_Renamed.Builder.newSetOfReactions(); reactionSet.addReaction(readReaction(object_Renamed.Builder)); model.SetOfReactions = reactionSet; return(model); } else if (object_Renamed is IChemFile) { IChemFile chemFile = object_Renamed.Builder.newChemFile(); IChemSequence sequence = object_Renamed.Builder.newChemSequence(); sequence.addChemModel((IChemModel)read(object_Renamed.Builder.newChemModel())); chemFile.addChemSequence(sequence); return(chemFile); } else { throw new CDKException("Only supported are Reaction and ChemModel, and not " + object_Renamed.GetType().FullName + "."); } }
public void TestMultipleDataFields() { var filename = "NCDK.Data.MDL.bug1587283.mol"; var ins = ResourceLoader.GetAsStream(filename); var reader = new MDLV2000Reader(ins); IChemFile fileContents = (IChemFile)reader.Read(builder.NewChemFile()); reader.Close(); Assert.AreEqual(1, fileContents.Count); IChemSequence sequence = fileContents[0]; Assert.IsNotNull(sequence); Assert.AreEqual(1, sequence.Count); var model = sequence[0]; Assert.IsNotNull(model); var som = model.MoleculeSet; Assert.IsNotNull(som); Assert.AreEqual(1, som.Count); IAtomContainer m = som[0]; Assert.IsNotNull(m); Assert.AreEqual("B02", m.GetProperty <string>("id_no")); Assert.AreEqual("2-2", m.GetProperty <string>("eductkey")); Assert.AreEqual("1", m.GetProperty <string>("Step")); Assert.AreEqual("2", m.GetProperty <string>("Pos")); Assert.AreEqual("B02", m.GetProperty <string>("Tag")); }
public void TestNewChemSequence() { IChemObjectBuilder builder = RootObject.Builder; IChemSequence sequence = builder.NewChemSequence(); Assert.IsNotNull(sequence); }
private IChemFile ReadChemFile(IChemFile chemFile) { IChemSequence sequence = ReadChemSequence(chemFile.Builder.NewChemSequence()); chemFile.Add(sequence); return(chemFile); }
public virtual void createIDs(IChemSequence sequence) { IChemModel[] models = sequence.ChemModels; for (int i = 0; i < models.Length; i++) { createIDs(models[i]); } }
public bool Remove(IChemSequence chemSequence) { bool ret = chemSequences.Remove(chemSequence); chemSequence.Listeners.Remove(this); NotifyChanged(); return(ret); }
// procedures required by CDOInterface /// <summary> Procedure required by the CDOInterface. This function is only /// supposed to be called by the JCFL library /// </summary> public virtual void startDocument() { //logger.info("New CDO Object"); currentChemSequence = currentChemFile.Builder.newChemSequence(); currentChemModel = currentChemFile.Builder.newChemModel(); currentSetOfMolecules = currentChemFile.Builder.newSetOfMolecules(); currentMolecule = currentChemFile.Builder.newMolecule(); atomEnumeration = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable()); }
public virtual void TestGetChemModelCount() { IChemSequence cs = (IChemSequence)NewChemObject(); cs.Add(cs.Builder.NewChemModel()); cs.Add(cs.Builder.NewChemModel()); cs.Add(cs.Builder.NewChemModel()); Assert.AreEqual(3, cs.Count); }
public static int getBondCount(IChemSequence sequence) { int count = 0; for (int i = 0; i < sequence.ChemModelCount; i++) { count += ChemModelManipulator.getBondCount(sequence.getChemModel(i)); } return count; }
public override void TestStateChanged_IChemObjectChangeEvent() { ChemObjectListenerImpl listener = new ChemObjectListenerImpl(); IChemSequence chemObject = (IChemSequence)NewChemObject(); chemObject.Listeners.Add(listener); chemObject.Add(chemObject.Builder.NewChemModel()); Assert.IsTrue(listener.Changed); }
public static int getBondCount(IChemSequence sequence) { int count = 0; for (int i = 0; i < sequence.ChemModelCount; i++) { count += ChemModelManipulator.getBondCount(sequence.getChemModel(i)); } return(count); }
public static System.Collections.IList getAllChemObjects(IChemSequence sequence) { System.Collections.ArrayList list = new System.Collections.ArrayList(); list.Add(sequence); for (int i = 0; i < sequence.ChemModelCount; i++) { list.AddRange(ChemModelManipulator.getAllChemObjects(sequence.getChemModel(i))); } return(list); }
/// <summary> /// Get the total number of bonds inside an IChemSequence. /// /// <param name="sequence">The IChemSequence object.</param> /// <returns>The number of Bond objects inside.</returns> /// </summary> public static int GetBondCount(IChemSequence sequence) { int count = 0; for (int i = 0; i < sequence.Count; i++) { count += ChemModelManipulator.GetBondCount(sequence[i]); } return(count); }
/// <summary> /// Read a ChemFile from a file in MDL RDF format. /// </summary> /// <param name="chemFile">The IChemFile</param> /// <returns>The IChemFile that was read from the RDF file.</returns> private IChemFile ReadChemFile(IChemFile chemFile) { IChemSequence chemSequence = chemFile.Builder.NewChemSequence(); IChemModel chemModel = chemFile.Builder.NewChemModel(); chemSequence.Add(ReadChemModel(chemModel)); chemFile.Add(chemSequence); return(chemFile); }
/// <summary> Puts all the Molecules of this container together in one /// AtomCcntainer. /// /// </summary> /// <returns> The AtomContainer with all the Molecules of this container /// /// </returns> /// <deprecated> This method has a serious performace impact. Try to use /// other methods. /// </deprecated> public static IAtomContainer getAllInOneContainer(IChemSequence sequence) { IAtomContainer container = sequence.Builder.newAtomContainer(); for (int i = 0; i < sequence.ChemModelCount; i++) { IChemModel model = sequence.getChemModel(i); container.add(ChemModelManipulator.getAllInOneContainer(model)); } return container; }
/// <summary> Returns all the AtomContainer's of a ChemSequence.</summary> public static IAtomContainer[] getAllAtomContainers(IChemSequence sequence) { IChemModel[] models = sequence.ChemModels; int acCount = 0; System.Collections.ArrayList acArrays = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); for (int i = 0; i < models.Length; i++) { IAtomContainer[] modelContainers = ChemModelManipulator.getAllAtomContainers(models[i]); acArrays.Add(modelContainers); acCount += modelContainers.Length; } IAtomContainer[] containers = new IAtomContainer[acCount]; int arrayOffset = 0; //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'" for (System.Collections.IEnumerator acArraysElements = acArrays.GetEnumerator(); acArraysElements.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'" IAtomContainer[] modelContainers = (IAtomContainer[])acArraysElements.Current; Array.Copy(modelContainers, 0, containers, arrayOffset, modelContainers.Length); arrayOffset += modelContainers.Length; } return containers; }
public static System.Collections.IList getAllChemObjects(IChemSequence sequence) { System.Collections.ArrayList list = new System.Collections.ArrayList(); list.Add(sequence); for (int i = 0; i < sequence.ChemModelCount; i++) { list.AddRange(ChemModelManipulator.getAllChemObjects(sequence.getChemModel(i))); } return list; }
//protected internal LoggingTool logger; /// <summary> Basic contructor</summary> public ChemFileCDO(IChemFile file) { //logger = new LoggingTool(this); currentChemFile = file; currentChemSequence = file.Builder.newChemSequence(); currentChemModel = file.Builder.newChemModel(); currentSetOfMolecules = file.Builder.newSetOfMolecules(); currentSetOfReactions = null; currentReaction = null; currentMolecule = file.Builder.newMolecule(); atomEnumeration = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable()); }
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; }
private IChemSequence readChemSequence(IChemSequence sequence) { IChemModel model = null; try { System.String line = input.ReadLine(); //String levelOfTheory = null; // Find first set of coordinates while (input.Peek() != -1 && (line != null)) { if (line.IndexOf("Standard orientation:") >= 0) { // Found a set of coordinates model = sequence.Builder.newChemModel(); try { readCoordinates(model); } catch (System.IO.IOException 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'" throw new CDKException("Error while reading coordinates: " + exception.ToString(), exception); } break; } line = input.ReadLine(); } if (model != null) { // Read all other data line = input.ReadLine(); while (input.Peek() != -1 && (line != null)) { if (line.IndexOf("Standard orientation:") >= 0) { // Found a set of coordinates // Add current frame to file and create a new one. sequence.addChemModel(model); fireFrameRead(); model = sequence.Builder.newChemModel(); readCoordinates(model); } else if (line.IndexOf("SCF Done:") >= 0) { // Found an energy model.setProperty("org.openscience.cdk.io.Gaussian03Reaer:SCF Done", line.Trim()); } else if (line.IndexOf("Harmonic frequencies") >= 0) { // Found a set of vibrations try { readFrequencies(model); } catch (System.IO.IOException 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'" throw new CDKException("Error while reading frequencies: " + exception.ToString(), exception); } } else if (line.IndexOf("Mulliken atomic charges") >= 0) { readPartialCharges(model); } else if (line.IndexOf("Magnetic shielding") >= 0) { // Found NMR data try { readNMRData(model, line); } catch (System.IO.IOException 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'" throw new CDKException("Error while reading NMR data: " + exception.ToString(), exception); } } else if (line.IndexOf("GINC") >= 0) { // Found calculation level of theory //levelOfTheory = parseLevelOfTheory(line); // FIXME: is doing anything with it? } line = input.ReadLine(); } // Add current frame to file sequence.addChemModel(model); fireFrameRead(); } } catch (System.IO.IOException 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'" throw new CDKException("Error while reading general structure: " + exception.ToString(), exception); } return sequence; }
public virtual void addChemSequence(IChemSequence chemSequence) { currentChemFile.addChemSequence(chemSequence); }
/// <summary> Procedure required by the CDOInterface. This function is only /// supposed to be called by the JCFL library /// </summary> public virtual void startObject(System.String objectType) { //logger.debug("START:" + objectType); if (objectType.Equals("Molecule")) { if (currentChemModel == null) currentChemModel = currentChemFile.Builder.newChemModel(); if (currentSetOfMolecules == null) currentSetOfMolecules = currentChemFile.Builder.newSetOfMolecules(); currentMolecule = currentChemFile.Builder.newMolecule(); } else if (objectType.Equals("Atom")) { currentAtom = currentChemFile.Builder.newAtom("H"); //logger.debug("Atom # " + numberOfAtoms); numberOfAtoms++; } else if (objectType.Equals("Bond")) { bond_id = null; bond_stereo = -99; } else if (objectType.Equals("Animation")) { currentChemSequence = currentChemFile.Builder.newChemSequence(); } else if (objectType.Equals("Frame")) { currentChemModel = currentChemFile.Builder.newChemModel(); } else if (objectType.Equals("SetOfMolecules")) { currentSetOfMolecules = currentChemFile.Builder.newSetOfMolecules(); currentMolecule = currentChemFile.Builder.newMolecule(); } else if (objectType.Equals("Crystal")) { currentMolecule = currentChemFile.Builder.newCrystal(currentMolecule); } else if (objectType.Equals("a-axis") || objectType.Equals("b-axis") || objectType.Equals("c-axis")) { crystal_axis_x = 0.0; crystal_axis_y = 0.0; crystal_axis_z = 0.0; } else if (objectType.Equals("SetOfReactions")) { currentSetOfReactions = currentChemFile.Builder.newSetOfReactions(); } else if (objectType.Equals("Reaction")) { if (currentSetOfReactions == null) startObject("SetOfReactions"); currentReaction = currentChemFile.Builder.newReaction(); } else if (objectType.Equals("Reactant")) { if (currentReaction == null) startObject("Reaction"); currentMolecule = currentChemFile.Builder.newMolecule(); } else if (objectType.Equals("Product")) { if (currentReaction == null) startObject("Reaction"); currentMolecule = currentChemFile.Builder.newMolecule(); } }