github.com/vertgenlab/gonomics@v1.0.0/genomeGraph/routines.go (about) 1 package genomeGraph 2 3 import ( 4 "sync" 5 6 "github.com/vertgenlab/gonomics/fastq" 7 "github.com/vertgenlab/gonomics/giraf" 8 "github.com/vertgenlab/gonomics/sam" 9 ) 10 11 // Goroutine worker functions. 12 func RoutineFqToGiraf(gg *GenomeGraph, seedHash map[uint64][]uint64, seedLen int, stepSize int, scoreMatrix [][]int64, inputChan <-chan fastq.FastqBig, outputChan chan<- giraf.Giraf, wg *sync.WaitGroup) { 13 matrix := NewSwMatrix(defaultMatrixSize) 14 seedPool := NewMemSeedPool() 15 dnaPool := NewDnaPool() 16 seedBuildHelper := newSeedBuilder() 17 scorekeeper := scoreKeeper{} 18 dynamicKeeper := dynamicScoreKeeper{} 19 for read := range inputChan { 20 outputChan <- *GraphSmithWatermanToGiraf(gg, read, seedHash, seedLen, stepSize, &matrix, scoreMatrix, &seedPool, &dnaPool, scorekeeper, dynamicKeeper, seedBuildHelper) 21 } 22 wg.Done() 23 } 24 25 func RoutineFqPairToGiraf(gg *GenomeGraph, seedHash map[uint64][]uint64, seedLen int, stepSize int, scoreMatrix [][]int64, input <-chan fastq.PairedEndBig, output chan<- giraf.GirafPair, wg *sync.WaitGroup) { 26 matrix := NewSwMatrix(defaultMatrixSize) 27 seedPool := NewMemSeedPool() 28 dnaPool := NewDnaPool() 29 seedBuildHelper := newSeedBuilder() 30 scorekeeper := scoreKeeper{} 31 dynamicKeeper := dynamicScoreKeeper{} 32 for read := range input { 33 output <- WrapPairGiraf(gg, read, seedHash, seedLen, stepSize, &matrix, scoreMatrix, &seedPool, &dnaPool, scorekeeper, dynamicKeeper, seedBuildHelper) 34 } 35 wg.Done() 36 } 37 38 func RoutineGirafToSamSingle(gg *GenomeGraph, seedHash map[uint64][]uint64, seedLen int, stepSize int, scoreMatrix [][]int64, inputChan <-chan fastq.FastqBig, outputChan chan<- sam.Sam, wg *sync.WaitGroup) { 39 matrix := NewSwMatrix(defaultMatrixSize) 40 seedPool := NewMemSeedPool() 41 dnaPool := NewDnaPool() 42 seedBuildHelper := newSeedBuilder() 43 scorekeeper := scoreKeeper{} 44 dynamicKeeper := dynamicScoreKeeper{} 45 for read := range inputChan { 46 outputChan <- GirafToSam(GraphSmithWatermanToGiraf(gg, read, seedHash, seedLen, stepSize, &matrix, scoreMatrix, &seedPool, &dnaPool, scorekeeper, dynamicKeeper, seedBuildHelper)) 47 } 48 wg.Done() 49 } 50 51 func RoutineGirafToSam(gg *GenomeGraph, seedHash map[uint64][]uint64, seedLen int, stepSize int, scoreMatrix [][]int64, input <-chan fastq.PairedEndBig, output chan<- sam.Sam, wg *sync.WaitGroup) { 52 matrix := NewSwMatrix(defaultMatrixSize) 53 seedPool := NewMemSeedPool() 54 dnaPool := NewDnaPool() 55 scorekeeper := scoreKeeper{} 56 dynamicKeeper := dynamicScoreKeeper{} 57 seedBuildHelper := newSeedBuilder() 58 var pair sam.MatePair 59 for read := range input { 60 pair = GirafPairToSam(WrapPairGiraf(gg, read, seedHash, seedLen, stepSize, &matrix, scoreMatrix, &seedPool, &dnaPool, scorekeeper, dynamicKeeper, seedBuildHelper)) 61 output <- pair.Fwd 62 output <- pair.Rev 63 } 64 wg.Done() 65 }