File: MangoIndex.cs

package info (click to toggle)
indigo 1.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 48,936 kB
  • sloc: ansic: 332,816; cpp: 169,470; python: 20,033; java: 13,701; cs: 9,979; asm: 8,475; sql: 6,743; xml: 6,354; javascript: 1,245; sh: 555; php: 506; makefile: 54
file content (70 lines) | stat: -rw-r--r-- 2,270 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Runtime.InteropServices; 

namespace indigo
{
   public class MangoIndex
   {
      public const int COUNTED_ELEMENTS_COUNT = 6;

      public float mass;
      public byte[] cmf;
      public byte[] xyz;

      public string gross, counted_elements_str;

      public byte[] fingerprint;
      public string fingerprint_sim_str;

      public int sim_fp_bits_count;

      public MoleculeHash hash;

      public bool readPrepared (out int id)
      {
         IntPtr cmf_ptr, xyz_ptr, fingerprint_ptr;
         int cmf_buf_len, xyz_buf_len, fingerprint_buf_len;
         IntPtr gross_str, counter_elements_str, fingerprint_sim_str_ptr;

         int ret = BingoCore.lib.mangoIndexReadPreparedMolecule(out id,
            out cmf_ptr, out cmf_buf_len, out xyz_ptr, out xyz_buf_len,
            out gross_str, out counter_elements_str,
            out fingerprint_ptr, out fingerprint_buf_len,
            out fingerprint_sim_str_ptr, out mass, out sim_fp_bits_count);

         if (ret == -2)
            throw new Exception(BingoCore.lib.bingoGetError());
         if (ret == -1)
            return false;

         cmf = new byte[cmf_buf_len];
         xyz = new byte[xyz_buf_len];
         fingerprint = new byte[fingerprint_buf_len];

         Marshal.Copy(cmf_ptr, cmf, 0, cmf_buf_len);
         if (xyz_ptr != IntPtr.Zero)
            Marshal.Copy(xyz_ptr, xyz, 0, xyz_buf_len);

         Marshal.Copy(fingerprint_ptr, fingerprint, 0, fingerprint_buf_len);

         gross = Marshal.PtrToStringAnsi(gross_str);
         counted_elements_str = Marshal.PtrToStringAnsi(counter_elements_str);
         fingerprint_sim_str = Marshal.PtrToStringAnsi(fingerprint_sim_str_ptr);

         // Get each hash element
         hash = new MoleculeHash();
         hash.elements.Clear();
         int hash_count, tmp;
         BingoCore.lib.mangoGetHash(true, -1, out hash_count, out tmp);
         for (int i = 0; i < hash_count; i++)
         {
            MoleculeHashElement elem = new MoleculeHashElement();

            BingoCore.lib.mangoGetHash(true, i, out elem.count, out elem.hash);
            hash.elements.Add(elem);
         }

         return true;
      }
   }
}