Bio-EnsEMBL

 view release on metacpan or  search on metacpan

lib/Bio/EnsEMBL/Map/DBSQL/DitagAdaptor.pm  view on Meta::CPAN

      $sth->bind_param(2,$ditag->name,SQL_VARCHAR);
      $sth->bind_param(3,$ditag->type,SQL_VARCHAR);
      $sth->bind_param(4,$ditag->tag_count,SQL_VARCHAR);
      $sth->bind_param(5,$ditag->sequence,SQL_VARCHAR);
      $sth->execute();
    } else {
      my $sth = $self->prepare( "INSERT INTO ditag( name, type, tag_count, sequence ) ".
			        "VALUES( ?,?,?,? )" );
      $sth->bind_param(1,$ditag->name,SQL_VARCHAR);
      $sth->bind_param(2,$ditag->type,SQL_VARCHAR);
      $sth->bind_param(3,$ditag->tag_count,SQL_VARCHAR);
      $sth->bind_param(4,$ditag->sequence,SQL_VARCHAR);
      $sth->execute();
      my $dbID = $self->last_insert_id('ditag_id', undef, 'ditag');
      $ditag->dbID($dbID);
      $ditag->adaptor($self);
    }
  }

  return 1;
}


=head2 print_creation

  Arg [1]    : ditag probe name
  Arg [2]    : ditag type
  Arg [3]    : ditag count
  Arg [4]    : ditag sequence
  Arg [5]    : (optional) ditag dbID
  Description: convenience method to produce SQL insert statements
               to speed up the creation of new ditags
  Returntype : string

=cut

sub print_creation {
  my ($self, $probe_name, $type, $count, $sequence, $dbid) = @_;
  my $string;
  if($dbid){
    $string = "INSERT INTO ditag( ditag_id, name, type, tag_count, sequence ) ".
	      "VALUES($dbid, '".$probe_name."', '".$type."', ".$count."'".$sequence."');\n";
  }
  else {
    $string = "INSERT INTO ditag( name, type, tag_count, sequence ) ".
	      "VALUES('".$probe_name."', '".$type."', ".$count.", '".$sequence."');\n";
  }

  return $string;
}


=head2 update_ditag

  Arg [1]    : ditag to update
  Description: update an existing ditag with new values
  Returntype : true on success

=cut

sub update_ditag {
  my ($self, $ditag) = @_;

  my $sth = $self->prepare( "UPDATE ditag SET name=?, type=?, tag_count=?, sequence=? where ditag_id=?;" );
  my $result =$sth->execute(
                            $ditag->name,
                            $ditag->type,
                            $ditag->tag_count,
                            $ditag->sequence,
                            $ditag->dbID,
                           );

  return $result;
}


=head2 list_dbIDs

  Args       : None
  Example    : my @feature_ids = @{$da->list_dbIDs()};
  Description: Gets an array of internal IDs for all Ditag objects in
               the current database.
  Returntype : List of ints
  Exceptions : None

=cut

sub list_dbIDs {
  my ($self, $ordered) = @_;
	
  return $self->_list_dbIDs('ditag');
}

1;



( run in 0.839 second using v1.01-cache-2.11-cpan-f56aa216473 )