Skip to content

Commit

Permalink
Merge c6d44fa into 6324f77
Browse files Browse the repository at this point in the history
  • Loading branch information
iskandr committed Oct 27, 2019
2 parents 6324f77 + c6d44fa commit 1f07693
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Expand Up @@ -6,5 +6,5 @@ pyvcf>=0.6.7
memoized_property>=1.0.2
nose>=1.3.3
pylint>=1.4.4
serializable>=0.1.0
serializable>=0.2.1
sercol>=0.1.4
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -67,7 +67,7 @@
'biopython>=1.64',
'pyvcf>=0.6.7',
'memoized_property>=1.0.2',
'serializable>=0.1.1',
'serializable>=0.2.1',
'sercol>=0.1.4',
],
entry_points={
Expand Down
38 changes: 38 additions & 0 deletions test/test_variant.py
Expand Up @@ -151,6 +151,44 @@ def test_serialization():
reconstituted = Variant.from_json(serialized)
eq_(original, reconstituted)

def test_deserialization_old_keywords():
old_variant_representation_json = """
{
"ref": "T",
"contig": "22",
"start": 23230319,
"__class__": {
"__name__": "Variant",
"__module__": "varcode.variant"
},
"normalize_contig_name": true,
"alt": "G",
"allow_extended_nucleotides": false,
"ensembl": {
"__class__": {
"__name__": "EnsemblRelease",
"__module__": "pyensembl.ensembl_release"
},
"release": 75,
"server": "ftp://ftp.ensembl.org",
"species": {
"__class__": {
"__name__": "Species",
"__module__": "pyensembl.species"
},
"latin_name": "homo_sapiens"
}
}
}
"""
variant = Variant.from_json(old_variant_representation_json)
eq_(variant.contig, "22")
eq_(variant.ref, "T")
eq_(variant.alt, "G")
eq_(variant.reference_name, "GRCh37")
eq_(variant.normalize_contig_names, True)
eq_(variant.allow_extended_nucleotides, False)

def test_hg19_chromosome_names():
# trimming of mithochondrial name
eq_(Variant("M", 1, "A", "G", "hg19", convert_ucsc_contig_names=True).contig, "MT")
Expand Down
4 changes: 3 additions & 1 deletion varcode/__init__.py
Expand Up @@ -24,18 +24,20 @@
NonsilentCodingMutation,
)

__version__ = '1.0.1'
__version__ = '1.0.2'

__all__ = [
# basic classes
"Variant",
"EffectCollection",
"VariantCollection",

# effects
"effect_priority",
"top_priority_effect",
"MutationEffect",
"NonsilentCodingMutation",

# file loading
"load_maf",
"load_maf_dataframe",
Expand Down
7 changes: 7 additions & 0 deletions varcode/variant.py
Expand Up @@ -54,6 +54,13 @@ class Variant(Serializable):
"_gene_names",
)

# any keywords which are renamed or removed should be added to this
# dictionary to preserve the ability to deserialize old representations
# of Variant objects
_SERIALIZABLE_KEYWORD_ALIASES = {
"normalize_contig_name": "normalize_contig_names"
}

def __init__(
self,
contig,
Expand Down

0 comments on commit 1f07693

Please sign in to comment.