From 599822c42f4ad6ceb7a68c281ffb7040c379158d Mon Sep 17 00:00:00 2001 From: Piotr Kaleta Date: Tue, 25 Nov 2014 16:13:40 +0100 Subject: [PATCH 1/5] Rename hgvs to pyhgvs. --- README.md | 8 ++++---- examples/example1.py | 6 +++--- {hgvs => pyhgvs}/__init__.py | 0 {hgvs => pyhgvs}/data/LRG_RefSeqGene | 0 {hgvs => pyhgvs}/data/genes.refGene | 0 {hgvs => pyhgvs}/models.py | 0 {hgvs => pyhgvs}/tests/__init__.py | 0 {hgvs => pyhgvs}/tests/data/test_hgvs.genome | 0 {hgvs => pyhgvs}/tests/data/test_hgvs.txt | 0 {hgvs => pyhgvs}/tests/data/test_name_to_variant.genome | 0 {hgvs => pyhgvs}/tests/data/test_refseqs.fa | 0 {hgvs => pyhgvs}/tests/data/test_variant_to_name.genome | 0 {hgvs => pyhgvs}/tests/genome.py | 0 {hgvs => pyhgvs}/tests/test_hgvs_names.py | 0 {hgvs => pyhgvs}/tests/test_hgvs_names_long.py | 0 {hgvs => pyhgvs}/tests/test_variants.py | 0 {hgvs => pyhgvs}/utils.py | 0 {hgvs => pyhgvs}/variants.py | 0 setup.py | 2 +- 19 files changed, 8 insertions(+), 8 deletions(-) rename {hgvs => pyhgvs}/__init__.py (100%) rename {hgvs => pyhgvs}/data/LRG_RefSeqGene (100%) rename {hgvs => pyhgvs}/data/genes.refGene (100%) rename {hgvs => pyhgvs}/models.py (100%) rename {hgvs => pyhgvs}/tests/__init__.py (100%) rename {hgvs => pyhgvs}/tests/data/test_hgvs.genome (100%) rename {hgvs => pyhgvs}/tests/data/test_hgvs.txt (100%) rename {hgvs => pyhgvs}/tests/data/test_name_to_variant.genome (100%) rename {hgvs => pyhgvs}/tests/data/test_refseqs.fa (100%) rename {hgvs => pyhgvs}/tests/data/test_variant_to_name.genome (100%) rename {hgvs => pyhgvs}/tests/genome.py (100%) rename {hgvs => pyhgvs}/tests/test_hgvs_names.py (100%) rename {hgvs => pyhgvs}/tests/test_hgvs_names_long.py (100%) rename {hgvs => pyhgvs}/tests/test_variants.py (100%) rename {hgvs => pyhgvs}/utils.py (100%) rename {hgvs => pyhgvs}/variants.py (100%) diff --git a/README.md b/README.md index 8633cb3..0dcb324 100644 --- a/README.md +++ b/README.md @@ -93,8 +93,8 @@ and transcripts are read from a RefSeqGenes flat-file using methods provided by `hgvs`. ```python -import hgvs -import hgvs.utils +import pyhgvs as hgvs +import hgvs.utils as hgvs_utils from pygr.seqdb import SequenceFileDB # Read genome sequence using pygr. @@ -102,7 +102,7 @@ genome = SequenceFileDB('hg19.fa') # Read RefSeq transcripts into a python dict. with open('hgvs/data/genes.refGene') as infile: - transcripts = hgvs.utils.read_transcripts(infile) + transcripts = hgvs_utils.read_transcripts(infile) # Provide a callback for fetching a transcript by its name. def get_transcript(name): @@ -127,7 +127,7 @@ The `hgvs` library can also perform just the parsing step and provide a parse tree of the HGVS name. ```python -import hgvs +import pyhgvs as hgvs hgvs_name = hgvs.HGVSName('NM_000352.3:c.215-10A>G') diff --git a/examples/example1.py b/examples/example1.py index 25723d9..bc9d7f2 100644 --- a/examples/example1.py +++ b/examples/example1.py @@ -26,8 +26,8 @@ """ -import hgvs -import hgvs.utils +import pyhgvs as hgvs +import hgvs.utils as hgvs_utils from pygr.seqdb import SequenceFileDB # Read genome sequence using pygr. @@ -35,7 +35,7 @@ # Read RefSeq transcripts into a python dict. with open('hgvs/data/genes.refGene') as infile: - transcripts = hgvs.utils.read_transcripts(infile) + transcripts = hgvs_utils.read_transcripts(infile) # Provide a callback for fetching a transcript by its name. diff --git a/hgvs/__init__.py b/pyhgvs/__init__.py similarity index 100% rename from hgvs/__init__.py rename to pyhgvs/__init__.py diff --git a/hgvs/data/LRG_RefSeqGene b/pyhgvs/data/LRG_RefSeqGene similarity index 100% rename from hgvs/data/LRG_RefSeqGene rename to pyhgvs/data/LRG_RefSeqGene diff --git a/hgvs/data/genes.refGene b/pyhgvs/data/genes.refGene similarity index 100% rename from hgvs/data/genes.refGene rename to pyhgvs/data/genes.refGene diff --git a/hgvs/models.py b/pyhgvs/models.py similarity index 100% rename from hgvs/models.py rename to pyhgvs/models.py diff --git a/hgvs/tests/__init__.py b/pyhgvs/tests/__init__.py similarity index 100% rename from hgvs/tests/__init__.py rename to pyhgvs/tests/__init__.py diff --git a/hgvs/tests/data/test_hgvs.genome b/pyhgvs/tests/data/test_hgvs.genome similarity index 100% rename from hgvs/tests/data/test_hgvs.genome rename to pyhgvs/tests/data/test_hgvs.genome diff --git a/hgvs/tests/data/test_hgvs.txt b/pyhgvs/tests/data/test_hgvs.txt similarity index 100% rename from hgvs/tests/data/test_hgvs.txt rename to pyhgvs/tests/data/test_hgvs.txt diff --git a/hgvs/tests/data/test_name_to_variant.genome b/pyhgvs/tests/data/test_name_to_variant.genome similarity index 100% rename from hgvs/tests/data/test_name_to_variant.genome rename to pyhgvs/tests/data/test_name_to_variant.genome diff --git a/hgvs/tests/data/test_refseqs.fa b/pyhgvs/tests/data/test_refseqs.fa similarity index 100% rename from hgvs/tests/data/test_refseqs.fa rename to pyhgvs/tests/data/test_refseqs.fa diff --git a/hgvs/tests/data/test_variant_to_name.genome b/pyhgvs/tests/data/test_variant_to_name.genome similarity index 100% rename from hgvs/tests/data/test_variant_to_name.genome rename to pyhgvs/tests/data/test_variant_to_name.genome diff --git a/hgvs/tests/genome.py b/pyhgvs/tests/genome.py similarity index 100% rename from hgvs/tests/genome.py rename to pyhgvs/tests/genome.py diff --git a/hgvs/tests/test_hgvs_names.py b/pyhgvs/tests/test_hgvs_names.py similarity index 100% rename from hgvs/tests/test_hgvs_names.py rename to pyhgvs/tests/test_hgvs_names.py diff --git a/hgvs/tests/test_hgvs_names_long.py b/pyhgvs/tests/test_hgvs_names_long.py similarity index 100% rename from hgvs/tests/test_hgvs_names_long.py rename to pyhgvs/tests/test_hgvs_names_long.py diff --git a/hgvs/tests/test_variants.py b/pyhgvs/tests/test_variants.py similarity index 100% rename from hgvs/tests/test_variants.py rename to pyhgvs/tests/test_variants.py diff --git a/hgvs/utils.py b/pyhgvs/utils.py similarity index 100% rename from hgvs/utils.py rename to pyhgvs/utils.py diff --git a/hgvs/variants.py b/pyhgvs/variants.py similarity index 100% rename from hgvs/variants.py rename to pyhgvs/variants.py diff --git a/setup.py b/setup.py index 8c3ecbe..3f57c98 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ def main(): long_description=description, author='Matt Rasmussen', author_email='rasmus@counsyl.com', - packages=['hgvs', 'hgvs.tests'], + packages=['pyhgvs', 'pyhgvs.tests'], include_package_data=True, package_data={ '': ['requirements-dev.txt'], From c06343ab9f6ddacaedca134c91bfe057a71bb8df Mon Sep 17 00:00:00 2001 From: Piotr Kaleta Date: Tue, 25 Nov 2014 16:14:10 +0100 Subject: [PATCH 2/5] Bump version. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3f57c98..1619777 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ def main(): setup( name='pyhgvs', - version='0.9.1', + version='0.9.2', description='HGVS name parsing and formatting', long_description=description, author='Matt Rasmussen', From d9275ffd0becd68c8229ce31d193c9507e50dcc4 Mon Sep 17 00:00:00 2001 From: Matt Rasmussen Date: Thu, 11 Dec 2014 09:59:18 -0800 Subject: [PATCH 3/5] fix filenames in tests --- pyhgvs/tests/test_hgvs_names.py | 8 ++++---- pyhgvs/tests/test_hgvs_names_long.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pyhgvs/tests/test_hgvs_names.py b/pyhgvs/tests/test_hgvs_names.py index 7a70a89..b15d32e 100644 --- a/pyhgvs/tests/test_hgvs_names.py +++ b/pyhgvs/tests/test_hgvs_names.py @@ -97,7 +97,7 @@ def test_name_to_variant(): """ genome = MockGenomeTestFile( db_filename='hg19.fa', - filename='hgvs/tests/data/test_name_to_variant.genome', + filename='pyhgvs/tests/data/test_name_to_variant.genome', create_data=False) for hgvs_name, variant, name_canonical, var_canonical in _name_variants: @@ -115,7 +115,7 @@ def test_variant_to_name(): """ genome = MockGenomeTestFile( db_filename='hg19.fa', - filename='hgvs/tests/data/test_variant_to_name.genome', + filename='pyhgvs/tests/data/test_variant_to_name.genome', create_data=False) for (expected_hgvs_name, variant, @@ -139,7 +139,7 @@ def test_variant_to_name_counsyl(): """ genome = MockGenomeTestFile( db_filename='hg19.fa', - filename='hgvs/tests/data/test_variant_to_name.genome', + filename='pyhgvs/tests/data/test_variant_to_name.genome', create_data=False) for (expected_hgvs_name, variant, @@ -164,7 +164,7 @@ def test_name_to_variant_refseqs(): if not SequenceFileDB: print 'skip test_name_to_variant_refseqs' return - genome = SequenceFileDB('hgvs/tests/data/test_refseqs.fa') + genome = SequenceFileDB('pyhgvs/tests/data/test_refseqs.fa') for hgvs_name, variant, name_canonical, var_canonical in _name_variants: if not var_canonical or 'NM_' not in hgvs_name: diff --git a/pyhgvs/tests/test_hgvs_names_long.py b/pyhgvs/tests/test_hgvs_names_long.py index 8a99c46..e03fde7 100644 --- a/pyhgvs/tests/test_hgvs_names_long.py +++ b/pyhgvs/tests/test_hgvs_names_long.py @@ -12,11 +12,11 @@ def test_name_to_variant_long(): """ genome = MockGenomeTestFile( db_filename='hg19.fa', - filename='hgvs/tests/data/test_hgvs.genome', + filename='pyhgvs/tests/data/test_hgvs.genome', create_data=False) # Read transcripts. - with open('hgvs/data/genes.refGene', 'r') as infile: + with open('pyhgvs/data/genes.refGene', 'r') as infile: transcripts = read_transcripts(infile) class NoTranscriptError(Exception): @@ -40,7 +40,7 @@ def get_transcript_long(name): return transcript errors = [] - with open('hgvs/tests/data/test_hgvs.txt', 'r') as infile: + with open('pyhgvs/tests/data/test_hgvs.txt', 'r') as infile: for i, line in enumerate(infile): row = line.rstrip().split('\t') chrom, offset, ref, alt, hgvs_name = row[:5] From 1864514acea6a2dfd35e01a798775de2e39294f9 Mon Sep 17 00:00:00 2001 From: Matt Rasmussen Date: Thu, 11 Dec 2014 10:16:37 -0800 Subject: [PATCH 4/5] add a change log --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..3355e12 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +# HGVS library change log + +## 0.9.2 (2014-12-11) + - Rename package to pyhgvs to avoid naming conflict with other libraries. + +## 0.9.1 (2014-03-10) + - Normalize variants by default when generating names. + +## 0.9 (2014-01-16) + - Improved testing. From 3a93eba15cf725af1c0cff0fcdb49995a115656e Mon Sep 17 00:00:00 2001 From: Matt Rasmussen Date: Fri, 12 Dec 2014 10:49:40 -0800 Subject: [PATCH 5/5] update hgvs script to use new package name --- bin/hgvs | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/bin/hgvs b/bin/hgvs index b6655be..214a2d9 100755 --- a/bin/hgvs +++ b/bin/hgvs @@ -1,13 +1,13 @@ #!/usr/bin/env python +import argparse import logging -import optparse import sys -import hgvs -from hgvs.variants import normalize_variant -from hgvs.utils import read_transcripts -from hgvs import parse_hgvs_name +import pyhgvs +from pyhgvs import parse_hgvs_name +from pyhgvs.variants import normalize_variant +from pyhgvs.utils import read_transcripts import pygr.logger from pygr.seqdb import SequenceFileDB @@ -24,9 +24,10 @@ handler.setFormatter(formatter) logger.addHandler(handler) # Command line options. -options = optparse.OptionParser() -options.add_option('-f', '--fasta') -options.add_option('-t', '--trans') +options = argparse.ArgumentParser() +options.add_argument('-f', '--fasta', required=True) +options.add_argument('-t', '--trans', required=True) +options.add_argument('hgvs_name', nargs='*') #============================================================================= @@ -61,7 +62,7 @@ def determine_allele(genome, hgvs_name): chrom, start, ref, alt = parse_hgvs_name( hgvs_name, genome, get_transcript=get_transcript) except (NotImplementedError, AssertionError, KeyError, ValueError, - hgvs.InvalidHGVSName) as error: + pyhgvs.InvalidHGVSName) as error: messages.append(str(error)) return None, messages @@ -86,23 +87,25 @@ def determine_allele(genome, hgvs_name): # Main. if __name__ == '__main__': - conf, args = options.parse_args() + args = options.parse_args() # Read genome and transcripts. - genome = SequenceFileDB(conf.fasta) - with open(conf.trans) as infile: + genome = SequenceFileDB(args.fasta) + with open(args.trans) as infile: transcripts = read_transcripts(infile) gene2transcript = {transcript.gene.name: transcript for transcript in transcripts.itervalues()} - if len(args) == 0: - args = (line.rstrip() for line in sys.stdin) + if args.hgvs_name: + hgvs_names = args.hgvs_name + else: + hgvs_names = (line.rstrip() for line in sys.stdin) headers = ['name', 'chrom', 'start', 'ref', 'alt', 'messages'] print '\t'.join(map(str, headers)) - for allele_name in args: + for allele_name in hgvs_names: allele, messages = determine_allele(genome, allele_name) message = '|'.join(messages) if allele: