Ejemplo n.º 1
0
        public void addToShadowTable(SqlConnection conn, MangoIndex index, int id, int storage_id)
        {
            lock (_sync_object)
            {
                if (shadow_datatable == null)
                {
                    _createDataTables();
                }

                if (shadow_datatable.Rows.Count >= 10000)
                {
                    _flushShadowTable(conn);
                }

                DataRow shadow_row = shadow_datatable.NewRow();
                shadow_row["id"]         = id;
                shadow_row["storage_id"] = storage_id;
                shadow_row["gross"]      = index.gross;
                shadow_row["cmf"]        = index.cmf;
                shadow_row["xyz"]        = index.xyz;
                shadow_row["mass"]       = index.mass;

                int fragments_count = 0;
                for (int i = 0; i < index.hash.elements.Count; i++)
                {
                    fragments_count += index.hash.elements[i].count;
                }
                shadow_row["fragments"] = fragments_count;

                string[] counted = index.counted_elements_str.Split(',');
                for (int i = 0; i < MangoIndex.COUNTED_ELEMENTS_COUNT; i++)
                {
                    shadow_row[BingoCore.mangoGetCountedElementName(i)] = Convert.ToInt32(counted[i + 1]);
                }

                shadow_datatable.Rows.Add(shadow_row);

                foreach (MoleculeHashElement elem in index.hash.elements)
                {
                    DataRow comp_row = components_datatable.NewRow();
                    comp_row["id"]    = id;
                    comp_row["hash"]  = elem.hash;
                    comp_row["count"] = elem.count;

                    components_datatable.Rows.Add(comp_row);
                }
            }
        }
Ejemplo n.º 2
0
      public void addToShadowTable (SqlConnection conn, MangoIndex index, int id, int storage_id)
      {
         lock (_sync_object)
         {
            if (shadow_datatable == null)
               _createDataTables();

            if (shadow_datatable.Rows.Count >= 10000)
               _flushShadowTable(conn);

            DataRow shadow_row = shadow_datatable.NewRow();
            shadow_row["id"] = id;
            shadow_row["storage_id"] = storage_id;
            shadow_row["gross"] = index.gross;
            shadow_row["cmf"] = index.cmf;
            shadow_row["xyz"] = index.xyz;
            shadow_row["mass"] = index.mass;

            int fragments_count = 0;
            for (int i = 0; i < index.hash.elements.Count; i++)
               fragments_count += index.hash.elements[i].count;
            shadow_row["fragments"] = fragments_count;

            string[] counted = index.counted_elements_str.Split(',');
            for (int i = 0; i < MangoIndex.COUNTED_ELEMENTS_COUNT; i++)
               shadow_row[BingoCore.mangoGetCountedElementName(i)] = Convert.ToInt32(counted[i + 1]);

            shadow_datatable.Rows.Add(shadow_row);

            foreach (MoleculeHashElement elem in index.hash.elements)
            {
               DataRow comp_row = components_datatable.NewRow();
               comp_row["id"] = id;
               comp_row["hash"] = elem.hash;
               comp_row["count"] = elem.count;

               components_datatable.Rows.Add(comp_row);
            }
         }
      }
Ejemplo n.º 3
0
      private static bool _AddMoleculeToIndex (SqlConnection conn, BingoIndexData bingo_data)
      {
         MangoIndexData data = (MangoIndexData)bingo_data;

         MangoIndex index = new MangoIndex();
         int id;
         if (!index.readPrepared(out id))
         {
            string message =
               String.Format("Molecule with ID={0} wasn't added to the index: {1}",
                  id, BingoCore.lib.bingoGetWarning());
            SqlContext.Pipe.Send(message);
            BingoLog.logMessage(message);
            return false;
         }
         // 4 bytes for Id, 2 bytes for similarity fingerprints bits counts
         byte[] new_data = new byte[index.cmf.Length + 4 + 2];
         index.cmf.CopyTo(new_data, 6);

         MemoryStream stream = new MemoryStream(new_data, 0, 6, true);
         BinaryWriter writer = new BinaryWriter(stream);
         writer.Write(id);
         writer.Write((short)index.sim_fp_bits_count);

         int storage_id = data.storage.add(new_data, conn);
         data.fingerprints.addFingerprint(conn, index.fingerprint, storage_id);

         data.addToShadowTable(conn, index, id, storage_id);
         return true;
      }