Skip to content

Commit

Permalink
Merge pull request #19 from dev/validate-num-columns-in-refgene-file
Browse files Browse the repository at this point in the history
Validate number of columns in refgene file
  • Loading branch information
Christine Lo committed Aug 20, 2015
2 parents def8ab6 + 3e44f32 commit 5032f9a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pyhgvs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def cdna_to_genomic_coord(transcript, coord):
# 5' flanking sequence.
if pos < 1:
if transcript_strand:
return transcript.tx_position.chrom_start + pos - 1
return transcript.tx_position.chrom_start + pos
else:
return transcript.tx_position.chrom_stop - pos + 1

Expand Down Expand Up @@ -1358,7 +1358,7 @@ def parse_hgvs_name(hgvs_name, genome, transcript=None,
if transcript and hgvs.transcript in genome:
# Reference sequence is directly known, use it.
genome = GenomeSubset(genome, transcript.tx_position.chrom,
transcript.tx_position.chrom_start - 1,
transcript.tx_position.chrom_start,
transcript.tx_position.chrom_stop,
hgvs.transcript)

Expand Down
8 changes: 7 additions & 1 deletion pyhgvs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,28 @@ def read_refgene(infile):
if line.startswith('#'):
continue
row = line.rstrip('\n').split('\t')
if len(row) != 16:
raise ValueError(
'File has incorrect number of columns '
'in at least one line.', code='invalid')

# Skip trailing ,
exon_starts = map(int, row[9].split(',')[:-1])
exon_ends = map(int, row[10].split(',')[:-1])
exon_frames = map(int, row[15].split(',')[:-1])
exons = zip(exon_starts, exon_ends)

yield {
'chrom': row[2],
'start': int(row[4]) + 1,
'start': int(row[4]),
'end': int(row[5]),
'id': row[1],
'strand': row[3],
'cds_start': int(row[6]),
'cds_end': int(row[7]),
'gene_name': row[12],
'exons': exons,
'exon_frames': exon_frames
}


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def main():

setup(
name='pyhgvs',
version='0.9.5',
version='0.9.6',
description='HGVS name parsing and formatting',
long_description=description,
author='Matt Rasmussen',
Expand Down

0 comments on commit 5032f9a

Please sign in to comment.