Skip to content

Commit efefc75

Browse files
committed
fix bugs while processing with cigar
1 parent 8cffb39 commit efefc75

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

Diff for: const.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var conf config
2020
var region *Region
2121

2222
const (
23-
VERSION = "0.0.3-beta"
23+
VERSION = "0.0.4-beta"
2424
DefaultBaseQuality = 30
2525
)
2626

Diff for: fast.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ func workerFast(
5656
}
5757

5858
start, index := 0, 0
59+
5960
for _, i := range record.Cigar {
6061
if i.Type() == sam.CigarMatch {
62+
6163
for j := 1; j <= i.Len(); j++ {
6264
at := index + j - 1
6365

@@ -69,14 +71,23 @@ func workerFast(
6971
genomic := start + record.Start
7072

7173
if _, ok := edits[genomic]; !ok {
74+
// GL000220.1
75+
if genomic - 1 >= len(chrRef) {
76+
sugar.Error(record.Record)
77+
sugar.Fatalf("%s: genomic - 1[%d] >= len(chrRef)[%d]", ref.Ref, genomic - 1, len(chrRef))
78+
}
7279
edits[genomic] = NewEditsInfo(ref.Ref, chrRef[genomic-1], genomic)
7380
}
7481

7582
edits[genomic].AddReads(record, at)
7683
start++
7784
}
7885
index += i.Len()
79-
} else if i.Type() != sam.CigarDeletion || i.Type() != sam.CigarHardClipped || i.Type() != sam.CigarInsertion {
86+
} else if i.Type() != sam.CigarDeletion &&
87+
i.Type() != sam.CigarHardClipped &&
88+
i.Type() != sam.CigarInsertion &&
89+
i.Type() != sam.CigarSoftClipped {
90+
8091
start += i.Len()
8192
}
8293
}

Diff for: slow.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ func worker(wg *sync.WaitGroup, refs chan *Region, w chan string, omopolymericPo
7373
start++
7474
}
7575
index += i.Len()
76-
} else if i.Type() != sam.CigarDeletion || i.Type() != sam.CigarHardClipped || i.Type() != sam.CigarInsertion {
76+
} else if i.Type() != sam.CigarDeletion &&
77+
i.Type() != sam.CigarHardClipped &&
78+
i.Type() != sam.CigarInsertion &&
79+
i.Type() != sam.CigarSoftClipped {
7780
start += i.Len()
7881
}
7982
}

0 commit comments

Comments
 (0)