Big change iin the data model, and a first version of obiuniq

This commit is contained in:
2022-02-21 19:00:23 +01:00
parent 9737f97084
commit 2e7c1834b0
43 changed files with 664 additions and 440 deletions

View File

@@ -7,32 +7,32 @@ import (
// Returns a sub sequence start from position 'from' included,
// to position 'to' excluded. Coordinates start at position 0.
func (sequence BioSequence) Subsequence(from, to int, circular bool) (BioSequence, error) {
func (sequence *BioSequence) Subsequence(from, to int, circular bool) (*BioSequence, error) {
if from >= to && !circular {
return NilBioSequence, errors.New("from greater than to")
return nil, errors.New("from greater than to")
}
if from < 0 || from >= sequence.Length() {
return NilBioSequence, errors.New("from out of bounds")
return nil, errors.New("from out of bounds")
}
if to <= 0 || to > sequence.Length() {
return NilBioSequence, errors.New("to out of bounds")
return nil, errors.New("to out of bounds")
}
var newSeq BioSequence
var newSeq *BioSequence
if from < to {
newSeq = MakeEmptyBioSequence()
newSeq = NewEmptyBioSequence()
newSeq.Write(sequence.Sequence()[from:to])
if sequence.HasQualities() {
newSeq.WriteQualities(sequence.Qualities()[from:to])
}
newSeq.sequence.id = fmt.Sprintf("%s_sub[%d..%d]", sequence.Id(), from+1, to)
newSeq.sequence.definition = sequence.sequence.definition
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.Write(sequence.Sequence()[0:to])
@@ -44,7 +44,7 @@ func (sequence BioSequence) Subsequence(from, to int, circular bool) (BioSequenc
}
if len(sequence.Annotations()) > 0 {
newSeq.sequence.annotations = GetAnnotation(sequence.Annotations())
newSeq.annotations = GetAnnotation(sequence.Annotations())
}
return newSeq, nil