Beispiel #1
0
                 }
             }
         } elseif ($structSearchType === 'similarity') {
             // similarity search
             $results_temp = array();
             if ($num_react + $num_prod > 0) {
                 for ($i = 0; $i < $num_react; $i++) {
                     $results_temp[] = similarity_search($molecules[$i], 'rel_exp_structure_react', $results_id, $tanimoto, 'exp_id');
                 }
                 for ($i = $num_react; $i < $num_react + $num_prod; $i++) {
                     $results_temp[] = similarity_search($molecules[$i], 'rel_exp_structure_prod', $results_id, $tanimoto, 'exp_id');
                 }
             } elseif (count($molecules) > 0) {
                 for ($i = 0; $i < count($molecules); $i++) {
                     $x = similarity_search($molecules[$i], 'rel_exp_structure_react', $results_id, $tanimoto, 'exp_id');
                     $y = similarity_search($molecules[$i], 'rel_exp_structure_prod', $results_id, $tanimoto, 'exp_id');
                     $results_temp[] = array_merge($x, $y);
                 }
             }
         }
         // where we have more than one results set, we treat the query as AND. So we find the intersection of the different
         // results arrays and return that as result.
         if (count($results_temp) > 1) {
             $results_id = call_user_func_array('array_intersect', $results_temp);
         } else {
             $results_id = $results_temp[0];
         }
         $results_id = array_unique($results_id);
         $count = count($results_id);
     }
 }
Beispiel #2
0
     // then, if necessary, do molecule-based search
     if (!empty($mol)) {
         if ($structSearchType === 'substructure') {
             $results_temp = array();
             $results_temp[] = substruc_search($mol, 'compound_registry', $results_id, 'id');
         } else {
             if ($structSearchType === 'exact') {
                 // exact search
                 // we will do this by inchi
                 $results_temp = array();
                 $results_temp[] = exact_search($mol, 'compound_registry', $results_id, 'id');
             } else {
                 if ($structSearchType === 'similarity') {
                     // similarity search
                     $results_temp = array();
                     $results_temp[] = similarity_search($mol, 'compound_registry', $results_id, $tanimoto, 'id');
                 }
             }
         }
         // where we have more than one results set, we treat the query as AND. So we find the intersection of the different
         // results arrays and return that as result.
         if (count($results_temp) > 1) {
             $results_id = call_user_func_array('array_intersect', $results_temp);
         } else {
             $results_id = array_intersect($results_id, $results_temp[0]);
         }
         $results_id = array_values(array_unique($results_id));
         $count = count($results_id);
     }
     // endif !empty($mol)
 }