use std::sync::Arc;
use arrow::datatypes::{DataType, Field, SchemaRef};
use exon_common::TableSchemaBuilder;
use object_store::ObjectStore;
pub struct FASTAConfig {
pub batch_size: usize,
pub file_schema: SchemaRef,
pub object_store: Arc<dyn ObjectStore>,
pub projection: Option<Vec<usize>>,
pub fasta_sequence_buffer_capacity: usize,
}
impl FASTAConfig {
pub fn new(object_store: Arc<dyn ObjectStore>, file_schema: SchemaRef) -> Self {
Self {
object_store,
file_schema,
batch_size: exon_common::DEFAULT_BATCH_SIZE,
projection: None,
fasta_sequence_buffer_capacity: 384, }
}
pub fn with_batch_size(mut self, batch_size: usize) -> Self {
self.batch_size = batch_size;
self
}
pub fn with_projection(mut self, projection: Vec<usize>) -> Self {
let file_projection = projection
.iter()
.filter(|f| **f < self.file_schema.fields().len())
.cloned()
.collect::<Vec<_>>();
self.projection = Some(file_projection);
self
}
pub fn with_fasta_sequence_buffer_capacity(
mut self,
fasta_sequence_buffer_capacity: usize,
) -> Self {
self.fasta_sequence_buffer_capacity = fasta_sequence_buffer_capacity;
self
}
}
pub fn new_fasta_schema_builder() -> TableSchemaBuilder {
TableSchemaBuilder::new_with_field_fields(vec![
Field::new("id", DataType::Utf8, false),
Field::new("description", DataType::Utf8, true),
Field::new("sequence", DataType::Utf8, false),
])
}