By @rpinho
Refereed correctness bugs in open-source research software, with patches and links to upstream PRs
diff --git a/lib/GO/AnnotationProvider/AnnotationParser.pm b/lib/GO/AnnotationProvider/AnnotationParser.pm
index d196016..1201240 100755
--- a/lib/GO/AnnotationProvider/AnnotationParser.pm
+++ b/lib/GO/AnnotationProvider/AnnotationParser.pm
@@ -580,7 +580,7 @@ sub __init{
@line = split("\t", $_, -1);
- next if $line[$kNotColumn] eq 'NOT'; # skip annotations NOT to a GOID
+ next if $line[$kNotColumn] =~ /(?:^|\|)NOT(?:\||$)/; # skip annotations NOT to a GOID
($databaseId, $goid, $aspect) = @line[$kDatabaseIdColumn, $kGoidColumn, $kAspectColumn];
($standardName, $aliases) = @line[$kStandardNameColumn, $kAliasesColumn];
diff --git a/lib/GO/OntologyProvider/OboParser.pm b/lib/GO/OntologyProvider/OboParser.pm
index b13a61a..9f79a2a 100644
--- a/lib/GO/OntologyProvider/OboParser.pm
+++ b/lib/GO/OntologyProvider/OboParser.pm
@@ -273,18 +273,27 @@ sub __init { # okay
my @entryLine;
my $isValidEntry = 0;
+ my $isObsolete = 0;
my $namespace;
+ my $skipStanza = 0;
while (<$ontologyFh>){
chomp;
- # finish parsing the obo file of we reach the typedef line.
-
- last if (/^\[Typedef\]/);
+ # Finish the previous term and skip non-term stanzas, wherever they occur.
+ if (/^\[(?!Term\])[^]]+\]$/){
+ $self->__processNode(\@entryLine) if $isValidEntry;
+ @entryLine = ();
+ $isValidEntry = 0;
+ $namespace = q{};
+ $skipStanza = 1;
+ next;
+ }
if ($_ eq '[Term]') {
+ $skipStanza = 0;
# we reached a new term - so process the previous entry
@@ -299,25 +308,28 @@ sub __init { # okay
@entryLine = ();
$isValidEntry = 0;
+ $isObsolete = 0;
$namespace = '';
+ }elsif ($skipStanza){
+ next;
}elsif ($_ eq "namespace: $aspect"){
# term is in the requested namespace
$namespace = $aspect;
- $isValidEntry = 1;
+ $isValidEntry = !$isObsolete;
}elsif ($_ eq 'is_obsolete: true'){
# we don't want obsolete nodes - DO NOT COMMENT THIS OUT -
# infinite recursion will result!
- # Note, the logic here relies on the is_obsolete line coming after the
- # namespace line.
+ # Keep the obsolete flag regardless of the order of tags in this stanza.
$isValidEntry = 0;
+ $isObsolete = 1;
}else {
@@ -615,6 +627,10 @@ sub __findAncestors {
foreach my $ancestorGoid (@{$self->{$kParent}{$parentGoid}}) {
+ die "Cycle in ontology involving $ancestorGoid\n"
+ if $ancestorGoid eq $childNode->goid ||
+ grep { defined($_) && $_->goid eq $ancestorGoid } @{$pathArrayRef};
+
# add the ancestor node to our path to the root which is being
# built
diff --git a/lib/GO/TermFinder.pm b/lib/GO/TermFinder.pm
index 0104b3e..bb662c8 100644
--- a/lib/GO/TermFinder.pm
+++ b/lib/GO/TermFinder.pm
@@ -1771,7 +1771,9 @@ sub __samplingPopulation{
if ($self->__isUsingPopulation){
- @names = @{$self->__population};
+ # Resolve aliases and duplicates exactly as for the background counts.
+ my ($ids) = $self->__determineDatabaseIdsFromGenes($self->__population);
+ @names = @{$ids};
}else{
@@ -1974,8 +1976,16 @@ sub __calculateFDR{
# real data. We threshold this at a maximum of 1, as we can't
# have a FDR of greater than 100%
+ my $numDiscoveries = 0;
foreach (my $i = 0; $i < @realHypotheses; $i++){
+ # A p-value cutoff includes every member of a tie.
+ $numDiscoveries = $i + 1 if $numDiscoveries <= $i;
+ while ($numDiscoveries < @realHypotheses &&
+ $realHypotheses[$numDiscoveries]->{PVALUE} == $realHypotheses[$i]->{PVALUE}){
+ $numDiscoveries++;
+ }
+
if (exists $realHypotheses[$i]->{FDR_OBSERVATIONS}){
# the rate is the average number in the simulations that
@@ -1984,7 +1994,7 @@ sub __calculateFDR{
$realHypotheses[$i]->{FDR_OBSERVATIONS} /= $numSimulations;
- $realHypotheses[$i]->{FDR_RATE} = $realHypotheses[$i]->{FDR_OBSERVATIONS} / ($i + 1);
+ $realHypotheses[$i]->{FDR_RATE} = $realHypotheses[$i]->{FDR_OBSERVATIONS} / $numDiscoveries;
if ($realHypotheses[$i]->{FDR_RATE} > 1){
@@ -2009,7 +2019,7 @@ sub __calculateFDR{
# be chosen at this point, we can calculate the expected number of
# false positives, as the FDR x the number of hypotheses
- $realHypotheses[$i]->{EXPECTED_FALSE_POSITIVES} = $realHypotheses[$i]->{FDR_RATE} * ($i+1);
+ $realHypotheses[$i]->{EXPECTED_FALSE_POSITIVES} = $realHypotheses[$i]->{FDR_RATE} * $numDiscoveries;
}