Esempio n. 1
0
 /**
  * Save a sequence list for the given item ID
  *
  * @param array $item_id
  * @param BfoxRangeList $seqs
  * @return boolean (TRUE if there were actually sequences to save)
  */
 public function save_item($item_id, BfoxRangeList $seqs)
 {
     $this->delete_items(array($item_id));
     if ($seqs->is_valid()) {
         global $wpdb;
         $item_id = $this->prepare_item_id($item_id);
         $item_id_value = implode(', ', $item_id);
         $item_id_col = implode(', ', array_keys($item_id));
         $values = array();
         foreach ($seqs->get_seqs() as $seq) {
             $values[] = $wpdb->prepare("({$item_id_value}, %d, %d)", $seq->start, $seq->end);
         }
         if (!empty($values)) {
             $wpdb->query($wpdb->prepare("\n\t\t\t\t\tINSERT INTO {$this->table_name}\n\t\t\t\t\t({$item_id_col}, start, end)\n\t\t\t\t\tVALUES " . implode(', ', $values)));
         }
         return true;
     }
     return false;
 }
 /**
  * Returns whether the given sequence list intersects this sequence list
  *
  * @param BfoxRangeList $seq_list
  * @return boolean
  */
 public function intersects(BfoxRangeList $seq_list)
 {
     // Test each sequence to see if it would modify our sequence list if we subtracted it
     // If it never modifies our list, then our list never intersects
     return $this->sub_seqs($seq_list->get_seqs(), true);
 }