mirror of
https://github.com/metabarcoding/obitools4.git
synced 2026-02-03 06:40:33 +00:00
obiannotate --cut bug
This commit is contained in:
@@ -134,12 +134,12 @@ func CutSequenceWorker(from, to int, breakOnError bool) obiseq.SeqWorker {
|
||||
t = to
|
||||
}
|
||||
|
||||
if from < 0 {
|
||||
from = 0
|
||||
if f < 0 {
|
||||
f = 0
|
||||
}
|
||||
|
||||
if to >= s.Len() {
|
||||
to = s.Len()
|
||||
if t >= s.Len() {
|
||||
t = s.Len()
|
||||
}
|
||||
|
||||
rep, err := s.Subsequence(f, t, false)
|
||||
@@ -147,7 +147,7 @@ func CutSequenceWorker(from, to int, breakOnError bool) obiseq.SeqWorker {
|
||||
if breakOnError {
|
||||
log.Fatalf("Cannot cut sequence %s (%v)", s.Id(), err)
|
||||
} else {
|
||||
err = fmt.Errorf("Cannot cut sequence %s (%v), sequence discarded", s.Id(), err)
|
||||
err = fmt.Errorf("cannot cut sequence %s (%v), sequence discarded", s.Id(), err)
|
||||
}
|
||||
}
|
||||
return obiseq.BioSequenceSlice{rep}, err
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package obiannotate
|
||||
|
||||
import (
|
||||
"math"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -266,6 +267,7 @@ func CLICut() (int, int) {
|
||||
return 0, 0
|
||||
}
|
||||
values := strings.Split(_cut, ":")
|
||||
log.Warnf("values: %v (%d-%d)", values, len(values), len(values[1]))
|
||||
|
||||
if len(values) != 2 {
|
||||
log.Fatalf("Invalid cut value %s. value should be of the form start:end", _cut)
|
||||
@@ -274,12 +276,20 @@ func CLICut() (int, int) {
|
||||
start, err := strconv.Atoi(values[0])
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Invalid cut value %s. value %s should be an integer", _cut, values[0])
|
||||
if len(values[0]) == 0 {
|
||||
start = 1
|
||||
} else {
|
||||
log.Fatalf("Invalid start cut value %s. value %s should be an integer", _cut, values[0])
|
||||
}
|
||||
}
|
||||
end, err := strconv.Atoi(values[1])
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Invalid cut value %s. value %s should be an integer", _cut, values[1])
|
||||
if len(values[1]) == 0 {
|
||||
end = math.MaxInt
|
||||
} else {
|
||||
log.Fatalf("Invalid end cut value %s. value %s should be an integer", _cut, values[1])
|
||||
}
|
||||
}
|
||||
|
||||
return start, end
|
||||
|
||||
Reference in New Issue
Block a user