feat: function to return *all* matching genes/transcripts by id#201
feat: function to return *all* matching genes/transcripts by id#201
Conversation
allow users to avoid errors in cases where there are multiple matches (typical but not limited to pseudoautosomal regions) gene/transcript table __getitem__ returns a single arbitrary match
| return mock_result(Gene) | ||
|
|
||
| @mock | ||
| def find_by_id(self, id): # pragma: no cover |
There was a problem hiding this comment.
type annotations on newer code? or the mock override doesn't play well with it?
realizing first_by_name is not following the conventions of the rest of the code
There was a problem hiding this comment.
Good point. I'll check vscode and jetbrains to make sure first.
| return nullptr; | ||
| } | ||
|
|
||
| template <typename T> // T = PyGene, PyTran -- anything that when unpacked has an 'id' member. |
There was a problem hiding this comment.
does this need to be in c++ or is it a hotspot?
There was a problem hiding this comment.
Good question, I admit I didn't really give it much thought before implementation.
It's not a hotspot yet because it's a new API, but we'll try steering users to use the new API, to avoid the duplicate-per-id footgun. We discussed changing PyGenomeAnnoTable_GetSubscript_ByID() to raise an error on dupes but realized it's too common so is likely to break existing code.
I think this particular function is easy enough to maintain to keep as C++.
Co-authored-by: Steve Chan <32464643+s22chan@users.noreply.github.com>
allow users to avoid errors in cases where there are multiple matches (typical but not limited to pseudoautosomal regions)
gene/transcript table getitem returns a single arbitrary match