Bio::EnsEMBL::ExternalData::SangerSNP
TranscriptVariationAdaptor
Toolbar
Summary
Bio::EnsEMBL::ExternalData::SangerSNP::TranscriptVariationAdaptor
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
A SNP adaptor which sits over the Sanger SNP database. Provides a means of
getting SNPs out of the Sanger SNP database as
Bio::EnsEMBL::Variation::VariationFeature objects.
Description
No description!
Methods
consequence_exp | Description | Code |
coordinate_systems | No description | Code |
fetch_all_by_VariationFeatures | No description | Code |
fetch_all_by_postype_consequence | No description | Code |
fetch_all_by_transcript_stable_id | No description | Code |
Methods description
Arg[1] : (optional) consequence experiment id Example : $glovar_adaptor->consequence_ext(2046); Description : getter/setter for the consequence experiment (coding_sequence.design_entry in the glovar db) Return type : String - consequence experiment id Exceptions : none Caller : general |
Methods code
sub consequence_exp
{ my ($self, $exp) = @_;
if ($exp) {
$self->{'consequence_exp'} = $exp;
}
return $self->{'consequence_exp'};
}
1; } |
sub coordinate_systems
{ return ("ASSEMBLY"); } |
sub fetch_all_by_VariationFeatures
{ my ($self, $vf_ref) = @_;
if(ref($vf_ref) ne 'ARRAY') {
throw('ArrayRef of Bio::EnsEMBL::Variation::VariationFeature expected');
}
my %vf_by_id;
my %v_by_id;
%vf_by_id = map {$_->dbID() . ":" . ($_->start + $_->slice->start - 1), $_ } @$vf_ref;
%v_by_id = map {$_->dbID(), $_ } @$vf_ref;
my $instr = join (",",keys( %v_by_id));
my $q = qq(
SELECT
sgc.id_snp as idsnp,
ptd.description as pos_type,
sgc_dict.description as consequence,
cs.name as transcript_stable_id,
sgc.transcript_position as cdna_start,
sgc.genomic_position as gen_pos
FROM
coding_sequence cs,
snp_gene_consequence sgc,
position_type_dict ptd,
sgc_dict
WHERE sgc.id_snp in ($instr)
AND sgc.consequence = sgc_dict.id_dict
AND sgc.position_description = ptd.id_dict
AND sgc.id_codingseq = cs.id_codingseq
AND cs.design_entry = ?
);
my $sth;
eval {
$sth = $self->prepare($q);
$sth->execute($self->consequence_exp);
};
if ($@){
warn("ERROR: SQL failed in " . (caller(0))[3] . "\n$@");
return;
}
my %trans_hash;
foreach my $vf (@$vf_ref) {
$vf->{transcriptVariations} = [];
}
my @tvs;
while (my $row = $sth->fetchrow_hashref) {
my $conskey = $row->{'POS_TYPE'}." ".$row->{'CONSEQUENCE'};
my $consequence_type = $CONSEQUENCE_TYPE_MAP{$conskey};
my $vfkey = $row->{IDSNP} . ":" . $row->{GEN_POS};
if (exists($vf_by_id{$vfkey})) {
$vf_by_id{$vfkey}->add_consequence_type($consequence_type);
my $tsid = $row->{'TRANSCRIPT_STABLE_ID'};
if (!exists($trans_hash{$tsid})) {
$trans_hash{$tsid} = $self->ensembl_db->get_TranscriptAdaptor->fetch_by_stable_id($tsid);
}
my $tvar = Bio::EnsEMBL::Variation::TranscriptVariation->new_fast({
transcript => $trans_hash{$tsid},
cdna_start => $row->{'CDNA_START'},
cdna_end => $row->{'CDNA_START'},
consequence_type => $consequence_type,
});
$vf_by_id{$vfkey}->add_TranscriptVariation( $tvar );
push @tvs,$tvar;
}
}
return\@ tvs; } |
sub fetch_all_by_postype_consequence
{ my ($self, $postype, $consequence) = @_;
my $q = qq(
SELECT
sgc.id_snp as idsnp,
ptd.description as pos_type,
sgc_dict.description as consequence,
cs.name as transcript_stable_id,
sgc.transcript_position as cdna_start,
sgc.genomic_position as gen_pos
FROM
coding_sequence cs,
snp_gene_consequence sgc,
position_type_dict ptd,
sgc_dict
WHERE sgc_dict.description = ?
AND ptd.description = ?
AND sgc.consequence = sgc_dict.id_dict
AND sgc.position_description = ptd.id_dict
AND sgc.id_codingseq = cs.id_codingseq
AND cs.design_entry = ?
);
my $sth;
eval {
$sth = $self->prepare($q);
$sth->execute($consequence,$postype,$self->consequence_exp);
};
if ($@){
warn("ERROR: SQL failed in " . (caller(0))[3] . "\n$@");
return;
}
my %trans_hash;
my %vf_hash;
my @tvs;
while (my $row = $sth->fetchrow_hashref) {
my $conskey = $row->{'POS_TYPE'}." ".$row->{'CONSEQUENCE'};
my $consequence_type = $CONSEQUENCE_TYPE_MAP{$conskey};
my $tsid = $row->{TRANSCRIPT_STABLE_ID};
if (!exists($trans_hash{$tsid})) {
$trans_hash{$tsid} = $self->ensembl_db->get_TranscriptAdaptor->fetch_by_stable_id($tsid);
}
my $vfid = $row->{IDSNP};
my $vfkey = $row->{IDSNP} . ":" . $row->{GEN_POS};
if (!exists($vf_hash{$vfkey})) {
$vf_hash{$vfkey} = $self->db->get_VariationAdaptor->fetch_by_dbID_position_range($vfid,$trans_hash{$tsid}->seq_region_name,
$row->{GEN_POS}, $row->{GEN_POS});
}
if (defined($vf_hash{$vfkey})) {
my $tvar = Bio::EnsEMBL::Variation::TranscriptVariation->new_fast({
transcript => $trans_hash{$tsid},
cdna_start => $row->{CDNA_START},
cdna_end => $row->{CDNA_START},
consequence_type => $consequence_type,
variation_feature => $vf_hash{$vfkey},
});
$vf_hash{$vfkey}->add_TranscriptVariation( $tvar );
$vf_hash{$vfkey}->add_consequence_type($consequence_type);
push @tvs,$tvar;
} else {
print "Missing variation feature " . $row->{IDSNP} . " for transcript " . $tsid .
" " . $trans_hash{$tsid}->seq_region_name . " " . $trans_hash{$tsid}->start . " " .
$trans_hash{$tsid}->end . " at " . $row->{GEN_POS} . "\n";
}
}
return\@ tvs; } |
fetch_all_by_transcript_stable_id | description | prev | next | Top |
sub fetch_all_by_transcript_stable_id
{ my ($self, $trans_stable_id) = @_;
my $q = qq(
SELECT
sgc.id_snp as idsnp,
ptd.description as pos_type,
sgc_dict.description as consequence,
cs.name as transcript_stable_id,
sgc.transcript_position as cdna_start,
sgc.genomic_position as gen_pos
FROM
coding_sequence cs,
snp_gene_consequence sgc,
position_type_dict ptd,
sgc_dict
WHERE cs.name = ?
AND sgc.consequence = sgc_dict.id_dict
AND sgc.position_description = ptd.id_dict
AND sgc.id_codingseq = cs.id_codingseq
AND cs.design_entry = ?
);
my $sth;
eval {
$sth = $self->prepare($q);
$sth->execute($trans_stable_id,$self->consequence_exp);
};
if ($@){
warn("ERROR: SQL failed in " . (caller(0))[3] . "\n$@");
return;
}
my %trans_hash;
my %vf_hash;
my @tvs;
while (my $row = $sth->fetchrow_hashref) {
my $conskey = $row->{'POS_TYPE'}." ".$row->{'CONSEQUENCE'};
my $consequence_type = $CONSEQUENCE_TYPE_MAP{$conskey};
my $tsid = $row->{TRANSCRIPT_STABLE_ID};
if (!exists($trans_hash{$tsid})) {
$trans_hash{$tsid} = $self->ensembl_db->get_TranscriptAdaptor->fetch_by_stable_id($tsid);
}
my $vfid = $row->{IDSNP};
my $vfkey = $row->{IDSNP} . ":" . $row->{GEN_POS};
if (!exists($vf_hash{$vfid})) {
$vf_hash{$vfkey} = $self->db->get_VariationAdaptor->fetch_by_dbID_position_range($vfid,$trans_hash{$tsid}->seq_region_name,
$row->{GEN_POS},$row->{GEN_POS});
}
if (defined($vf_hash{$vfid})) {
my $tvar = Bio::EnsEMBL::Variation::TranscriptVariation->new_fast({
transcript => $trans_hash{$tsid},
cdna_start => $row->{CDNA_START},
cdna_end => $row->{CDNA_START},
consequence_type => $consequence_type,
variation_feature => $vf_hash{$vfkey},
});
$vf_hash{$vfkey}->add_TranscriptVariation( $tvar );
$vf_hash{$vfkey}->add_consequence_type($consequence_type);
push @tvs,$tvar;
} else {
print "Missing variation feature " . $row->{IDSNP} . " for transcript " . $tsid .
" " . $trans_hash{$tsid}->seq_region_name . " " . $trans_hash{$tsid}->start . " " .
$trans_hash{$tsid}->end . " at " . $row->{GEN_POS} . "\n";
}
}
return\@ tvs; } |
General documentation