Skip to content

Commit

Permalink
fix bugs while processing with cigar
Browse files Browse the repository at this point in the history
  • Loading branch information
ygidtu committed Jul 17, 2020
1 parent 9e69514 commit dd22815
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]:/mnt/data8/zhangyiming/REDItools2
2 changes: 1 addition & 1 deletion const.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var conf config
var region *Region

const (
VERSION = "0.0.3-beta"
VERSION = "0.0.4-beta"
DefaultBaseQuality = 30
)

Expand Down
13 changes: 12 additions & 1 deletion fast.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -69,14 +71,23 @@ 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)
}

edits[genomic].AddReads(record, at)
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()
}
}
Expand Down
5 changes: 4 additions & 1 deletion slow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down

0 comments on commit dd22815

Please sign in to comment.