Skip to content
Snippets Groups Projects
Commit 41b92fbd authored by Simon Potter's avatar Simon Potter
Browse files

adapted to work with tandem repeats

more mutilation of James' beautiful adaptor ...
parent 4321dc79
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@ use vars qw(@ISA);
sub fetch_by_RawContig {
my( $self, $contig ) = @_;
my @repeats = $self->fetch_by_contig_id($contig->dbID);
foreach my $r (@repeats) {
$r->attach_seq($contig);
......@@ -22,7 +22,7 @@ sub fetch_by_RawContig {
sub fetch_by_contig_id {
my( $self, $contig_id ) = @_;
return $self->_generic_fetch(
qq{ contig_id = $contig_id }
);
......@@ -30,7 +30,7 @@ sub fetch_by_contig_id {
sub fetch_by_dbID {
my( $self, $db_id ) = @_;
my ($rf) = $self->_generic_fetch(
qq{ repeat_feature_id = $db_id }
);
......@@ -39,7 +39,7 @@ sub fetch_by_dbID {
sub _generic_fetch {
my( $self, $where_clause ) = @_;
my( $repeat_feature_id,
$contig_id,
$contig_start,
......@@ -50,7 +50,7 @@ sub _generic_fetch {
$repeat_end,
$analysis_id,
);
my $sth = $self->prepare(qq{
SELECT repeat_feature_id
, contig_id
......@@ -63,7 +63,7 @@ sub _generic_fetch {
, analysis_id
FROM repeat_feature f
WHERE }. $where_clause);
$sth->execute;
$sth->bind_columns(
\$repeat_feature_id,
......@@ -76,7 +76,7 @@ sub _generic_fetch {
\$repeat_end,
\$analysis_id,
);
my $rca = $self->db->get_RepeatConsensusAdaptor;
my $aa = $self->db->get_AnalysisAdaptor;
......@@ -85,18 +85,18 @@ sub _generic_fetch {
# new in RepeatFeature takes no arguments
my $r = Bio::EnsEMBL::RepeatFeature->new;
$r->dbID($repeat_feature_id);
# So RepeatFeature can get its repeat
$r->repeat_consensus_adaptor($rca);
$r->repeat_id($repeat_id);
$r->contig_id( $contig_id );
$r->start ( $contig_start );
$r->end ( $contig_end );
$r->strand ( $contig_strand );
$r->hstart ( $repeat_start );
$r->hend ( $repeat_end );
my( $ana_obj );
unless ($ana_obj = $analysis_cache{$analysis_id}) {
$ana_obj = $aa->fetch_by_dbID($analysis_id)
......@@ -104,7 +104,7 @@ sub _generic_fetch {
$analysis_cache{$analysis_id} = $ana_obj;
}
$r->analysis($ana_obj);
push(@repeats, $r);
}
return( @repeats );
......@@ -115,7 +115,7 @@ sub store {
my $rca = $self->db->get_RepeatConsensusAdaptor;
my ($cons, $db_id);
$self->throw("Can't store repeats without a contig_id (got '$contig_id')")
unless $contig_id =~ /^\d+$/;
......@@ -134,31 +134,47 @@ sub store {
});
foreach my $rf (@repeats) {
unless ($rf->repeat_id) {
# must have a consensus attached
$self->throw("Must have a RepeatConsensus attached")
unless defined ($cons = $rf->repeat_consensus);
# need to get the consensus seq object for this repeat
# for tandem repeats - simply store consensus and repeat
# one pair per hit. don't need to check consensi stored
# already. consensus has name and class set to 'trf'
if ($cons->name eq 'trf') {
$rca->store($cons);
$rf->repeat_id($cons->dbID);
$self->throw("Must have a RepeatConsensus attached")
unless defined ($cons = $rf->repeat_consensus);
} else {
unless ($cons->dbID) {
my @match = ($rca->fetch_by_name($cons->name));
# for other repeats - need to see if a consensus is stored already
if (@match > 1) {
$self->warn(@match . " consensi for " . $cons->name . "\n");
}
# FIXME - need to take some action here if we don't
# match a consensus seq already stored
elsif (@match == 0) {
$self->warn("Can't find " . $cons->name . "\n");
$cons->repeat_consensus("N");
$rca->store($cons);
}
$db_id = ($rca->fetch_by_name($cons->name))[0]->dbID;
unless ($rf->repeat_id) {
$cons->dbID($db_id);
# need to get the consensus seq object for this repeat
unless ($cons->dbID) {
my @match = ($rca->fetch_by_name($cons->name));
if (@match > 1) {
$self->warn(@match . " consensi for " . $cons->name . "\n");
} elsif (@match == 0) {
# if we don't match a consensus already stored
# create a fake one
# set consensus to 'N' as null seq not allowed
# FIXME: not happy with this, but ho hum ...
$self->warn("Can't find " . $cons->name . "\n");
$cons->repeat_consensus("N");
$rca->store($cons);
}
$db_id = ($rca->fetch_by_name($cons->name))[0]->dbID;
$cons->dbID($db_id);
}
$rf->repeat_id($cons->dbID);
}
$rf->repeat_id($cons->dbID);
}
$sth->execute(
......
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