hgvs
hgvs copied to clipboard
fix: update gene symbol when it is `None` and `AssemblyMapper` normalizer
Two fixes:
-
The
_update_gene_symbol
ofVariantMapper
class did not update symbol when it isNone
. -
The normalizer of
AssemblyMapper
uses aVariantMapper
configured inconsistently fromAssemblyMapper
itself. TheAssemblyMapper._norm
is aNormalizer
object.Normalizer
has a fieldvm
ofVariantMapper
class. In the current code, when initializing anAssemblyMapper
object with the argument of a different value fromglobal_config
(e.g.add_gene_symbol=True
, thevm
will be created usingglobal_config
, rather than the parameters passed toAssemblyMapper
. This is confusing, because the mappers are configured differently and can bring unexpected behaviors.
The fix passes a VariantMapper
object initialized using the same arguments as AssemblyMapper
object.
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
Hi, thanks for the pull request, here are some comments on the change:
- _update_gene_symbol
The existing code:
if not symbol:
Already handles symbol being None - I verified this:
In [16]: var_c.gene = None
In [17]: vm._update_gene_symbol(var_c, "test_gene_symbol") # existing code
Out[17]: SequenceVariant(ac=NM_002386.3, type=c, posedit=-5_1del, gene=test_gene_symbol)
In [18]: var_c.gene
Out[18]: 'test_gene_symbol'
Next time - it's good to include a test that fails on the old code, and then passes on the new code (eg an automated test doing what I did above). I think if you did this, you would have discovered that the code change was unnecessary
- Given an AssemblyMapper is a VariantMapper, could you pass
variantmapper=self
? That would future proof the code so that if we added some new parameters, we wouldn't have to make sure we update them in 2 places
Also - is this a fix for issue #704 - if so, could you please link issue in pull request?
Also, a test would be nice (eg recreate #704 on old code, validate it's fixed in new code)
Thanks
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This PR was closed because it has been stalled for 7 days with no activity.
@markgene - thanks for your contribution, I have taken your change, removed the gene parts, and added a unit test - submitted as a new pull request: https://github.com/biocommons/hgvs/pull/746