mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Reduce redundante call to bytes.ToLower and substitute the last call by an home made version doing the conversion in place
Former-commit-id: d9ea22f649d97be352f8dbb37acc1495df830118
This commit is contained in:
@ -1,7 +1,6 @@
|
|||||||
package obiformats
|
package obiformats
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"encoding/csv"
|
"encoding/csv"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -70,7 +69,7 @@ func __read_ecopcr_bioseq__(file *__ecopcr_file__) (*obiseq.BioSequence, error)
|
|||||||
comment = strings.TrimSpace(record[19])
|
comment = strings.TrimSpace(record[19])
|
||||||
}
|
}
|
||||||
|
|
||||||
bseq := obiseq.NewBioSequence(name, bytes.ToLower(sequence), comment)
|
bseq := obiseq.NewBioSequence(name, sequence, comment)
|
||||||
annotation := bseq.Annotations()
|
annotation := bseq.Annotations()
|
||||||
|
|
||||||
annotation["ac"] = name
|
annotation["ac"] = name
|
||||||
|
@ -141,10 +141,10 @@ func _ParseEmblFile(source string, input <-chan _FileChunk, out obiiter.IBioSequ
|
|||||||
}
|
}
|
||||||
case line == "//":
|
case line == "//":
|
||||||
sequence := obiseq.NewBioSequence(id,
|
sequence := obiseq.NewBioSequence(id,
|
||||||
bytes.ToLower(seqBytes.Bytes()),
|
seqBytes.Bytes(),
|
||||||
defBytes.String())
|
defBytes.String())
|
||||||
sequence.SetSource(source)
|
sequence.SetSource(source)
|
||||||
|
|
||||||
sequence.SetFeatures(featBytes.Bytes())
|
sequence.SetFeatures(featBytes.Bytes())
|
||||||
|
|
||||||
annot := sequence.Annotations()
|
annot := sequence.Annotations()
|
||||||
|
@ -7,7 +7,6 @@ package obiformats
|
|||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@ -42,7 +41,7 @@ func _FastseqReader(source string,
|
|||||||
comment = ""
|
comment = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
rep := obiseq.NewBioSequence(name, bytes.ToLower(sequence), comment)
|
rep := obiseq.NewBioSequence(name, sequence, comment)
|
||||||
rep.SetSource(source)
|
rep.SetSource(source)
|
||||||
if s.qual.l > C.ulong(0) {
|
if s.qual.l > C.ulong(0) {
|
||||||
cquality := unsafe.Slice(s.qual.s, C.int(s.qual.l))
|
cquality := unsafe.Slice(s.qual.s, C.int(s.qual.l))
|
||||||
|
@ -69,7 +69,7 @@ func _ParseGenbankFile(source string,
|
|||||||
case line == "//":
|
case line == "//":
|
||||||
log.Debugln("Total lines := ", nl)
|
log.Debugln("Total lines := ", nl)
|
||||||
sequence := obiseq.NewBioSequence(id,
|
sequence := obiseq.NewBioSequence(id,
|
||||||
bytes.ToLower(seqBytes.Bytes()),
|
seqBytes.Bytes(),
|
||||||
defBytes.String())
|
defBytes.String())
|
||||||
sequence.SetSource(source)
|
sequence.SetSource(source)
|
||||||
state = inHeader
|
state = inHeader
|
||||||
|
@ -11,10 +11,10 @@
|
|||||||
package obiseq
|
package obiseq
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiutils"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -210,7 +210,6 @@ func (s *BioSequence) Source() string {
|
|||||||
return s.source
|
return s.source
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Returning the MD5 hash of the sequence.
|
// Returning the MD5 hash of the sequence.
|
||||||
func (s *BioSequence) MD5() [16]byte {
|
func (s *BioSequence) MD5() [16]byte {
|
||||||
return md5.Sum(s.sequence)
|
return md5.Sum(s.sequence)
|
||||||
@ -244,7 +243,7 @@ func (s *BioSequence) SetSequence(sequence []byte) {
|
|||||||
if s.sequence != nil {
|
if s.sequence != nil {
|
||||||
RecycleSlice(&s.sequence)
|
RecycleSlice(&s.sequence)
|
||||||
}
|
}
|
||||||
s.sequence = bytes.ToLower(sequence)
|
s.sequence = obiutils.InPlaceToLower(sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setting the qualities of the BioSequence.
|
// Setting the qualities of the BioSequence.
|
||||||
|
11
pkg/obiutils/bytes.go
Normal file
11
pkg/obiutils/bytes.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package obiutils
|
||||||
|
|
||||||
|
func InPlaceToLower(data []byte) []byte {
|
||||||
|
for i,l := range data {
|
||||||
|
if l >= 'A' && l <='Z' {
|
||||||
|
data[i]|=32
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return data
|
||||||
|
}
|
Reference in New Issue
Block a user