bridgedb / BridgeDb

The BridgeDb Library source code
https://bridgedb.org/
Apache License 2.0
28 stars 21 forks source link

wrong Xref from Bioregistry compact identifier #240

Closed egonw closed 7 months ago

egonw commented 8 months ago

When I create a Xref from the compact identifier ensembl:ENSGALG00000007562 then it creates an Xref with the DataSource for OpenTargets with the system code Opt. OpenTargets uses the same Ensembl identifiers so it sort of makes sense, but it's not good.

We see this when we do the Xref.toString() and get Opt:ENSGALG00000007562:T where it should return En:ENSGALG00000007562:T.

@youphendriks, can you please create a unit test in the class a new test class XrefTest in the org.bridgedb.bio java package in the org.bridgedb.bio module (where DataSourceTxtTest.java is too)?

The test should check if Xref.fromBioregistryIdentifier("ensembl:ENSGALG00000007562").toString() equals En:ENSGALG00000007562:T.

youphendriks commented 8 months ago

Created the requested test class, however it results in a failure. Test class:

Xref xref = Xref.fromBioregistryIdentifier("ensembl:ENSGALG00000007562");
assertEquals("En:ENSGALG00000007562:T", xref.toString());

Test failure message:

Failures (1): JUnit Jupiter:XrefTest:testCheckCorrectBioregistryIdentifier() MethodSource [className = 'org.bridgedb.XrefTest', methodName = 'testCheckCorrectBioregistryIdentifier', methodParameterTypes = ''] => java.lang.NullPointerException: Cannot invoke "org.bridgedb.Xref.toString()" because "xref" is null org.bridgedb.XrefTest.testCheckCorrectBioregistryIdentifier(XrefTest.java:205) java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) java.base/java.lang.reflect.Method.invoke(Method.java:580) org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727) org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131) org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156) org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:147) org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:86) org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103) [...]

Created a test using a different identifier to check syntax, this results in a succesful test:

Xref xref = Xref.fromBioregistryIdentifier("uniprot:P12345");
assertEquals("S:P12345:T", xref.toString());

Found out the "ENSGALG00000007562" identifier is marked as " not in the current EnsEMBL database" on the ensembl website, maybe this has something to do with the issue?

youphendriks commented 8 months ago

Did not mean to close the issue since it is not fixed.

egonw commented 8 months ago

Created the requested test class, however it results in a failure. Test class:

Xref xref = Xref.fromBioregistryIdentifier("ensembl:ENSGALG00000007562");
assertEquals("En:ENSGALG00000007562:T", xref.toString());

I guess a assertNutNoll(xref) should be added between these too lines.

Created a test using a different identifier to check syntax, this results in a succesful test:

Xref xref = Xref.fromBioregistryIdentifier("uniprot:P12345");
assertEquals("S:P12345:T", xref.toString());

Yes, this is what you would expect also for the failing code. But that fail is enough for the test.

Found out the "ENSGALG00000007562" identifier is marked as " not in the current EnsEMBL database"

The method does not check that, actually, so that cannot be the reason.

egonw commented 7 months ago

Fixed