Skip to content

Commit

Permalink
Merge pull request #385 from CGATOxford/{TS}-DebugCellTag
Browse files Browse the repository at this point in the history
avoids keyError when generating random reads
  • Loading branch information
TomSmithCGAT authored Dec 6, 2019
2 parents 5e99b63 + fa324a8 commit 289b9cc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
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"

0 comments on commit 289b9cc

Please sign in to comment.