Skip to content
Snippets Groups Projects
Commit d2da46d2 authored by Ian Longden's avatar Ian Longden
Browse files

more tests

parent 5d1ce6c9
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@ use IPC::Open3;
##### Unlinked entries ##############
# ERRORS
# dependent_xref and xref
# primary_xref and xref
# transcript_direct_xref and xref
......@@ -32,14 +33,12 @@ use IPC::Open3;
# gene_transcript_translation and transcript_stable_id
# gene_transcript_translation and translation_stable_id
##### if human or mouse check the number of gene name changes.
##### All go_xref have a linkage_type
# All object_xref of type go have a go_xref entry
##### All object_xref of type go have a go_xref entry
##### Numbers between xref and core (xref and object_xref) are similar
##### if human or mouse check the number of gene name changes.
sub new {
my($class, $mapper) = @_;
......@@ -85,6 +84,7 @@ sub unlinked_entries{
$count_sql = "select count(1) from dependent_xref d left join xref x on d.dependent_xref_id = x.xref_id where x.xref_id is null";
$sql = "select distinct(d.dependent_xref_id) from dependent_xref d left join xref x on d.dependent_xref_id = x.xref_id where x.xref_id is null limit 10";
$sth = $self->xref->dbc->prepare($count_sql);
......@@ -94,7 +94,7 @@ sub unlinked_entries{
$sth->finish;
if($count){
$failed = 0;
$failed = 1;
$sth = $self->xref->dbc->prepare($sql);
$sth->execute();
$sth->bind_columns(\$xref_id);
......@@ -105,7 +105,213 @@ sub unlinked_entries{
$sth->finish;
}
$count_sql = "select count(1) from primary_xref d left join xref x on d.xref_id = x.xref_id where x.xref_id is null";
$sql = "select distinct(d.xref_id) from primary_xref d left join xref x on d.xref_id = x.xref_id where x.xref_id is null limit 10";
$sth = $self->xref->dbc->prepare($count_sql);
$sth->execute();
$sth->bind_columns(\$count);
$sth->fetch();
$sth->finish;
if($count){
$failed = 1;
$sth = $self->xref->dbc->prepare($sql);
$sth->execute();
$sth->bind_columns(\$xref_id);
print "SQL QUERY: $sql\n";
while($sth->fetch){
print "Problem with primary xref $xref_id\n";
}
$sth->finish;
}
foreach my $type (qw(transcript translation gene)){
$count_sql = "select count(1) from ".$type."_direct_xref d left join xref x on d.general_xref_id = x.xref_id where x.xref_id is null";
$sql = "select distinct(d.xref_id) from ".$type."_direct_xref d left join xref x on d.general_xref_id = x.xref_id where x.xref_id is null limit 10";
$sth = $self->xref->dbc->prepare($count_sql);
$sth->execute();
$sth->bind_columns(\$count);
$sth->fetch();
$sth->finish;
if($count){
$failed = 1;
$sth = $self->xref->dbc->prepare($sql);
$sth->execute();
$sth->bind_columns(\$xref_id);
print "SQL QUERY: $sql\n";
while($sth->fetch){
print "Problem with ".$type."_direct_xref $xref_id\n";
}
$sth->finish;
}
}
$count_sql = "select count(1) from synonym d left join xref x on d.xref_id = x.xref_id where x.xref_id is null";
$sql = "select distinct(d.xref_id) from synonym d left join xref x on d.xref_id = x.xref_id where x.xref_id is null limit 10";
$sth = $self->xref->dbc->prepare($count_sql);
$sth->execute();
$sth->bind_columns(\$count);
$sth->fetch();
$sth->finish;
if($count){
$failed = 1;
$sth = $self->xref->dbc->prepare($sql);
$sth->execute();
$sth->bind_columns(\$xref_id);
print "SQL QUERY: $sql\n";
while($sth->fetch){
print "Problem with synonym $xref_id\n";
}
$sth->finish;
}
$count_sql = "select count(1) from identity_xref d left join object_xref o on d.object_xref_id = o.object_xref_id where o.object_xref_id is null";
$sql = "select distinct(d.object_xref_id) from identity d left join object_xref o on d.object_xref_id = o.object_xref_id where o.object_xref_id is null limit 10";
$sth = $self->xref->dbc->prepare($count_sql);
$sth->execute();
$sth->bind_columns(\$count);
$sth->fetch();
$sth->finish;
if($count){
$failed = 1;
$sth = $self->xref->dbc->prepare($sql);
$sth->execute();
$sth->bind_columns(\$xref_id);
print "SQL QUERY: $sql\n";
while($sth->fetch){
print "Problem with object_xref $xref_id\n";
}
$sth->finish;
}
$count_sql = "select count(1) from go_xref d left join object_xref o on d.object_xref_id = o.object_xref_id where o.object_xref_id is null";
$sql = "select distinct(d.object_xref_id) from go_xref d left join object_xref o on d.object_xref_id = o.object_xref_id where o.object_xref_id is null limit 10";
$sth = $self->xref->dbc->prepare($count_sql);
$sth->execute();
$sth->bind_columns(\$count);
$sth->fetch();
$sth->finish;
if($count){
$failed = 1;
$sth = $self->xref->dbc->prepare($sql);
$sth->execute();
$sth->bind_columns(\$xref_id);
print "SQL QUERY: $sql\n";
while($sth->fetch){
print "Problem with object_xref $xref_id\n";
}
$sth->finish;
}
foreach my $type (qw(transcript translation gene)){
$count_sql = "select count(1) from gene_transcript_translation d left join ".$type."_stable_id x on d.".$type."_id = x.internal_id where x.internal_id is null and d.".$type."_id is not null";
$sql = "select distinct(d.".$type."_id) from gene_transcript_translation d left join ".$type."_stable_id x on d.".$type."_id = x.internal_id where x.internal_id is null and d.".$type."_id is not null limit 10";
$sth = $self->xref->dbc->prepare($count_sql);
$sth->execute();
$sth->bind_columns(\$count);
$sth->fetch();
$sth->finish;
if($count){
$failed = 1;
$sth = $self->xref->dbc->prepare($sql);
$sth->execute();
$sth->bind_columns(\$xref_id);
print "SQL QUERY: $sql\n";
while($sth->fetch){
print "Problem with ".$type."_id $xref_id\n";
}
$sth->finish;
}
}
$count_sql = "select count(1) from xref x, source s, object_xref o left join go_xref g on o.object_xref_id = g.object_xref_id where x.xref_id = o.xref_id and s.source_id = x.source_id and s.name like 'GO' and g.object_xref_id is null";
$sql = "select distinct(o.object_xref_id) from xref x, source s, object_xref o left join go_xref g on o.object_xref_id = g.object_xref_id where x.xref_id = o.xref_id and s.source_id = x.source_id and s.name like 'GO' and g.object_xref_id is null limit 10";
my $sth = $self->xref->dbc->prepare($count_sql);
$sth->execute();
$sth->bind_columns(\$count);
$sth->fetch();
$sth->finish;
if($count){
$failed = 1;
$sth = $self->xref->dbc->prepare($sql);
$sth->execute();
$sth->bind_columns(\$xref_id);
print "SQL QUERY: $sql\n";
while($sth->fetch){
print "Problem with object_xref $xref_id which is linked to a GO source but has no go_xref reference\n";
}
$sth->finish;
}
return $failed;
}
sub entry_number_check{
my ($self) = @_;
# No point doing xrefs object_xrefs are more important and gives a better indication of wether things went okay.
my %old_object_xref_count;
my %new_object_xref_count;
my $sth = $self->xref->dbc->prepare('select s.name, count(*) from xref x, object_xref ox, source s where ox.xref_id = x.xref_id and x.source_id = s.source_id and ox_status = "DUMP_OUT" group by s.name');
$sth->execute();
my ($name, $count);
$sth->bind_columns(\$name,\$count);
while($sth->fetch()){
$new_object_xref_count{$name} = $count;
}
$sth->finish;
$sth = $self->core->dbc->prepare('select e.db_name, count(*) from xref x, object_xref ox, external_db e where ox.xref_id = x.xref_id and x.external_db_id = e.external_db_id group by e.db_name');
$sth->execute();
$sth->bind_columns(\$name,\$count);
while($sth->fetch()){
my $change = 0;
if(defined($new_object_xref_count{$name})){
$change = (($new_object_xref_count{$name} - $count)/$new_object_xref_count{$name}) * 100;
if($change > 5){ # increase of 5%
print "WARNING: $name has increased by $change\% was $count now ". $new_object_xref_count{$name}. "\n";
}
elsif($change < -5){ # decrease by 5%
print "WARNING: $name has decreased by $change\% was $count now ". $new_object_xref_count{$name}. "\n";
}
}
}
$sth->finish;
return;
}
1;
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