Skip to content

Commit

Permalink
Merge branch 'release/0.1.31'
Browse files Browse the repository at this point in the history
  • Loading branch information
kbchoi-jax committed Feb 17, 2017
2 parents 10547e9 + be92826 commit 57c3dde
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
2 changes: 1 addition & 1 deletion g2gtools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .bins import bins


__version__ = '0.1.29'
__version__ = '0.1.31'
__author__ = 'Matthew Vincent, The Jackson Laboratory'
__email__ = 'matt.vincent@jax.org'

Expand Down
20 changes: 16 additions & 4 deletions g2gtools/fasta_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,21 @@ def get_pos(fai, chromosome, start, end):
byte_end = fai_entry_offset + newlines_total + fai_entry_length
return byte_start, byte_end, byte_len_seq

def _show_error():
import traceback, sys
"""
show system errors
"""
et, ev, tb = sys.exc_info()

print "Error Type: %s" % et
print "Error Value: %s" % ev
while tb :
co = tb.tb_frame.f_code
filename = str(co.co_filename)
line_no = str(traceback.tb_lineno(tb))
print ' %s:%s' % (filename, line_no)
tb = tb.tb_next

def process_piece(filename_vcf, chrom, start, end, sample_index, diploid, pass_only, quality):
"""
Expand Down Expand Up @@ -109,11 +124,8 @@ def process_piece(filename_vcf, chrom, start, end, sample_index, diploid, pass_o
byte_start, byte_end, byte_len_seq = get_pos(fasta_index, rec.CHROM, rec.POS-1, rec.POS)
gt = parse_gt(rec, sample_index)

#LOG.debug(rec)
#LOG.debug(gt)

# FI : Whether a sample was a Pass(1) or fail (0) based on FILTER values
if quality and gt.fi == '0':
if quality and gt.fi is not None and gt.fi == '0':
continue

global mm_l
Expand Down
23 changes: 16 additions & 7 deletions g2gtools/vcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# 1 based


from collections import namedtuple
from collections import namedtuple

from .g2g_utils import get_logger
Expand Down Expand Up @@ -149,7 +150,11 @@ def parse_gt(vcf_record, sample_index):

if sample_data != '.':
gt_index = vcf_record.FORMAT.split(':').index('GT')
fi_index = vcf_record.FORMAT.split(':').index('FI')

try:
fi_index = vcf_record.FORMAT.split(':').index('FI')
except:
fi_index = None

try:
# parse the GT field
Expand Down Expand Up @@ -181,12 +186,16 @@ def parse_gt(vcf_record, sample_index):
LOG.debug(ve)
except IndexError, ie:
LOG.debug(ie)
try:
fi = sample_data.split(':')[fi_index]
except ValueError, ve:
LOG.debug(ve)
except IndexError, ie:
LOG.debug(ie)

if fi_index is not None:
try:
fi = sample_data.split(':')[fi_index]
except ValueError, ve:
LOG.debug(ve)
except IndexError, ie:
LOG.debug(ie)
else:
fi = None

return GTData(vcf_record.REF, left, right, gt, fi, phase)

Expand Down

0 comments on commit 57c3dde

Please sign in to comment.