Code refactoring

This commit is contained in:
2022-01-14 17:32:12 +01:00
parent 5753723618
commit ef66ca4972
16 changed files with 260 additions and 260 deletions

View File

@@ -6,32 +6,32 @@ import (
"github.com/DavidGamba/go-getoptions"
)
var __forward_files__ = make([]string, 0, 10)
var __reverse_files__ = make([]string, 0, 10)
var __delta__ = 5
var __min_overlap__ = 20
var __gap_penality__ = 2
var __without_stats__ = false
var _ForwardFiles = make([]string, 0, 10)
var _ReverseFiles = make([]string, 0, 10)
var _Delta = 5
var _MinOverlap = 20
var _GapPenality = 2
var _WithoutStats = false
func PairingOptionSet(options *getoptions.GetOpt) {
options.StringSliceVar(&__forward_files__, "forward-reads",
options.StringSliceVar(&_ForwardFiles, "forward-reads",
1, 1000,
options.Alias("F"),
options.Description("The file names containing the forward reads"))
options.StringSliceVar(&__reverse_files__, "reverse-reads",
options.StringSliceVar(&_ReverseFiles, "reverse-reads",
1, 1000,
options.Alias("R"),
options.Description("The file names containing the reverse reads"))
options.IntVar(&__delta__, "delta", 5,
options.IntVar(&_Delta, "delta", 5,
options.Alias("D"),
options.Description("Length added to the fast detected overlap for the precise alignement (default 5)."))
options.IntVar(&__min_overlap__, "min-overlap", 20,
options.IntVar(&_MinOverlap, "min-overlap", 20,
options.Alias("O"),
options.Description("Minimum ovelap between both the reads to consider the aligment (default 20)."))
options.IntVar(&__gap_penality__, "gap-penality", 2,
options.IntVar(&_GapPenality, "gap-penality", 2,
options.Alias("G"),
options.Description("Gap penality expressed as the multiply factor applied to the mismatch score between two nucleotides with a quality of 40 (default 2)."))
options.BoolVar(&__without_stats__, "without-stat", false,
options.BoolVar(&_WithoutStats, "without-stat", false,
options.Alias("S"),
options.Description("Remove alignment statistics from the produced consensus sequences."))
}
@@ -42,12 +42,12 @@ func OptionSet(options *getoptions.GetOpt) {
}
func IBatchPairedSequence() (obiseq.IPairedBioSequenceBatch, error) {
forward, err := obiconvert.ReadBioSequencesBatch(__forward_files__...)
forward, err := obiconvert.ReadBioSequencesBatch(_ForwardFiles...)
if err != nil {
return obiseq.NilIPairedBioSequenceBatch, err
}
reverse, err := obiconvert.ReadBioSequencesBatch(__reverse_files__...)
reverse, err := obiconvert.ReadBioSequencesBatch(_ReverseFiles...)
if err != nil {
return obiseq.NilIPairedBioSequenceBatch, err
}
@@ -58,17 +58,17 @@ func IBatchPairedSequence() (obiseq.IPairedBioSequenceBatch, error) {
}
func Delta() int {
return __delta__
return _Delta
}
func MinOverlap() int {
return __min_overlap__
return _MinOverlap
}
func GapPenality() int {
return __gap_penality__
return _GapPenality
}
func WithStats() bool {
return !__without_stats__
return !_WithoutStats
}

View File

@@ -112,16 +112,16 @@ func IAssemblePESequencesBatch(iterator obiseq.IPairedBioSequenceBatch,
buffsize = sizes[1]
}
new_iter := obiseq.MakeIBioSequenceBatch(buffsize)
newIter := obiseq.MakeIBioSequenceBatch(buffsize)
new_iter.Add(nworkers)
newIter.Add(nworkers)
go func() {
new_iter.Wait()
for len(new_iter.Channel()) > 0 {
newIter.Wait()
for len(newIter.Channel()) > 0 {
time.Sleep(time.Millisecond)
}
close(new_iter.Channel())
close(newIter.Channel())
log.Printf("End of the sequence Pairing")
}()
@@ -157,14 +157,14 @@ func IAssemblePESequencesBatch(iterator obiseq.IPairedBioSequenceBatch,
B.Destroy()
}
bar.Add(batch.Length() - processed)
new_iter.Channel() <- obiseq.MakeBioSequenceBatch(
newIter.Channel() <- obiseq.MakeBioSequenceBatch(
batch.Order(),
cons...,
)
// log.Printf("\n==> %d Wait data to align\n", wid)
// start = time.Now()
}
new_iter.Done()
newIter.Done()
}
log.Printf("Start of the sequence Pairing")
@@ -173,6 +173,6 @@ func IAssemblePESequencesBatch(iterator obiseq.IPairedBioSequenceBatch,
go f(iterator.Split(), i)
}
return new_iter
return newIter
}

View File

@@ -8,34 +8,34 @@ import (
"github.com/DavidGamba/go-getoptions"
)
var __circular__ = false
var __forward_primer__ string
var __reverse_primer__ string
var __allowed_mismatch__ = 0
var __minimum_length__ = 0
var __maximum_length__ = -1
var _Circular = false
var _ForwardPrimer string
var _ReversePrimer string
var _AllowedMismatch = 0
var _MinimumLength = 0
var _MaximumLength = -1
func PCROptionSet(options *getoptions.GetOpt) {
options.BoolVar(&__circular__, "circular", false,
options.BoolVar(&_Circular, "circular", false,
options.Alias("c"),
options.Description("Considers that sequences are [c]ircular."))
options.StringVar(&__forward_primer__, "forward", "",
options.StringVar(&_ForwardPrimer, "forward", "",
options.Required("You must provide a forward primer"),
options.Description("The forward primer used for the electronic PCR."))
options.StringVar(&__reverse_primer__, "reverse", "",
options.StringVar(&_ReversePrimer, "reverse", "",
options.Required("You must provide a reverse primer"),
options.Description("The reverse primer used for the electronic PCR."))
options.IntVar(&__allowed_mismatch__, "allowed-mismatches", 0,
options.IntVar(&_AllowedMismatch, "allowed-mismatches", 0,
options.Alias("e"),
options.Description("Maximum number of mismatches allowed for each primer."))
options.IntVar(&__minimum_length__, "min-length", 0,
options.IntVar(&_MinimumLength, "min-length", 0,
options.Alias("l"),
options.Description("Minimum length of the barcode (primers excluded)."))
options.IntVar(&__maximum_length__, "max-length", -1,
options.IntVar(&_MaximumLength, "max-length", -1,
options.Alias("L"),
options.Description("Maximum length of the barcode (primers excluded)."))
}
@@ -46,7 +46,7 @@ func OptionSet(options *getoptions.GetOpt) {
}
func ForwardPrimer() string {
pattern, err := obiapat.MakeApatPattern(__forward_primer__, __allowed_mismatch__)
pattern, err := obiapat.MakeApatPattern(_ForwardPrimer, _AllowedMismatch)
if err != nil {
log.Fatalf("%+v", err)
@@ -54,11 +54,11 @@ func ForwardPrimer() string {
pattern.Free()
return __forward_primer__
return _ForwardPrimer
}
func ReversePrimer() string {
pattern, err := obiapat.MakeApatPattern(__reverse_primer__, __allowed_mismatch__)
pattern, err := obiapat.MakeApatPattern(_ReversePrimer, _AllowedMismatch)
if err != nil {
log.Fatalf("%+v", err)
@@ -66,21 +66,21 @@ func ReversePrimer() string {
pattern.Free()
return __reverse_primer__
return _ReversePrimer
}
func AllowedMismatch() int {
return __allowed_mismatch__
return _AllowedMismatch
}
func Circular() bool {
return __circular__
return _Circular
}
func MinLength() int {
return __minimum_length__
return _MinimumLength
}
func MaxLength() int {
return __maximum_length__
return _MaximumLength
}