From dd22815f138c46849a9a7f4c0142eaf499b8c6ec Mon Sep 17 00:00:00 2001 From: ygidtu Date: Fri, 17 Jul 2020 09:56:29 +0800 Subject: [PATCH] fix bugs while processing with cigar --- build.sh | 1 + const.go | 2 +- fast.go | 13 ++++++++++++- slow.go | 5 ++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 50be217..8a03abe 100644 --- a/build.sh +++ b/build.sh @@ -4,3 +4,4 @@ env GOOS=darwin GOARCH=amd64 go build -o REDItools2_darwin_amd64 . env GOOS=linux GOARCH=amd64 go build -o REDItools2_linux_amd64 . env GOOS=windows GOARCH=amd64 go build -o REDItools2_win_amd64.exe . +# scp -P 1100 REDItools2_linux_amd64 zhangyiming@chenlinlab.synology.me:/mnt/data8/zhangyiming/REDItools2 diff --git a/const.go b/const.go index fa7c0d0..2465d03 100644 --- a/const.go +++ b/const.go @@ -20,7 +20,7 @@ var conf config var region *Region const ( - VERSION = "0.0.3-beta" + VERSION = "0.0.4-beta" DefaultBaseQuality = 30 ) diff --git a/fast.go b/fast.go index eb4308e..b660c98 100644 --- a/fast.go +++ b/fast.go @@ -56,8 +56,10 @@ func workerFast( } start, index := 0, 0 + for _, i := range record.Cigar { if i.Type() == sam.CigarMatch { + for j := 1; j <= i.Len(); j++ { at := index + j - 1 @@ -69,6 +71,11 @@ func workerFast( genomic := start + record.Start if _, ok := edits[genomic]; !ok { + // GL000220.1 + if genomic - 1 >= len(chrRef) { + sugar.Error(record.Record) + sugar.Fatalf("%s: genomic - 1[%d] >= len(chrRef)[%d]", ref.Ref, genomic - 1, len(chrRef)) + } edits[genomic] = NewEditsInfo(ref.Ref, chrRef[genomic-1], genomic) } @@ -76,7 +83,11 @@ func workerFast( start++ } index += i.Len() - } else if i.Type() != sam.CigarDeletion || i.Type() != sam.CigarHardClipped || i.Type() != sam.CigarInsertion { + } else if i.Type() != sam.CigarDeletion && + i.Type() != sam.CigarHardClipped && + i.Type() != sam.CigarInsertion && + i.Type() != sam.CigarSoftClipped { + start += i.Len() } } diff --git a/slow.go b/slow.go index e7449a7..b247b64 100644 --- a/slow.go +++ b/slow.go @@ -73,7 +73,10 @@ func worker(wg *sync.WaitGroup, refs chan *Region, w chan string, omopolymericPo start++ } index += i.Len() - } else if i.Type() != sam.CigarDeletion || i.Type() != sam.CigarHardClipped || i.Type() != sam.CigarInsertion { + } else if i.Type() != sam.CigarDeletion && + i.Type() != sam.CigarHardClipped && + i.Type() != sam.CigarInsertion && + i.Type() != sam.CigarSoftClipped { start += i.Len() } }