Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoids keyError when generating random reads #385

Merged
merged 3 commits into from
Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions tests/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ dedup_single_tag_missing:
stdin: chr19_tag_missing.bam
outputs: [stdout]
references: [single_tag_missing_py3.sam]
options: dedup -L test_missing.log --out-sam --random-seed=123456789 --method=directional --umi-tag=RX --extract-umi-method=tag
options: dedup -L test_missing.log --out-sam --random-seed=123456789 --method=directional --umi-tag=RX --extract-umi-method=tag --output-stats=stats_tag_missing

dedup_single_gene_tag:
stdin: chr19_gene_tags.bam
Expand Down Expand Up @@ -311,11 +311,11 @@ group_paired_use_unmapped:
references: [paired_group_use_unmapped.sam]
options: group -L test.log --out-sam --random-seed=123456789 --method=directional --no-sort-output --output-bam --unmapped=use --paired

### Tests to implement ####
# ### Tests to implement ####

## dedup ##
# mapping-quality (Need a BAM with meaningful MAPQ)
# paired end (obv. need a paired end BAM)
# read-length (ideally with sRNA-Seq BAM?!)
# ## dedup ##
# # mapping-quality (Need a BAM with meaningful MAPQ)
# # paired end (obv. need a paired end BAM)
# # read-length (ideally with sRNA-Seq BAM?!)

# unpaired reads (Need a BAM with mixed paired and single end reads)
# # unpaired reads (Need a BAM with mixed paired and single end reads)
6 changes: 5 additions & 1 deletion umi_tools/umi_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def __init__(self, bamfile, chrom, barcode_getter):
self.umis = collections.defaultdict(int)
self.barcode_getter = barcode_getter
self.random_fill_size = 100000 # Higher = faster, more memory
self.first_kerror = 1
self.fill()

def refill_random(self):
Expand All @@ -169,7 +170,10 @@ def fill(self):
if read.is_read2:
continue

self.umis[self.barcode_getter(read)[0]] += 1
try:
self.umis[self.barcode_getter(read)[0]] += 1
except KeyError:
continue

self.umis_counter = collections.Counter(self.umis)
total_umis = sum(self.umis_counter.values())
Expand Down
2 changes: 1 addition & 1 deletion umi_tools/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.0"
__version__ = "1.0.1"