public CdxRecordsEnumerator(Stream stream) { indigo.setOption("ignore-stereochemistry-errors", "true"); indigo.setOption("unique-dearomatization", "false"); indigo.setOption("ignore-noncritical-query-features", "true"); indigo.setOption("timeout", "600000"); byte[] buffer = new byte[16 * 1024]; using (MemoryStream ms = new MemoryStream()) { int read; while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) { ms.Write(buffer, 0, read); } reader = indigo.iterateCDX(indigo.loadBuffer(ms.ToArray())); } }
/// <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 void renderMolecule2(IndigoObject input, string mw) { IndigoRenderer renderer = new IndigoRenderer(_indigo); _indigo.setOption("render-output-format", "emf"); _indigo.setOption("render-margins", 10, 10); if (showBonds == true) { _indigo.setOption("render-bond-ids-visible", true); } else { _indigo.setOption("render-bond-ids-visible", false); } if (showAtoms == true) { _indigo.setOption("render-atom-ids-visible", true); } else { _indigo.setOption("render-atom-ids-visible", false); } _indigo.setOption("render-atom-ids-visible", false); _indigo.setOption("render-atom-ids-visible", true); _indigo.setOption("render-label-mode", "hetero"); _indigo.setOption("render-stereo-style", "none"); _indigo.setOption("render-bond-length", 45); input.layout(); Form1 f = new Form1(); MemoryStream ms = new MemoryStream(renderer.renderToBuffer(input)); f.pictureBox1.Image = Image.FromStream(ms); f.label1.Text = mw; f.Show(); ms.Close(); }
private double calculateRgrpMassShift(fragmentationRule rule, IndigoObject structure) { Console.Out.WriteLine(rule._MassShift1); double mshift = 0.00; foreach (IndigoObject atom in structure.iterateAtoms()) { if (atom.symbol().Equals("R")) { try { double RgrpMassShift = double.Parse(rmasses[rmasses.IndexOf(rmasses.Find(x => x.index == atom.index()))].interfaceText.Text); mshift += RgrpMassShift; } catch (FormatException e) { MessageBox.Show("All R-Groups must have masses... R Group #" + atom.index() + " does not!"); } } } Console.Out.WriteLine("MASS SHIFT FINAL " + mshift); return(mshift); }
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); }
/// <summary> /// Execute similarity search for most similar structures with external fingerprint /// </summary> /// <param name="query"> indigo object (molecule or reaction)</param> /// <param name="limit"> Number of structures</param> /// <param name="minSim"> Minimum similarity value</param> /// <param name="extFp"> Indigo object with a external similarity fingerprint (molecule or reaction)</param> /// <returns> Bingo search object instance</returns> public BingoObject searchSimTopNWithExtFP(IndigoObject query, int limit, float minSim, IndigoObject extFp) { return(searchSimTopNWithExtFP(query, limit, minSim, extFp, null)); }
/// <summary> /// Execute similarity search for most similar structures (defined by limit) /// </summary> /// <param name="query"> indigo object (molecule or reaction)</param> /// <param name="limit"> Number of structures</param> /// <param name="minSim"> Minimum similarity value</param> /// <returns>Bingo search object instance</returns> public BingoObject searchSimTopN(IndigoObject query, int limit, float minSim) { return(searchSimTopN(query, limit, minSim, null)); }
/// <summary> /// Execute similarity search operation /// </summary> /// <param name="query">indigo object (molecule or reaction)</param> /// <param name="min">Minimum similarity value</param> /// <param name="max">Maximum similairy value</param> /// <returns>Bingo search object instance</returns> public BingoObject searchSim(IndigoObject query, float min, float max) { return(searchSim(query, min, max, null)); }
/// <summary> /// Inserts a structure under a specified id /// </summary> /// <param name="record">Indigo object with a chemical structure (molecule or reaction)</param> /// <param name="ext_fp">Indigo object with a external similarity fingerprint</param> /// <param name="id">record id</param> /// <returns> inserted record id</returns> public int insertWithExtFP(IndigoObject record, IndigoObject ext_fp, int id) { _indigo.setSessionID(); return(Bingo.checkResult(_indigo, _lib.bingoInsertRecordObjWithIdAndExtFP(_id, record.self, id, ext_fp.self))); }
public void transform(IndigoObject reaction, IndigoObject monomer) { setSessionID(); checkResult(_indigo_lib.indigoTransform(reaction.self, monomer.self)); }
public IndigoObject reactionProductEnumerate(IndigoObject reaction, IndigoObject monomers) { setSessionID(); return(new IndigoObject(this, checkResult(_indigo_lib.indigoReactionProductEnumerate(reaction.self, monomers.self)))); }
/// <summary> /// Insert a structure into the database and returns id of this structure /// </summary> /// <param name="record">Indigo object with a chemical structure (molecule or reaction)</param> /// <param name="ext_fp">Indigo object with a external similarity fingerprint</param> /// <returns>record id</returns> public int insertWithExtFP(IndigoObject record, IndigoObject ext_fp) { _indigo.setSessionID(); return(checkResult(BingoLib.bingoInsertRecordObjWithExtFP(_id, record.self, ext_fp.self))); }
/// <summary> /// Insert a structure into the database and returns id of this structure /// </summary> /// <param name="record">Indigo object with a chemical structure (molecule or reaction)</param> /// <returns>record id</returns> public int insert(IndigoObject record) { _indigo.setSessionID(); return(checkResult(BingoLib.bingoInsertRecordObj(_id, record.self))); }
static void Main(string[] args) { Indigo indigo = new Indigo(); // By default Bingo loads a database and stores all the data in RAM for faster operations // But if the application is limited in the memory usage Bingo can work // in a file mode with loading only minor parts of data into the memory Bingo database = Bingo.createDatabaseFile(indigo, "db1", "molecule", "storage:file"); // Insert structures from the file using (IndigoObject input = indigo.iterateSmilesFile("input.smi")) foreach (IndigoObject obj in input) { Console.WriteLine(" Object: {0}", obj.name()); // When loading from SMILES the only information that we have is an object name // that is stored on the same line with the SMILES in the file int id = int.Parse(obj.name()); // Insert loaded object into the database database.insert(obj, id); // Dispose native Indigo object as .NET object is much smaller than native object // and GC can postpone disposing of this object resulting in a large memory // consumption obj.Dispose(); } // Bingo can also assign structure ID automatically int autoId1 = database.insert(indigo.loadMolecule("OC1C(C(=O)O)=CC=CC1O")); Console.WriteLine("Automatic id = {0}", autoId1); int autoId2 = database.insert(indigo.loadMolecule("OC1C(C(=O)O)=CC=CC1O")); Console.WriteLine("Automatic id = {0}", autoId2); // Search over the database Console.WriteLine("Search Benzene:"); IndigoObject query = indigo.loadQueryMolecule("C1=CC=CC=C1"); BingoObject search = database.searchSub(query); while (search.next()) { Console.WriteLine(" Found id = {0}", search.getCurrentId()); } // You can close and reopen database at any moment database.close(); // Load Bingo in a RAM mode with caching all data into the memory // Search operations works faster in this mode database = Bingo.loadDatabaseFile(indigo, "db1", "molecule", "storage:ram"); // Search the same query but in the aromatic form // Results are the same Console.WriteLine("Search Benzene in the aromatic form:"); query = indigo.loadQueryMolecule("c1ccccc1"); search = database.searchSub(query); while (search.next()) { Console.WriteLine(" Found id = {0}", search.getCurrentId()); } Console.WriteLine("Search C=O"); query = indigo.loadQueryMolecule("C=O"); // Using block will automatically call search.Dispose() that calls search.close() // to terminate further search using (search = database.searchSub(query)) { int count = 0; while (search.next()) { Console.WriteLine(" Found id = {0}", search.getCurrentId()); count++; if (count == 4) { break; } } } // Similarity search Console.WriteLine("Similarity search:"); query = indigo.loadMolecule("NC1C=CC=C(C1O)C(O)=O"); search = database.searchSim(query, 0.7f, 1.0f); while (search.next()) { Console.WriteLine(" Found id = {0}", search.getCurrentId()); } // Database will be closed automatically in the object destructor // but we can close it manually to dispose memory database.close(); }
public void renderToFile(IndigoObject obj, string filename) { _indigo.setSessionID(); _indigo.checkResult(IndigoRendererLib.indigoRenderToFile(obj.self, filename)); }
public IndigoObject decomposeMolecules(IndigoObject scaffold, IEnumerable structures) { return(decomposeMolecules(scaffold, toIndigoArray(structures))); }
public IndigoObject createDecomposer(IndigoObject scaffold) { setSessionID(); return(new IndigoObject(this, checkResult(_indigo_lib.indigoCreateDecomposer(scaffold.self)))); }
public String getInchi(IndigoObject molecule) { _indigo.setSessionID(); return(new String(_indigo.checkResult(_inchi_lib.indigoInchiGetInchi(molecule.self)))); }
public IndigoObject createSaver(IndigoObject output, string format) { setSessionID(); return(new IndigoObject(this, checkResult(_indigo_lib.indigoCreateSaver(output.self, format)), output)); }
public IndigoObject exactMatch(IndigoObject obj1, IndigoObject obj2) { return(exactMatch(obj1, obj2, "")); }
/// <summary> /// Inserts a structure under a specified id /// </summary> /// <param name="record">Indigo object with a chemical structure (molecule or reaction)</param> /// <param name="id">record id</param> /// <returns> inserted record id</returns> public int insert(IndigoObject record, int id) { _indigo.setSessionID(); return(Bingo.checkResult(_indigo, _lib.bingoInsertRecordObjWithId(_id, record.self, id))); }
public float similarity(IndigoObject obj1, IndigoObject obj2) { return(similarity(obj1, obj2, "")); }
/// <summary> /// Execute substructure search operation /// </summary> /// <param name="query">Indigo query object (molecule or reaction)</param> /// <returns>Bingo search object instance</returns> public BingoObject searchSub(IndigoObject query) { return(searchSub(query, null)); }
public int commonBits(IndigoObject obj1, IndigoObject obj2) { setSessionID(); return(checkResult(_indigo_lib.indigoCommonBits(obj1.self, obj2.self))); }
/// <summary> /// Execute similarity search operation /// </summary> /// <param name="query">indigo object (molecule or reaction)</param> /// <param name="min">Minimum similarity value</param> /// <param name="max">Maximum similairy value</param> /// <param name="ext_fp">Indigo object with a external similarity fingerprint</param> /// <param name="metric">Default value is "tanimoto"</param> /// <returns>Bingo search object instance</returns> public BingoObject searchSimWithExtFP(IndigoObject query, float min, float max, IndigoObject ext_fp, string metric) { if (metric == null) { metric = "tanimoto"; } _indigo.setSessionID(); return(new BingoObject(Bingo.checkResult(_indigo, _lib.bingoSearchSimWithExtFP(_id, query.self, min, max, ext_fp.self, metric)), _indigo, _lib)); }
public IndigoObject substructureMatcher(IndigoObject target, string mode) { setSessionID(); return(new IndigoObject(this, checkResult(_indigo_lib.indigoSubstructureMatcher(target.self, mode)), target)); }
/// <summary> /// Execute similarity search for most similar structures with external fingerprint /// </summary> /// <param name="query"> indigo object (molecule or reaction)</param> /// <param name="limit"> Number of structures</param> /// <param name="minSim"> Minimum similarity value</param> /// <param name="metric"> Default value is "tanimoto"</param> /// <param name="extFp"> Indigo object with a external similarity fingerprint (molecule or reaction)</param> /// <returns> Bingo search object instance</returns> public BingoObject searchSimTopNWithExtFP(IndigoObject query, int limit, float minSim, IndigoObject extFp, String metric) { if (metric == null) { metric = "tanimoto"; } _indigo.setSessionID(); return(new BingoObject(Bingo.checkResult(_indigo, _lib.bingoSearchSimTopNWithExtFP(_id, query.self, limit, minSim, extFp.self, metric)), _indigo, _lib)); }
public IndigoObject substructureMatcher(IndigoObject target) { return(substructureMatcher(target, "")); }
/// <summary> /// Perform exact search operation /// </summary> /// <param name="query">indigo object (molecule or reaction)</param> /// <returns>Bingo search object instance</returns> public BingoObject searchExact(IndigoObject query) { return(searchExact(query, null)); }
public IndigoObject decomposeMolecules(IndigoObject scaffold, IndigoObject structures) { setSessionID(); return(new IndigoObject(this, checkResult(_indigo_lib.indigoDecomposeMolecules(scaffold.self, structures.self)))); }