This module is an entry point into a glovar database. It allows you to retrieve
traces from Glovar
sub fetch_Light_Trace_by_chr_start_end
{ my ($self,$slice) = @_;
my $slice_chr = $slice->chr_name();
my $slice_start = $slice->chr_start();
my $slice_end = $slice->chr_end();
my $ass_name = $slice->assembly_name();
my $ass_version = $slice->assembly_version();
my $key = join(":", $slice_chr, $slice_start, $slice_end);
if ($self->{'_cache'}->{$key}) {
return $self->{'_cache'}->{$key};
}
&eprof_start('glovar_trace2');
my $q = qq(
SELECT
ms.snp_rea_id_read as read_id,
sr.readname as readname,
ms.contig_match_start as contig_start,
ms.contig_match_end as contig_end,
ms.contig_orientation as read_ori,
ms.read_match_start as read_start,
ms.read_match_end as read_end,
ssm.start_coordinate as chr_start,
ssm.end_coordinate as chr_end,
ssm.contig_orientation as contig_ori
FROM chrom_seq cs,
seq_seq_map ssm,
mapped_seq ms,
snp_read sr,
database_dict dd
WHERE cs.database_seqname = '$slice_chr'
AND dd.database_version = '$ass_version'
AND dd.database_name = '$ass_name'
AND cs.database_source = dd.id_dict
AND cs.id_chromseq = ssm.id_chromseq
AND ssm.sub_sequence = ms.id_sequence
AND ms.snp_rea_id_read = sr.id_read
AND ssm.start_coordinate
BETWEEN
($slice_start - ms.contig_match_end + 1)
AND
($slice_end - ms.contig_match_start + 1)
);
my $sth;
eval {
$sth = $self->prepare($q);
$sth->execute();
};
if ($@){
warn("ERROR: SQL failed in " . (caller(0))[3] . "\n$@");
return([]);
}
my @traces = ();
while (my $row = $sth->fetchrow_hashref()) {
return([]) unless keys %{$row};
warn "Contig is in reverse orientation. THIS IS BAD!"
if ($row->{'CONTIG_ORI'} == -1);
my $start = $row->{'CONTIG_START'} + $row->{'CHR_START'} - 1;
my $end = $row->{'CONTIG_END'} + $row->{'CHR_START'} - 1;
my $strand = $row->{'READ_ORI'};
my $trace = Bio::EnsEMBL::MapFrag->new(
$slice_start,
$row->{'READ_ID'},
'clone',
$slice_chr,
'Chromosome',
$start,
$end,
$strand,
$row->{'READNAME'},
);
$trace->add_annotation('read_start', $row->{'READ_START'});
$trace->add_annotation('read_end', $row->{'READ_END'});
$trace->add_annotation('strand', $strand);
push (@traces, $trace);
}
@{$self->{'_cache'}->{$key}} =
sort { $a->seq_start <=> $b->seq_start }
@traces;
&eprof_end('glovar_trace2');
return $self->{'_cache'}->{$key}; } |
sub fetch_all_by_Slice
{ my ($self, $slice, $is_light) = @_;
unless ($slice->assembly_name && $slice->assembly_version) {
warn ("Cannot determine assembly name and version from Slice in GlovarAdaptor!\n");
return ([]);
}
my @f = ();
if($is_light){
push @f, @{$self->fetch_Light_Trace_by_chr_start_end($slice)};
} else {
push @f, @{$self->fetch_Trace_by_chr_start_end($slice)};
}
return(\@f); } |