mirror of
https://github.com/metabarcoding/obitools4.git
synced 2026-02-02 22:30:34 +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
|
t = to
|
||||||
}
|
}
|
||||||
|
|
||||||
if from < 0 {
|
if f < 0 {
|
||||||
from = 0
|
f = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if to >= s.Len() {
|
if t >= s.Len() {
|
||||||
to = s.Len()
|
t = s.Len()
|
||||||
}
|
}
|
||||||
|
|
||||||
rep, err := s.Subsequence(f, t, false)
|
rep, err := s.Subsequence(f, t, false)
|
||||||
@@ -147,7 +147,7 @@ func CutSequenceWorker(from, to int, breakOnError bool) obiseq.SeqWorker {
|
|||||||
if breakOnError {
|
if breakOnError {
|
||||||
log.Fatalf("Cannot cut sequence %s (%v)", s.Id(), err)
|
log.Fatalf("Cannot cut sequence %s (%v)", s.Id(), err)
|
||||||
} else {
|
} 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
|
return obiseq.BioSequenceSlice{rep}, err
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package obiannotate
|
package obiannotate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -266,6 +267,7 @@ func CLICut() (int, int) {
|
|||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
values := strings.Split(_cut, ":")
|
values := strings.Split(_cut, ":")
|
||||||
|
log.Warnf("values: %v (%d-%d)", values, len(values), len(values[1]))
|
||||||
|
|
||||||
if len(values) != 2 {
|
if len(values) != 2 {
|
||||||
log.Fatalf("Invalid cut value %s. value should be of the form start:end", _cut)
|
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])
|
start, err := strconv.Atoi(values[0])
|
||||||
|
|
||||||
if err != nil {
|
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])
|
end, err := strconv.Atoi(values[1])
|
||||||
|
|
||||||
if err != nil {
|
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
|
return start, end
|
||||||
|
|||||||
Reference in New Issue
Block a user