Skip to content

Commit

Permalink
debug MD tag missing
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmsk committed Sep 8, 2020
1 parent d281c86 commit 47a65c1
Show file tree
Hide file tree
Showing 32 changed files with 47 additions and 224 deletions.
3 changes: 3 additions & 0 deletions docs/version_history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Version History

v0.2.x release series
---------------------
0.2.10 (2020.09.08):
- debug ValueError when MD tag of read is missing (`issue #5<https://github.com/parklab/bamsnap/issues/5>`_)

0.2.9 (2020.09.03):
- add ``insert_size_del_threshold`` for deletion, ``insert_size_ins_threshold`` for insertsion
- add ``read_color_deletion`` for deletion, ``read_color_insersion`` for insertion
Expand Down
2 changes: 1 addition & 1 deletion pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ pip uninstall -y bamsnap
rm -rf build
rm -rf ./dist/*
python3 setup.py sdist bdist_wheel
pip install ./dist/bamsnap-0.2.9-py3-none-any.whl
pip install ./dist/bamsnap-0.2.10-py3-none-any.whl
# twine upload dist/*
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}

setup(name='bamsnap',
version='0.2.9',
version='0.2.10',
url='https://github.com/danielmsk/bamsnap',
license='MIT',
author='Daniel Minseok Kwon',
Expand Down
10 changes: 8 additions & 2 deletions src/bamsnap.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Metadata-Version: 2.1
Name: bamsnap
Version: 0.2.9
Version: 0.2.10
Summary: A converter from .bam to .png for specific genomic region.
Home-page: https://github.com/danielmsk/bamsnap
Author: Daniel Minseok Kwon
Author-email: [email protected]
License: MIT
Download-URL: https://github.com/danielmsk/bamsnap/archive/0.1.tar.gz
Description: # <img src="https://bampdx.com/wp-content/uploads/2015/12/BAMPDX-logo.png" height=28px width=45px>&nbsp;BAMsnap
Description: # BamSnap
<!--[![Build Status](https://travis-ci.org/bamsnap/bamsnap.svg?branch=develop)](https://travis-ci.org/bamsnap/bamsnap)
[![Code Health](https://landscape.io/github/bamsnap/bamsnap/develop/landscape.svg?style=flat)](https://landscape.io/github/bamsnap/bamsnap/develop)
[![Coverage Status](https://img.shields.io/codecov/c/github/bamsnap/bamsnap/develop.svg)](https://codecov.io/github/bamsnap/bamsnap?branch=develop)-->
Expand Down Expand Up @@ -36,6 +36,8 @@ Description: # <img src="https://bampdx.com/wp-content/uploads/2015/12/BAMPDX-lo
```bash
pip install bamsnap
```
* [pypi site for bamsnap](https://pypi.org/project/bamsnap/)

### Install with github

```
Expand All @@ -54,6 +56,10 @@ Description: # <img src="https://bampdx.com/wp-content/uploads/2015/12/BAMPDX-lo
For more details, see BamSnap [**Documentation**](http://bamsnap.readthedocs.io/en/latest).


## Example Use Case

* [**1000 Genome Data**](http://100.26.138.46:8000/): 1000 genomic loci in 2504 individuals
* [**BamSnap Plot Gallery**](https://bamsnap.readthedocs.io/en/latest/gallery.html)



Expand Down
Binary file modified src/bamsnap/__pycache__/drawread.cpython-37.pyc
Binary file not shown.
Binary file modified src/bamsnap/__pycache__/drawreadset.cpython-37.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions src/bamsnap/data/conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"TITLE":"BAMSNAP",
"VERSION":"0.2.9",
"VERSION_DATE":"2020-09-03",
"VERSION":"0.2.10",
"VERSION_DATE":"2020-09-07",
"PROG":"bamsnap",
"options":[
{"param":"bam", "default":[], "nargs":"*", "action": null, "choices":null, "type":null, "help":"bam file(s)"},
Expand Down
12 changes: 7 additions & 5 deletions src/bamsnap/drawread.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DrawRead():
y1 = 0
opt = {}

def __init__(self, a): # a:alignment
def __init__(self, a, refseq=""): # a:alignment
self.a = a
self.mapq = a.mapq
self.id = a.query_name
Expand All @@ -35,7 +35,11 @@ def __init__(self, a): # a:alignment
self.readseq_with_softclipped = a.query_sequence

self.base_qual = a.query_qualities
self.refseq = a.get_reference_sequence()
self.refseq = refseq
# try:
# self.refseq = a.get_reference_sequence()
# except ValueError:
# self.refseq = {}
self.g_spos = a.positions[0] + 1
self.g_epos = a.positions[-1] + 1
self.has_del = False
Expand Down Expand Up @@ -77,8 +81,6 @@ def set_SV(self):
pass




def set_read_variant(self):
gpos = self.g_spos
self.g_spos_with_softclipped = self.g_spos
Expand Down Expand Up @@ -121,7 +123,7 @@ def set_read_variant(self):
else:
for gp in range(prev_gpos, gpos):
base = self.readseq_with_softclipped[bidx]
refbase = self.refseq[ridx].upper()
refbase = self.refseq[gp].upper()
if base != refbase:
btype = 'S'
self.mismatch_list.append(gp)
Expand Down
16 changes: 12 additions & 4 deletions src/bamsnap/drawreadset.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,24 @@ def add_covmap(self, group, read):
self.covmap[group][gpos] = (cov + 1, base_composition)

def update_ref_seq_with_read(self, a):
read_ref_seq = a.get_reference_sequence()
read_ref_pos = a.get_reference_positions()
try:
read_ref_seq = a.get_reference_sequence()
except ValueError: # when MD tag is missing.
read_ref_seq = {}

for pidx in range(len(read_ref_pos)):
gpos = read_ref_pos[pidx] + 1
base = read_ref_seq[pidx]

try:
base = read_ref_seq[pidx]
except KeyError: # when MD tag is missing
base = "N"
try:
self.refseq[gpos]
except KeyError:
self.refseq[gpos] = base.upper()


def calculate_readmap(self, is_strand_group=False):
group_list = ['all']
Expand All @@ -289,8 +298,7 @@ def calculate_readmap(self, is_strand_group=False):
rid = self.get_rid(a)
self.update_ref_seq_with_read(a)
if not self.is_exist_read(rid):
r = DrawRead(a)
r.refseq = self.refseq
r = DrawRead(a, self.refseq)
r.id = rid
r.read_gap_h = self.read_gap_h
r.read_gap_w = self.read_gap_w
Expand Down
Binary file added tests/data/test_noMDtag_1_102345_103355.bam
Binary file not shown.
Binary file added tests/data/test_noMDtag_1_102345_103355.bam.bai
Binary file not shown.
Binary file modified tests/out/NATRIO_chr10_117542948.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/out/NATRIO_chr10_117542948_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/out/NATRIO_chr10_117542948_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/out/NATRIO_chr10_117542948_baseplot_ex1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/out/NATRIO_chr10_117542948_baseplot_ex2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/out/NATRIO_chr10_117542948_baseplot_ex3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/out/NATRIO_chr9_114786933.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/out/NATRIO_test_3/chr14:36516859.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/out/NATRIO_test_3/chr1:45803673.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/out/NATRIO_test_3/chr5:197095.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
195 changes: 0 additions & 195 deletions tests/out/test_DEL_1.png_bamsnap.log

This file was deleted.

Binary file modified tests/out/test_INV_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 47a65c1

Please sign in to comment.