Skip to content
Snippets Groups Projects
Commit 29c98e98 authored by Magali Ruffier's avatar Magali Ruffier
Browse files

avoid rounding errors

parent 94759eb8
No related branches found
No related tags found
No related merge requests found
......@@ -67,13 +67,13 @@ ok( $asi );
my $event = $asi->get_event("G2");
is(ref($event), 'Bio::EnsEMBL::StableIdEvent', "A stable id event was fetched");
is($event->score, 0.54, "Mapping score between G1 and G2");
is(sprintf("%.6f", $event->score), sprintf("%.6f", 0.54), "Mapping score between G1 and G2");
my $string = $event->ident_string();
my $old_archive_stable_id = $event->old_ArchiveStableId;
my $new_archive_stable_id = $event->new_ArchiveStableId;
is($string, "G2.3 (3) -> G1.2 (4) [0.54]", "Event string");
like($string, qr/G2.3 \(3\) -> G1.2 \(4\) \[0.54/, "Event string");
is($new_archive_stable_id, $asi, "Initial archive is new archive");
is($old_archive_stable_id->stable_id, "G2", "Old stable id");
......@@ -81,7 +81,7 @@ is($new_archive_stable_id->stable_id, "G1", "New stable id");
$event = $old_archive_stable_id->get_event("G1");
is($event->score, 0.54, "Mapping score between G1 and G2");
is(sprintf("%.6f", $event->score), sprintf("%.6f", 0.54), "Mapping score between G1 and G2");
$old_archive_stable_id = $event->old_ArchiveStableId;
$new_archive_stable_id = $event->new_ArchiveStableId;
......
......@@ -48,7 +48,7 @@ my $chr_slice = $db->get_SliceAdaptor->fetch_by_region('chromosome','20',
$feats = $dafa->fetch_all_by_Slice($chr_slice);
debug('---fetching by chromosomal slice---');
debug("Got " . scalar(@$feats) . " features back");
ok(@$feats == 6188);
is(@$feats, 6188, "Found 6188 features");
print_features($feats);
......@@ -60,7 +60,7 @@ $ctg_slice = $db->get_SliceAdaptor->fetch_by_region('contig',
$feats = $dafa->fetch_all_by_Slice($ctg_slice);
debug('--- contig AL031658.11.1.162976 (1-50000) features ---');
debug("Got " . scalar(@$feats));
ok(@$feats == 709);
is(@$feats, 709, "found 709 features");
print_features($feats);
......@@ -71,9 +71,8 @@ my $feat = $dafa->fetch_by_dbID(22171863);
debug('--- fetching by dbID ---');
ok($feat);
print_features([$feat]);
ok($feat->db_name eq 'EMBL');
ok($feat->db_display_name eq 'EMBL');
is($feat->db_name, 'EMBL', "Correct feature db_name");
is($feat->db_display_name, 'EMBL', "Correct feature db_display_name");
$feat = $feat->transform('supercontig');
debug('--- transform to supercontig coords ---');
......@@ -87,7 +86,7 @@ print_features([$feat]);
$feats = $dafa->fetch_all_by_Slice_and_pid($chr_slice, '90');
debug('--- fetching by chr Slice and pid (90) ---');
debug("Got " . scalar(@$feats));
ok(@$feats == 452);
is(@$feats, 452, "Found 452 features");
#print_features($feats);
#
......@@ -148,22 +147,21 @@ my $dbID = $feat->dbID();
$feat = $dafa->fetch_by_dbID($dbID, 'contig');
ok($feat->dbID == $dbID);
ok($feat->start == $start);
ok($feat->end == $end);
ok($feat->strand == $strand);
ok($feat->slice->name eq $slice->name);
ok($feat->hstart == $hstart);
ok($feat->hend == $hend);
ok($feat->hstrand == $hstrand);
ok($feat->hseqname eq $hseqname);
ok($feat->cigar_string eq $cigar_string);
ok($feat->percent_id == $percent_id);
ok($feat->score == $score);
ok($feat->p_value == $evalue);
ok($feat->analysis->logic_name eq $analysis->logic_name);
ok($feat->external_db_id == $external_db_id);
ok($feat->hcoverage == $hcoverage);
is($feat->dbID, $dbID, "Correct dbID");
is($feat->start, $start, "Correct start");
is($feat->end, $end, "Correct end");
is($feat->strand, $strand, "Correct strand");
is($feat->slice->name, $slice->name, "Correct name");
is($feat->hstart, $hstart, "Correct hstart");
is($feat->hend, $hend, "Correct hend");
is($feat->hseqname, $hseqname, "Correct hseqname");
is($feat->cigar_string, $cigar_string, "Correct cigar string");
is($feat->percent_id, $percent_id, "Correct percent id");
is($feat->score, $score, "Correct score");
is(sprintf("%.6f", $feat->p_value), sprintf("%.6f", $evalue), "Correct evalue");
is($feat->analysis->logic_name, $analysis->logic_name, "Correct logic_name");
is($feat->external_db_id, $external_db_id, "Correct external_db_id");
is($feat->hcoverage, $hcoverage, "Correct hcoverage");
my @attribs = @{$feat->get_all_Attributes};
is(@attribs, 1, "Stored 1 attribute");
......
......@@ -52,7 +52,7 @@ my $chr_slice = $db->get_SliceAdaptor->fetch_by_region('chromosome','20',
$feats = $pafa->fetch_all_by_Slice($chr_slice);
debug('---fetching by chromosomal slice---');
debug("Got " . scalar(@$feats) . " features back");
ok(@$feats == 2429);
is(@$feats, 2429, "Found 2429 features");
print_features($feats);
my $ctg_slice;
......@@ -63,7 +63,7 @@ $ctg_slice = $db->get_SliceAdaptor->fetch_by_region('contig',
$feats = $pafa->fetch_all_by_Slice($ctg_slice);
debug('--- contig AL031658.11.1.162976 (1-50000) features ---');
debug("Got " . scalar(@$feats));
ok(@$feats == 357);
is(@$feats, 357, "Found 357 features");
print_features($feats);
......@@ -74,8 +74,8 @@ my $feat = $pafa->fetch_by_dbID(5339568);
debug('--- fetching by dbID ---');
ok($feat);
print_features([$feat]);
ok($feat->db_name eq 'EMBL');
ok($feat->db_display_name eq 'EMBL');
is($feat->db_name, 'EMBL', "Correct feature db_name");
is($feat->db_display_name, 'EMBL', "Correct feature db_display_name");
$feat = $feat->transform('supercontig');
debug('--- transforming to supercontig coords ---');
......@@ -89,7 +89,7 @@ print_features([$feat]);
$feats = $pafa->fetch_all_by_Slice_and_pid($chr_slice, '90');
debug('--- fetching by chr Slice and pid (90) ---');
debug("Got " . scalar(@$feats));
ok(@$feats == 64);
is(@$feats, 64, "Found 64 features");
print_features($feats);
#
......@@ -142,21 +142,21 @@ my $dbID = $feat->dbID();
$feat = $pafa->fetch_by_dbID($dbID);
ok($feat->dbID == $dbID);
ok($feat->start == $start);
ok($feat->end == $end);
ok($feat->strand == $strand);
ok($feat->slice->name eq $slice->name);
ok($feat->hstart == $hstart);
ok($feat->hend == $hend);
ok($feat->hseqname eq $hseqname);
ok($feat->cigar_string eq $cigar_string);
ok($feat->percent_id == $percent_id);
ok($feat->score == $score);
ok($feat->p_value == $evalue);
ok($feat->analysis->logic_name eq $analysis->logic_name);
ok($feat->external_db_id == $external_db_id);
ok($feat->hcoverage == $hcoverage);
is($feat->dbID, $dbID, "Correct dbID");
is($feat->start, $start, "Correct start");
is($feat->end, $end, "Correct end");
is($feat->strand, $strand, "Correct strand");
is($feat->slice->name, $slice->name, "Correct name");
is($feat->hstart, $hstart, "Correct hstart");
is($feat->hend, $hend, "Correct hend");
is($feat->hseqname, $hseqname, "Correct hseqname");
is($feat->cigar_string, $cigar_string, "Correct cigar string");
is($feat->percent_id, $percent_id, "Correct percent id");
is($feat->score, $score, "Correct score");
is(sprintf("%.6f", $feat->p_value), sprintf("%.6f", $evalue), "Correct evalue");
is($feat->analysis->logic_name, $analysis->logic_name, "Correct logic_name");
is($feat->external_db_id, $external_db_id, "Correct external_db_id");
is($feat->hcoverage, $hcoverage, "Correct hcoverage");
$multi->restore('core', 'protein_align_feature');
......
......@@ -40,7 +40,7 @@ my $pfs = $pfa->fetch_all_by_translation_id(21724);
print_features($pfs);
ok(@$pfs == 15);
is(@$pfs, 15, "Found 15 features");
sub print_features {
my $features = shift;
......@@ -106,13 +106,13 @@ is($f_by_dbID->hend, $hend);
is($f_by_dbID->hseqname, $hseqname);
is($f_by_dbID->hdescription, $hdes);
is($f_by_dbID->score, $score);
is($f_by_dbID->percent_id, $percent_id);
is($f_by_dbID->p_value, $p_value);
is(sprintf("%.6f", $f_by_dbID->percent_id), sprintf("%.6f", $percent_id), "Correct percent_id");
is(sprintf("%.6f", $f_by_dbID->p_value), sprintf("%.6f", $p_value), "Correct p_value");
$pfs = $pfa->fetch_all_by_translation_id(21724);
ok(@$pfs == 16);
is(@$pfs, 16, "Found 16 features");
my @pfs = grep{$_->hdescription() eq $hdes} @$pfs;
......
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