bridgedb / BridgeDb

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

Function to get Prefix for Datasource #168

Closed mkutmon closed 3 years ago

mkutmon commented 3 years ago

Is it possible to implement a function for datasource to get the prefix? Currently, you can parse it per identifier using the Xref function getMiriamURN() but it would be nice to just get the prefix for a datasource directly.

Example:

DataSource ds = DataSource.getExistingBySystemCode("L");
String prefix = ds.getPrefix();

Output would be "ncbigene"

mkutmon commented 3 years ago
Xref x = new Xref("1234", DataSource.getExistingBySystemCode("L"));
String urn = x.getMiriamURN();

That results in "urn:miriam:ncbigene:1234" which contains the prefix but it's a little cumbersome to access it like this.

egonw commented 3 years ago

I just implemented this, which will be part of BridgeDb 3.0.5, which I'll release later today (I intend):

DataSource ds = DataSource.getExistingBySystemCode("L");
String prefix = ds.getCompactIdentifierPrefix();