mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-12-08 16:50:27 +00:00
Rename the Length methods Len to follow GO standart
This commit is contained in:
@@ -162,7 +162,7 @@ func (s *BioSequence) String() string {
|
||||
}
|
||||
|
||||
// Returning the length of the sequence.
|
||||
func (s *BioSequence) Length() int {
|
||||
func (s *BioSequence) Len() int {
|
||||
return len(s.sequence)
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,8 @@ import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/goutils"
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obieval"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/PaesslerAG/gval"
|
||||
)
|
||||
|
||||
type SequencePredicate func(*BioSequence) bool
|
||||
@@ -130,7 +128,7 @@ func IsLessAbundantOrEqualTo(count int) SequencePredicate {
|
||||
|
||||
func IsLongerOrEqualTo(length int) SequencePredicate {
|
||||
f := func(sequence *BioSequence) bool {
|
||||
return sequence.Length() >= length
|
||||
return sequence.Len() >= length
|
||||
}
|
||||
|
||||
return f
|
||||
@@ -138,7 +136,7 @@ func IsLongerOrEqualTo(length int) SequencePredicate {
|
||||
|
||||
func IsShorterOrEqualTo(length int) SequencePredicate {
|
||||
f := func(sequence *BioSequence) bool {
|
||||
return sequence.Length() <= length
|
||||
return sequence.Len() <= length
|
||||
}
|
||||
|
||||
return f
|
||||
@@ -203,17 +201,7 @@ func IsIdIn(ids ...string) SequencePredicate {
|
||||
|
||||
func ExpressionPredicat(expression string) SequencePredicate {
|
||||
|
||||
lang := gval.NewLanguage(
|
||||
gval.Full(),
|
||||
gval.Function("len", func(args ...interface{}) (interface{}, error) {
|
||||
length := goutils.Length(args[0])
|
||||
return (float64)(length), nil
|
||||
}),
|
||||
gval.Function("ismap", func(args ...interface{}) (interface{}, error) {
|
||||
ismap := goutils.IsAMap(args[0])
|
||||
return ismap, nil
|
||||
}))
|
||||
exp, err := lang.NewEvaluable(expression)
|
||||
exp, err := obieval.OBILang.NewEvaluable(expression)
|
||||
if err != nil {
|
||||
log.Fatalf("Error in the expression : %s", expression)
|
||||
}
|
||||
@@ -223,7 +211,7 @@ func ExpressionPredicat(expression string) SequencePredicate {
|
||||
map[string]interface{}{
|
||||
"annot": sequence.Annotations(),
|
||||
"count": sequence.Count(),
|
||||
"seqlength": sequence.Length(),
|
||||
"seqlength": sequence.Len(),
|
||||
"sequence": sequence,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ func (sequence *BioSequence) ReverseComplement(inplace bool) *BioSequence {
|
||||
|
||||
s := sequence.sequence
|
||||
|
||||
for i, j := sequence.Length()-1, 0; i >= j; i-- {
|
||||
for i, j := sequence.Len()-1, 0; i >= j; i-- {
|
||||
|
||||
// ASCII code & 31 -> builds an index in witch (a|A) is 1
|
||||
// ASCII code & 0x20 -> Foce lower case
|
||||
@@ -25,7 +25,7 @@ func (sequence *BioSequence) ReverseComplement(inplace bool) *BioSequence {
|
||||
|
||||
if sequence.HasQualities() {
|
||||
s := sequence.qualities
|
||||
for i, j := sequence.Length()-1, 0; i >= j; i-- {
|
||||
for i, j := sequence.Len()-1, 0; i >= j; i-- {
|
||||
s[j], s[i] = s[i], s[j]
|
||||
j++
|
||||
}
|
||||
@@ -49,7 +49,7 @@ func (sequence *BioSequence) _revcmpMutation() *BioSequence {
|
||||
return string(b)
|
||||
}
|
||||
|
||||
lseq := sequence.Length()
|
||||
lseq := sequence.Len()
|
||||
|
||||
mut, ok := sequence.GetIntMap("pairing_mismatches")
|
||||
if ok && len(mut) > 0 {
|
||||
|
||||
@@ -13,11 +13,11 @@ func (sequence *BioSequence) Subsequence(from, to int, circular bool) (*BioSeque
|
||||
return nil, errors.New("from greater than to")
|
||||
}
|
||||
|
||||
if from < 0 || from >= sequence.Length() {
|
||||
if from < 0 || from >= sequence.Len() {
|
||||
return nil, errors.New("from out of bounds")
|
||||
}
|
||||
|
||||
if to <= 0 || to > sequence.Length() {
|
||||
if to <= 0 || to > sequence.Len() {
|
||||
return nil, errors.New("to out of bounds")
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ func (sequence *BioSequence) Subsequence(from, to int, circular bool) (*BioSeque
|
||||
newSeq.id = fmt.Sprintf("%s_sub[%d..%d]", sequence.Id(), from+1, to)
|
||||
newSeq.definition = sequence.definition
|
||||
} else {
|
||||
newSeq, _ = sequence.Subsequence(from, sequence.Length(), false)
|
||||
newSeq, _ = sequence.Subsequence(from, sequence.Len(), false)
|
||||
newSeq.Write(sequence.Sequence()[0:to])
|
||||
|
||||
if sequence.HasQualities() {
|
||||
@@ -52,7 +52,7 @@ func (sequence *BioSequence) Subsequence(from, to int, circular bool) (*BioSeque
|
||||
|
||||
func (sequence *BioSequence) _subseqMutation(shift int) *BioSequence {
|
||||
|
||||
lseq := sequence.Length()
|
||||
lseq := sequence.Len()
|
||||
|
||||
mut, ok := sequence.GetIntMap("pairing_mismatches")
|
||||
if ok && len(mut) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user