Skip to content

Commit 195e131

Browse files
committed
possible bugfix, keep allowing null but filter for it and expand warning description
1 parent d44032b commit 195e131

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

boqa-core/src/main/java/org/p2gx/boqa/core/internal/OntologyTraverser.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ public Set<TermId> initLayer(Set<TermId> hpoTerms) {
122122
public static TermId getPrimaryTermId(TermId t){
123123
TermId primaryTermId = hpo.getPrimaryTermId(t);
124124
if (primaryTermId == null) {
125-
LOGGER.warn("Invalid HPO term {}! Skipping...", primaryTermId);
125+
if (LOGGED_REPLACEMENTS.add(t)) { // only log once per term
126+
LOGGER.warn("Invalid HPO term {}! Skipping it, this may negatively affect performance. " +
127+
"Are you using the latest HPO build? Consider running `download -w` to fetch the latest HPO release.", t);
128+
}
126129
} else {
127130
if (!t.equals(primaryTermId) && LOGGED_REPLACEMENTS.add(t)) {
128131
LOGGER.info("Replacing {} with primary term {}", t, primaryTermId);

boqa-core/src/main/java/org/p2gx/boqa/core/patient/PhenopacketData.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import java.nio.file.Path;
1414
import java.util.List;
15+
import java.util.Objects;
1516
import java.util.Set;
1617
import java.util.function.Predicate;
1718
import java.util.stream.Collectors;
@@ -49,6 +50,7 @@ public PhenopacketData(Phenopacket phenopacket) {
4950
.map(OntologyClass::getId)
5051
.map(TermId::of)
5152
.map(OntologyTraverser::getPrimaryTermId)
53+
.filter(Objects::nonNull) // If old HPO is used without a term, avoids the program crashing
5254
.collect(Collectors.toSet());
5355
if (this.observedTerms.isEmpty()) {
5456
LOGGER.warn("Phenopacket {} has no observed phenotypic features!", phenopacket.getId());
@@ -58,6 +60,7 @@ public PhenopacketData(Phenopacket phenopacket) {
5860
.map(OntologyClass::getId)
5961
.map(TermId::of)
6062
.map(OntologyTraverser::getPrimaryTermId)
63+
.filter(Objects::nonNull) // If old HPO is used without a term, avoids the program crashing
6164
.collect(Collectors.toSet());
6265
this.diseases = phenopacket.getDiseasesList().stream().map(d ->
6366
new DiseaseDTO(d.getTerm().getId(), d.getTerm().getLabel())).toList();

0 commit comments

Comments
 (0)