EdgeExpressDB
view release on metacpan or search on metacpan
lib/EEDB/Chrom.pm view on Meta::CPAN
$ts = $te+1;
if($ts > $end) { last; } #we are done
}
my $bioseq = Bio::Seq->new(-id=>$name, -seq=>$seq);
if($strand eq '-') { $bioseq = $bioseq->revcom; }
return $bioseq;
}
#################################################
#
# DBObject override methods
#
#################################################
=head2 store
Description : store this instance into an EEDB database
on return the instance will have the primary_id() set.
Parameter[1] : a MQdb::Database to store into
Returntype : $self or undef if a problem occurred
Exceptions : none
=cut
sub store {
my $self = shift;
my $db = shift;
if($db) { $self->database($db); }
my $dbh = $self->database->get_connection;
my $sql = "INSERT ignore INTO chrom (
chrom_name,
chrom_type,
assembly_id,
chrom_length)
VALUES(?,?,?,?)";
my $sth = $dbh->prepare($sql);
$sth->execute($self->chrom_name,
$self->chrom_type,
$self->assembly->id,
$self->chrom_length);
my $dbID = $sth->{'mysql_insertid'};
$sth->finish;
return undef unless($dbID);
$self->primary_id($dbID);
return $self;
}
=head2 update
Description : updates the data of this instance. require the Chrom to have been
fetched from database. It must have database() and primary_id()
Returntype : $self
Exceptions : none
=cut
sub update {
my $self = shift;
return undef unless($self->database and $self->id);
my $dbh = $self->database->get_connection;
my $sql = "UPDATE chrom set chrom_length=?, description=?, chrom_type=? where chrom_id=?";
my $sth = $dbh->prepare($sql);
$sth->execute($self->chrom_length,
$self->description,
$self->chrom_type,
$self->id);
return $self;
}
##### DBObject instance override methods #####
#mapRow is an internal method used by the MappedQuery template machinery
sub mapRow {
my $self = shift;
my $rowHash = shift;
my $dbh = shift;
$self->primary_id($rowHash->{'chrom_id'});
$self->chrom_name($rowHash->{'chrom_name'});
$self->chrom_length($rowHash->{'chrom_length'});
$self->chrom_type($rowHash->{'chrom_type'});
my $assembly = EEDB::Assembly->fetch_by_id($self->database, $rowHash->{'assembly_id'});
$self->assembly($assembly);
if($__riken_gsc_chrom_global_should_cache != 0) {
$__riken_gsc_chrom_global_id_cache->{$self->database() . $self->id} = $self;
$__riken_gsc_chrom_global_nameasm_cache->{$self->database() . $self->chrom_name. $rowHash->{'assembly_id'}} = $self;
}
return $self;
}
##### public class methods for fetching by utilizing DBObject framework methods #####
sub fetch_by_id {
my $class = shift;
my $db = shift;
my $id = shift;
if($__riken_gsc_chrom_global_should_cache != 0) {
my $chrom = $__riken_gsc_chrom_global_id_cache->{$db . $id};
if(defined($chrom)) { return $chrom; }
}
my $sql = "SELECT * FROM chrom WHERE chrom_id=?";
return $class->fetch_single($db, $sql, $id);
}
sub fetch_all {
my $class = shift;
my $db = shift;
my $sql = "SELECT * FROM chrom";
return $class->fetch_multiple($db, $sql);
( run in 1.167 second using v1.01-cache-2.11-cpan-d7f47b0818f )