EdgeExpressDB
view release on metacpan or search on metacpan
lib/EEDB/Feature.pm view on Meta::CPAN
chrom_end,
strand,
significance,
primary_name)
VALUES(?,?,?,?,?,?,?)";
my $sth = $dbh->prepare($sql);
$sth->execute($self->feature_source->id,
$chrom_id,
$self->chrom_start,
$self->chrom_end,
$self->strand,
$self->significance,
$self->primary_name);
my $dbID = $dbh->last_insert_id(undef, undef, qw(feature feature_id));
$sth->finish;
return undef unless($dbID);
$self->primary_id($dbID);
#now do the symbols and metadata
$self->store_metadata;
#link to chunk system
$self->link_2_chunk();
return $self;
}
sub store_metadata {
my $self = shift;
die("error no database to store metadata\n") unless($self->database);
return unless($self->{'metadataset'}); #if not created then don't lazy load
my $mdata_list = $self->metadataset->metadata_list;
foreach my $mdata (@$mdata_list) {
if(!defined($mdata->primary_id)) {
$mdata->store($self->database);
$mdata->store_link_to_feature($self);
}
}
}
sub create_link_to_feature {
my $self = shift;
my $feature = shift;
my $link_type = shift;
my $dir = shift;
my $weight = shift;
die("error no database to store symbol\n") unless($self->database);
#first do insert ignore to make sure symbol is in the database
my $dbc = $self->database->get_connection;
my $sql = "INSERT ignore INTO edge ".
"(feature1_id, feature2_id, direction, sub_type, weight, edge_source_id) VALUES(?,?,?,?,?,0)";
my $sth = $dbc->prepare($sql);
$sth->execute($self->id, $feature->id, $dir, $link_type, $weight);
$sth->finish;
}
sub update_location {
my $self = shift;
die("error no database set\n") unless($self->database);
dies("Feature with undef id") unless(defined($self->primary_id));
my $chrom_id = undef;
if($self->chrom) { $chrom_id = $self->chrom_id; }
my $sql = "UPDATE feature SET primary_name=?, chrom_id=?, chrom_start=?, chrom_end=?, strand=? WHERE feature_id=?";
$self->database->execute_sql($sql,
$self->primary_name,
$chrom_id,
$self->chrom_start,
$self->chrom_end,
$self->strand,
$self->id);
$self->link_2_chunk();
}
#################################################
#
# MappedQuery override methods - fetching
#
#################################################
sub mapRow {
my $self = shift;
my $rowHash = shift;
my $dbh = shift;
my $dbID = $rowHash->{'feature_id'};
if(($__riken_EEDB_feature_global_should_cache != 0) and ($self->database())) {
my $cached_self = $__riken_EEDB_feature_global_id_cache->{$self->database() . $dbID};
if(defined($cached_self)) {
#printf("link already loaded in cache, reuse\n");
#$cached_self->display_info;
#printf(" db_id :: %s\n", $cached_self->db_id);
return $cached_self;
}
}
$self->{'_primary_db_id'} = $rowHash->{'feature_id'};
$self->{'chrom_name'} = $rowHash->{'chrom_name'};
$self->{'chrom_start'} = $rowHash->{'chrom_start'};
$self->{'chrom_end'} = $rowHash->{'chrom_end'};
$self->{'strand'} = $rowHash->{'strand'};
$self->{'primary_name'} = $rowHash->{'primary_name'};
$self->{'significance'} = $rowHash->{'significance'};
$self->{'_chrom_id'} = $rowHash->{'chrom_id'};
$self->{'_feature_source_id'} = $rowHash->{'feature_source_id'};
if($rowHash->{'symbol_count'}) {
if($self->{'significance'}) {
$self->{'significance'} = $self->{'significance'} * $rowHash->{'symbol_count'};
} else {
$self->{'significance'} = $rowHash->{'symbol_count'};
}
( run in 0.500 second using v1.01-cache-2.11-cpan-39bf76dae61 )