예제 #1
0
void MangoPgSearchEngine::_prepareExactTauStrings(indigo::Array<char>& what_clause_str, indigo::Array<char>& from_clause_str, indigo::Array<char>& where_clause_str) {
   ArrayOutput what_clause(what_clause_str);
   ArrayOutput from_clause(from_clause_str);
   ArrayOutput where_clause(where_clause_str);

   what_clause.printf("b_id");
   from_clause.printf("%s", _shadowRelName.ptr());

   const char* query_gross = mangoTauGetQueryGross();
   if(query_gross == 0)
      CORE_HANDLE_ERROR(0, 1, "molecule seach engine: error while constructing gross string", bingoGetError());
   
   where_clause.printf("gross='%s' OR gross LIKE '%s H%%'", query_gross, query_gross);

   what_clause_str.push(0);
   from_clause_str.push(0);
   where_clause_str.push(0);

}
예제 #2
0
void RingoPgSearchEngine::_prepareExactQueryStrings(indigo::Array<char>& what_clause_str, indigo::Array<char>& from_clause_str, indigo::Array<char>& where_clause_str) {
   ArrayOutput what_clause(what_clause_str);
   ArrayOutput from_clause(from_clause_str);
   ArrayOutput where_clause(where_clause_str);

   what_clause.printf("b_id");
   from_clause.printf("%s", _shadowRelName.ptr());

   dword ex_hash;
   int bingo_res = ringoGetHash(0, &ex_hash);
   CORE_HANDLE_ERROR(bingo_res, 1, "reaction search engine: error while getting hash", bingoGetError());

   where_clause.printf("ex_hash=%d", ex_hash);

   what_clause_str.push(0);
   from_clause_str.push(0);
   where_clause_str.push(0);

}
예제 #3
0
void MangoPgSearchEngine::_prepareExactQueryStrings(indigo::Array<char>& what_clause_str, indigo::Array<char>& from_clause_str, indigo::Array<char>& where_clause_str) {
   int hash_elements_count, count, bingo_res;
   dword hash;

   ArrayOutput what_clause(what_clause_str);
   ArrayOutput from_clause(from_clause_str);
   ArrayOutput where_clause(where_clause_str);

   what_clause.printf("sh.b_id");

   bingo_res = mangoGetHash(false, -1, &hash_elements_count, &hash);
   CORE_HANDLE_ERROR(bingo_res, 1, "molecule search engine: error while getting hash", bingoGetError());

   if(hash_elements_count > MAX_HASH_ELEMENTS)
      hash_elements_count = MAX_HASH_ELEMENTS;

   from_clause.printf("%s sh", _shadowRelName.ptr());

   for (int i = 0; i < hash_elements_count; i++)
      from_clause.printf(", %s t%d", _shadowHashRelName.ptr(), i);

   /*
    * Create complex WHERE clause
    */

   bool where_was_added = false;
   if (hash_elements_count > 0) {
      where_was_added = true;
      /*
       * molecule ids must be same
       */
      where_clause.printf("sh.b_id = t0.b_id AND ");
      for (int i = 1; i < hash_elements_count; i++)
         where_clause.printf("t%d.b_id = t%d.b_id AND ", i - 1, i);
      /*
       * query components must match target components
       */
      for (int i = 0; i < hash_elements_count; i++) {
         bingo_res = mangoGetHash(false, i, &count, &hash);
         CORE_HANDLE_ERROR(bingo_res, 1, "molecule search engine: error while getting hash", bingoGetError());

         where_clause.printf("t%d.ex_hash = %d AND ", i, hash);
      }

      /*
       * components count mast must target components count
       */
      Array<char> rel;
      bingo_res = mangoExactNeedComponentMatching();
      CORE_HANDLE_ERROR(bingo_res, 0, "molecule search engine: error while getting need matching", bingoGetError());

      if (bingo_res > 0)
         rel.readString(">=", true);
      else
         rel.readString("=", true);

      for (int i = 0; i < hash_elements_count; i++) {
         if (i != 0)
            where_clause.printf("AND ");
         bingo_res = mangoGetHash(false, i, &count, &hash);
         CORE_HANDLE_ERROR(bingo_res, 1, "molecule search engine: error while getting hash", bingoGetError());

         where_clause.printf("t%d.f_count %s %d ", i, rel.ptr(), count);
      }
   }
   bingo_res = mangoExactNeedComponentMatching();
   CORE_HANDLE_ERROR(bingo_res, 0, "molecule search engine: error while getting need matching", bingoGetError());
   if (bingo_res == 0) {
      if (where_was_added)
         where_clause.printf("AND ");

      /*
       * There must be no other components in target
       */
      int query_fragments_count = 0;
      for (int i = 0; i < hash_elements_count; i++) {
         bingo_res = mangoGetHash(false, i, &count, &hash);
         CORE_HANDLE_ERROR(bingo_res, 1, "molecule search engine: error while getting hash", bingoGetError());
         query_fragments_count += count;
      }
      where_clause.printf("sh.fragments = %d", query_fragments_count);
   }
   what_clause_str.push(0);
   from_clause_str.push(0);
   where_clause_str.push(0);

}