void IDisposable.Dispose() { if (reader != null) { reader.Dispose(); } }
/// <summary> /// Returns a depiction of the chemical structure as a bitmap. /// </summary> /// <param name="width">The desired width in pixels.</param> /// <param name="height">The desired height in pixels.</param> /// <returns>The bitmap depicting the chemical structure.</returns> public Bitmap ToBitmap(int width, int height) { Bitmap bitmap = null; try { using (Indigo indigo = new Indigo()) { IndigoRenderer indigoRenderer = new IndigoRenderer(indigo); indigo.setOption("render-coloring", true); indigo.setOption("render-image-size", width, height); indigo.setOption("render-label-mode", "hetero"); indigo.setOption("render-margins", 10, 10); indigo.setOption("render-output-format", "png"); indigo.setOption("render-relative-thickness", 1.6f); IndigoObject structure = CreateIndigoStructure(indigo); structure.dearomatize(); structure.layout(); bitmap = indigoRenderer.renderToBitmap(structure); structure.Dispose(); } } catch { bitmap = Properties.Resources.Error; } return(bitmap); }
/// <summary> /// Returns a unique key for the chemical structure. /// </summary> /// <returns>A canonical Smiles string representing the unique key for the chemical structure.</returns> public string GetUniqueKey() { string uniqueKey = String.Empty; using (Indigo indigo = new Indigo()) { IndigoObject structure = CreateIndigoStructure(indigo); uniqueKey = structure.canonicalSmiles(); structure.Dispose(); } return(uniqueKey); }
/// <summary> /// Returns whether the chemical structure contains a specified substructure. /// </summary> /// <param name="substructureQuery">The specified substructure to search for.</param> /// <returns>True if this chemical structure contains the specified substructure.</returns> public bool HasSubstructure(ChemicalStructure substructureQuery) { bool hasSubstructure = false; using (Indigo indigo = new Indigo()) { // Load inputs. IndigoObject structure = CreateIndigoStructure(indigo); IndigoObject substructure = indigo.loadQueryMolecule(substructureQuery.MolfileContents); // Perform the match. IndigoObject substructureMatcher = indigo.substructureMatcher(structure); hasSubstructure = (substructureMatcher.match(substructure) != null); // Dispose. structure.Dispose(); substructure.Dispose(); substructureMatcher.Dispose(); } return(hasSubstructure); }
private List <int> GetFingerprintPositions(string type) { List <int> fingerprintPositions = new List <int>(); using (Indigo indigo = new Indigo()) { // Get the fingerprint as a byte array; this array is fixed length. IndigoObject structure = CreateIndigoStructure(indigo); byte[] fingerprint = structure.fingerprint(type).toBuffer(); structure.Dispose(); // Loop through the array and record the identified fingerprint positions. for (int i = 0; i < fingerprint.Length; i++) { if (Convert.ToBoolean(fingerprint[i])) { fingerprintPositions.Add(i); } } } return(fingerprintPositions); }