mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Patch a bug in the subseq and revcomplement methods. That patchs the bug in the option -c of obipcr
Former-commit-id: 7999b917d07545271036af6e66f53aea27fc6e7b
This commit is contained in:
@ -333,6 +333,9 @@ func _Pcr(seq ApatSequence,
|
||||
|
||||
annot["reverse_primer"] = reverse.String()
|
||||
match, _ = seq.pointer.reference.Subsequence(rm[0], rm[1], opt.pointer.circular)
|
||||
if match == nil {
|
||||
log.Fatalf("error in extracting sequence from reference: %d:%d (%v)\n", rm[0], rm[1], opt.pointer.circular)
|
||||
}
|
||||
match = match.ReverseComplement(true)
|
||||
annot["reverse_match"] = match.String()
|
||||
match.Recycle()
|
||||
|
@ -43,6 +43,10 @@ func nucComplement(n byte) byte {
|
||||
// The function returns the reverse complemented BioSequence.
|
||||
func (sequence *BioSequence) ReverseComplement(inplace bool) *BioSequence {
|
||||
|
||||
if sequence == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !inplace {
|
||||
sequence = sequence.Copy()
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package obiseq
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Subsequence returns a subsequence of the BioSequence.
|
||||
@ -23,14 +25,20 @@ func (sequence *BioSequence) Subsequence(from, to int, circular bool) (*BioSeque
|
||||
return nil, fmt.Errorf("from out of bounds %d < 0", from)
|
||||
}
|
||||
|
||||
if from >= sequence.Len() {
|
||||
if from >= sequence.Len() && !circular {
|
||||
return nil,
|
||||
fmt.Errorf("from out of bounds %d >= %d", from, sequence.Len())
|
||||
} else {
|
||||
log.Debugf("(%s) correcting from position from %d to %d", sequence.Id(), to, (to-1)%sequence.Len()+1)
|
||||
from = from % sequence.Len()
|
||||
}
|
||||
|
||||
if to > sequence.Len() {
|
||||
if to > sequence.Len() && !circular {
|
||||
return nil,
|
||||
fmt.Errorf("to out of bounds %d > %d", to, sequence.Len())
|
||||
} else {
|
||||
log.Debugf("(%s) correcting to position from %d to %d", sequence.Id(), to, (to-1)%sequence.Len()+1)
|
||||
to = ((to - 1) % sequence.Len()) + 1
|
||||
}
|
||||
|
||||
var newSeq *BioSequence
|
||||
|
Reference in New Issue
Block a user