Commit 3703d953 authored by Alistair Rust's avatar Alistair Rust
Browse files

Modified in line with bringing slices on-line: specfically related to

adding and debugging the get_all_Genes method on Slice.pm
parent 9aa20137
......@@ -181,10 +181,10 @@ sub _exon_from_sth {
$exon->dbID($hashRef->{'exon_id'});
# make first component exon
my $component = $self->_new_Exon_from_hashRef($hashRef);
$exon->add_component_Exon($component);
$sticky_length += $component->length;
$sticky_str .= $component->seq->seq;
$sticky_str .= $component->seq;
$exon->phase($component->phase);
$exon->adaptor($self);
......@@ -195,7 +195,7 @@ sub _exon_from_sth {
$exon->add_component_Exon($component);
$sticky_length += $component->length;
$sticky_str = $component->seq->seq . $sticky_str;
$sticky_str = $component->seq . $sticky_str;
if( $component->sticky_rank == 1 ) {
$exon->contig( $component->contig );
......
......@@ -245,7 +245,6 @@ sub fetch_by_contig_list{
$str =~ s/\,$//g;
$str = "($str)";
#
# this is non-optimised, because we are going to make multiple
# trips to the database. should fix here
......@@ -292,18 +291,30 @@ sub fetch_by_Slice {
my @cids = $mapper->list_contig_ids( $slice->chr_name(),
$slice->chr_start(),
$slice->chr_end());
# no genes found so return
if ( scalar (@cids) == 0 ) {
return undef;
}
my $str = "(".join( ",",@cids ).")";
my $sth = $self->prepare("select distinct(t.gene_id) from transcript t,exon_transcript et,exon e where e.contig_id in $str and et.exon_id = e.exon_id and et.transcript_id = t.transcript_id");
my $sth = $self->prepare("
SELECT distinct(t.gene_id)
FROM transcript t,exon_transcript et,exon e
WHERE e.contig_id in $str
AND et.exon_id = e.exon_id
AND et.transcript_id = t.transcript_id");
$sth->execute;
while( my $arref = $sth->fetchrow_arrayref() ) {
my $gene = $self->fetch_by_dbID( $$arref );
my $newgene = $gene->transform( $slice );
while( my ($geneid) = $sth->fetchrow ) {
my $gene = $self->fetch_by_dbID( $geneid );
my $newgene = $gene->transform( $slice );
push( @out, $newgene );
}
return @out;
}
......
......@@ -86,8 +86,7 @@ sub fetch_by_contig_id_start_end_strand {
$sth = $self->prepare( "SELECT c.length, SUBSTRING( d.sequence, $start, $length )
FROM dna d, contig c
WHERE d.dna_id = c.dna_id
AND c.contig_id = $contig_id" );
AND c.contig_id = $contig_id" );
}
$sth->execute();
......@@ -129,6 +128,8 @@ sub fetch_by_contig_id_start_end_strand {
sub fetch_by_Slice_start_end_strand {
my ( $self, $slice, $start, $end, $strand ) = @_;
my $seq= "";
if( !$slice ){
$self->throw("need a slice to work\n");
}
......@@ -145,7 +146,7 @@ sub fetch_by_Slice_start_end_strand {
# need to check the strand'edness of the slice as this
# affects the direction in which the dna seq is grabbed
if ( $slice->strand == 1 ) {
$self->fetch_by_assembly_location
$seq = $self->fetch_by_assembly_location
(
$slice->chr_start()+$start-1,
$slice->chr_start()+$end-1,
......@@ -155,7 +156,7 @@ sub fetch_by_Slice_start_end_strand {
);
}
elsif ( $slice->strand == -1 ) {
$self->fetch_by_assembly_location
$seq = $self->fetch_by_assembly_location
(
$slice->chr_end()-$end+1,
$slice->chr_end()-$start+1,
......@@ -167,6 +168,7 @@ sub fetch_by_Slice_start_end_strand {
else {
$self->throw("Incorrect strand set on slice $slice");
}
return $seq;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment