2022-02-24 07:08:40 +01:00
package obiiter
2023-11-29 12:14:37 +01:00
import "git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obiseq"
2022-02-24 07:08:40 +01:00
type BioSequenceBatch struct {
2024-08-02 12:35:46 +02:00
source string
slice obiseq . BioSequenceSlice
order int
2022-02-24 07:08:40 +01:00
}
2024-08-02 12:35:46 +02:00
var NilBioSequenceBatch = BioSequenceBatch { "" , nil , - 1 }
2022-02-24 07:08:40 +01:00
2024-08-02 12:35:46 +02:00
// MakeBioSequenceBatch creates a new BioSequenceBatch with the given source, order, and sequences.
//
// Parameters:
// - source: The source of the BioSequenceBatch.
// - order: The order of the BioSequenceBatch.
// - sequences: The slice of BioSequence.
//
// Returns:
// - BioSequenceBatch: The newly created BioSequenceBatch.
func MakeBioSequenceBatch (
source string ,
order int ,
2022-02-24 07:08:40 +01:00
sequences obiseq . BioSequenceSlice ) BioSequenceBatch {
return BioSequenceBatch {
2024-08-02 12:35:46 +02:00
source : source ,
slice : sequences ,
order : order ,
2022-02-24 07:08:40 +01:00
}
}
2024-08-02 12:35:46 +02:00
// Order returns the order of the BioSequenceBatch.
//
// Returns:
// - int: The order of the BioSequenceBatch.
2022-02-24 07:08:40 +01:00
func ( batch BioSequenceBatch ) Order ( ) int {
return batch . order
}
2024-08-02 12:35:46 +02:00
// Source returns the source of the BioSequenceBatch.
//
// Returns:
// - string: The source of the BioSequenceBatch.
func ( batch BioSequenceBatch ) Source ( ) string {
return batch . source
}
// Reorder updates the order of the BioSequenceBatch and returns the updated batch.
//
// Parameters:
// - newOrder: The new order value to assign to the BioSequenceBatch.
//
// Returns:
// - BioSequenceBatch: The updated BioSequenceBatch with the new order value.
2022-02-24 07:08:40 +01:00
func ( batch BioSequenceBatch ) Reorder ( newOrder int ) BioSequenceBatch {
batch . order = newOrder
return batch
}
2024-08-02 12:35:46 +02:00
// Slice returns the BioSequenceSlice contained within the BioSequenceBatch.
//
// Returns:
// - obiseq.BioSequenceSlice: The BioSequenceSlice contained within the BioSequenceBatch.
2022-02-24 07:08:40 +01:00
func ( batch BioSequenceBatch ) Slice ( ) obiseq . BioSequenceSlice {
return batch . slice
}
2024-08-02 12:35:46 +02:00
// Len returns the number of BioSequence elements in the given BioSequenceBatch.
//
// Parameters:
// - batch: The BioSequenceBatch to get the length from.
//
// Return type:
// - int: The number of BioSequence elements in the BioSequenceBatch.
2022-11-17 11:09:58 +01:00
func ( batch BioSequenceBatch ) Len ( ) int {
2022-02-24 07:08:40 +01:00
return len ( batch . slice )
}
2024-08-02 12:35:46 +02:00
// NotEmpty returns whether the BioSequenceBatch is empty or not.
//
// It checks if the BioSequenceSlice contained within the BioSequenceBatch is not empty.
//
// Returns:
// - bool: True if the BioSequenceBatch is not empty, false otherwise.
2022-02-24 07:08:40 +01:00
func ( batch BioSequenceBatch ) NotEmpty ( ) bool {
return batch . slice . NotEmpty ( )
}
2024-08-02 12:35:46 +02:00
// Pop0 returns and removes the first element of the BioSequenceBatch.
//
// It does not take any parameters.
// It returns a pointer to a BioSequence object.
2022-02-24 07:08:40 +01:00
func ( batch BioSequenceBatch ) Pop0 ( ) * obiseq . BioSequence {
return batch . slice . Pop0 ( )
}
2024-08-02 12:35:46 +02:00
// IsNil checks if the BioSequenceBatch's slice is nil.
//
// This function takes a BioSequenceBatch as a parameter and returns a boolean value indicating whether the slice of the BioSequenceBatch is nil or not.
//
// Parameters:
// - batch: The BioSequenceBatch to check for nil slice.
//
// Returns:
// - bool: True if the BioSequenceBatch's slice is nil, false otherwise.
2022-02-24 07:08:40 +01:00
func ( batch BioSequenceBatch ) IsNil ( ) bool {
return batch . slice == nil
}