From 6c73a58a28a9c887d6ecf46f85b5290be2b7ce0e Mon Sep 17 00:00:00 2001 From: Chris Beaumont Date: Tue, 10 Mar 2015 17:34:24 -0700 Subject: [PATCH 1/3] Update setup.py for new pip --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fb41e85..fbe149c 100644 --- a/setup.py +++ b/setup.py @@ -2,6 +2,7 @@ from setuptools import setup from pip.req import parse_requirements +from pip.download import PipSession import sys description = ("This library provides a simple to use Python API for parsing, " @@ -32,7 +33,7 @@ def main(): scripts=[], install_requires=['pip>=1.2'], tests_require=[str(line.req) for line in - parse_requirements('requirements-dev.txt')], + parse_requirements('requirements-dev.txt', session=PipSession())], ) if __name__ == '__main__': From 77015b8554293f8abf75608870f794541531f3bc Mon Sep 17 00:00:00 2001 From: Chris Beaumont Date: Wed, 11 Mar 2015 08:47:51 -0700 Subject: [PATCH 2/3] Raise error with nonincreasing coordinates in HGVS names. Closes #17 --- pyhgvs/__init__.py | 9 ++++++++- pyhgvs/tests/test_hgvs_names.py | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/pyhgvs/__init__.py b/pyhgvs/__init__.py index 0823e4e..c9b2c1b 100644 --- a/pyhgvs/__init__.py +++ b/pyhgvs/__init__.py @@ -92,7 +92,6 @@ BASES = BASE+ """ - import re from .variants import justify_indel @@ -746,6 +745,7 @@ def parse(self, name): # Parse prefix and allele. self.parse_allele(allele) self.parse_prefix(prefix, self.kind) + self._validate() def parse_prefix(self, prefix, kind): """ @@ -970,6 +970,13 @@ def parse_genome(self, details): raise InvalidHGVSName(details, 'genomic allele') + def _validate(self): + """ + Check for internal inconsistencies in representation + """ + if self.start > self.end: + raise InvalidHGVSName(reason="Coordinates are nonincreasing") + def __repr__(self): try: return "HGVSName('%s')" % self.format() diff --git a/pyhgvs/tests/test_hgvs_names.py b/pyhgvs/tests/test_hgvs_names.py index c947dd4..0f12cd8 100644 --- a/pyhgvs/tests/test_hgvs_names.py +++ b/pyhgvs/tests/test_hgvs_names.py @@ -11,6 +11,7 @@ from .. import CDNACoord from .. import CDNA_STOP_CODON from .. import HGVSName +from .. import InvalidHGVSName from .. import cdna_to_genomic_coord from .. import format_hgvs_name from .. import genomic_to_cdna_coord @@ -177,6 +178,19 @@ def test_name_to_variant_refseqs(): repr([hgvs_name, variant, hgvs_variant])) +@nose.tools.raises(InvalidHGVSName) +def test_invalid_coordinates(): + """ + Regression test for 17 + """ + if not SequenceFileDB: + raise nose.SkipTest + + genome = SequenceFileDB('pyhgvs/tests/data/test_refseqs.fa') + hgvs_name = 'NC_000005.10:g.177421339_177421327delACTCGAGTGCTCC' + parse_hgvs_name(hgvs_name, genome, get_transcript=get_transcript) + + # Test examples of cDNA coordinates. _parse_cdna_coords = [ ('1001', CDNACoord(1001)), From cffd9c0c546ef379ae21fd383206720ce6ff8dc3 Mon Sep 17 00:00:00 2001 From: Chris Beaumont Date: Wed, 11 Mar 2015 15:34:51 -0700 Subject: [PATCH 3/3] version bump --- setup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index fbe149c..ace27d1 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ def main(): setup( name='pyhgvs', - version='0.9.3', + version='0.9.4', description='HGVS name parsing and formatting', long_description=description, author='Matt Rasmussen', @@ -33,7 +33,8 @@ def main(): scripts=[], install_requires=['pip>=1.2'], tests_require=[str(line.req) for line in - parse_requirements('requirements-dev.txt', session=PipSession())], + parse_requirements('requirements-dev.txt', + session=PipSession())], ) if __name__ == '__main__':