Skip to content

Commit

Permalink
vcf/variant/record_buf/info/field: Move key to record
Browse files Browse the repository at this point in the history
  • Loading branch information
zaeleus committed Mar 13, 2024
1 parent c48ff83 commit ccc8141
Show file tree
Hide file tree
Showing 22 changed files with 71 additions and 67 deletions.
6 changes: 4 additions & 2 deletions noodles-bcf/src/async/io/reader/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ mod tests {
use noodles_vcf::{
self as vcf,
variant::{
record::{info::field::Value as InfoFieldValue, AlternateBases, Filters, Info},
record::{
info::{self, field::Value as InfoFieldValue},
AlternateBases, Filters, Info,
},
record_buf::{
info,
samples::{self, sample::Value as GenotypeFieldValue, Keys},
Samples as VcfGenotypes,
},
Expand Down
4 changes: 2 additions & 2 deletions noodles-bcf/src/io/reader/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ pub(crate) mod tests {
use noodles_vcf::{
self as vcf,
variant::{
record::{AlternateBases, Filters, Info},
record::{info, AlternateBases, Filters, Info},
record_buf::{
info::{self, field::Value as InfoFieldValue},
info::field::Value as InfoFieldValue,
samples::{
self,
sample::{value::Array, Value as GenotypeFieldValue},
Expand Down
4 changes: 2 additions & 2 deletions noodles-vcf/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl Header {
/// use noodles_vcf::{
/// self as vcf,
/// header::record::value::{map::Info, Map},
/// variant::record_buf::info::field::key,
/// variant::record::info::field::key,
/// };
///
/// let id = key::SAMPLES_WITH_DATA_COUNT;
Expand All @@ -142,7 +142,7 @@ impl Header {
/// use noodles_vcf::{
/// self as vcf,
/// header::record::value::{map::Info, Map},
/// variant::record_buf::info::field::key,
/// variant::record::info::field::key,
/// };
///
/// let mut header = vcf::Header::default();
Expand Down
6 changes: 4 additions & 2 deletions noodles-vcf/src/header/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl Builder {
/// use noodles_vcf::{
/// self as vcf,
/// header::record::value::{map::Info, Map},
/// variant::record_buf::info::field::key,
/// variant::record::info::field::key,
/// };
///
/// let id = key::SAMPLES_WITH_DATA_COUNT;
Expand Down Expand Up @@ -322,7 +322,9 @@ mod tests {
fn test_build() -> Result<(), Box<dyn std::error::Error>> {
use crate::{
header,
variant::record_buf::{info::field::key as info_key, samples::keys::key as format_key},
variant::{
record::info::field::key as info_key, record_buf::samples::keys::key as format_key,
},
};

let (key, value) = (
Expand Down
3 changes: 2 additions & 1 deletion noodles-vcf/src/header/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,8 @@ mod tests {
fn test_from_str() -> Result<(), Box<dyn std::error::Error>> {
use crate::{
header::record::{value::map::Other, Value},
variant::record_buf::{info, samples},
variant::record::info,
variant::record_buf::samples,
};

let s = r#"##fileformat=VCFv4.3
Expand Down
2 changes: 1 addition & 1 deletion noodles-vcf/src/header/parser/record/value/map/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ fn try_insert(
#[cfg(test)]
mod tests {
use super::*;
use crate::variant::record_buf::info::field::key;
use crate::variant::record::info::field::key;

#[test]
fn test_parse_info() {
Expand Down
2 changes: 1 addition & 1 deletion noodles-vcf/src/header/record/value/map/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl Map<Info> {
/// ```
/// use noodles_vcf::{
/// header::{record::value::{map::{info::Type, Info}, Map}, Number},
/// variant::record_buf::info::field::key,
/// variant::record::info::field::key,
/// };
///
/// let id = key::SAMPLES_WITH_DATA_COUNT;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
header::{record::value::map::info::Type, Number},
variant::record_buf::info::field::key,
variant::record::info::field::key,
};

pub(super) fn definition(key: &str) -> Option<(Number, Type, &'static str)> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
header::{record::value::map::info::Type, Number},
variant::record_buf::info::field::key,
variant::record::info::field::key,
};

pub(super) fn definition(key: &str) -> Option<(Number, Type, &'static str)> {
Expand Down
9 changes: 5 additions & 4 deletions noodles-vcf/src/header/string_maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl StringMaps {
/// record::value::{map::{Contig, Filter, Format, Info}, Map},
/// StringMaps,
/// },
/// variant::record_buf::{info, samples},
/// variant::{record::info, record_buf::samples},
/// };
///
/// let header = vcf::Header::builder()
Expand Down Expand Up @@ -80,7 +80,7 @@ impl StringMaps {
/// record::value::{map::{Contig, Filter, Format, Info}, Map},
/// StringMaps,
/// },
/// variant::record_buf::{info, samples},
/// variant::{record::info, record_buf::samples},
/// };
///
/// let header = vcf::Header::builder()
Expand Down Expand Up @@ -412,7 +412,8 @@ mod tests {
map::{AlternativeAllele, Contig, Filter, Format, Info},
Map,
},
variant::record_buf::{info, samples},
variant::record::info,
variant::record_buf::samples,
};

let header = Header::builder()
Expand Down Expand Up @@ -494,7 +495,7 @@ mod tests {
map::{Filter, Info},
Map,
},
variant::record_buf::info,
variant::record::info,
};

let ns = {
Expand Down
2 changes: 1 addition & 1 deletion noodles-vcf/src/io/reader/record_buf/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ mod tests {

#[test]
fn test_parse_info() -> Result<(), ParseError> {
use crate::variant::record_buf::info::field::{key, Value};
use crate::variant::{record::info::field::key, record_buf::info::field::Value};

let header = Header::default();
let mut info = Info::default();
Expand Down
2 changes: 1 addition & 1 deletion noodles-vcf/src/io/reader/record_buf/info/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub(super) fn parse_field(header: &Header, s: &str) -> Result<(String, Option<Va
#[cfg(test)]
mod tests {
use super::*;
use crate::variant::record_buf::info::field::key;
use crate::variant::record::info::field::key;

#[test]
fn test_parse_field() {
Expand Down
2 changes: 1 addition & 1 deletion noodles-vcf/src/io/writer/header/record/value/map/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use crate::variant::record_buf::info::field::key;
use crate::variant::record::info::field::key;

#[test]
fn test_write_info() -> Result<(), Box<dyn std::error::Error>> {
Expand Down
6 changes: 3 additions & 3 deletions noodles-vcf/src/io/writer/record/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ mod tests {

#[test]
fn test_write_info() -> io::Result<()> {
use crate::variant::record_buf::{
info::field::{key, Value as ValueBuf},
Info as InfoBuf,
use crate::variant::{
record::info::field::key,
record_buf::{info::field::Value as ValueBuf, Info as InfoBuf},
};

fn t(
Expand Down
2 changes: 1 addition & 1 deletion noodles-vcf/src/record/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ mod tests {

#[test]
fn test_iter() {
use crate::variant::record_buf::info::field::key;
use crate::variant::record::info::field::key;

let header = Header::default();

Expand Down
8 changes: 2 additions & 6 deletions noodles-vcf/src/variant/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ pub trait Record {

/// Returns or calculates the end.
fn end(&self, header: &Header) -> io::Result<Position> {
use self::info::field::Value;
use super::record_buf::info::field::key;
use self::info::field::{key, Value};

if let Some(Some(value)) = self.info().get(header, key::END_POSITION).transpose()? {
match value {
Expand Down Expand Up @@ -90,10 +89,7 @@ mod tests {

#[test]
fn test_end() -> Result<(), Box<dyn std::error::Error>> {
use crate::variant::{
record_buf::info::field::{key, Value},
RecordBuf,
};
use crate::variant::{record::info::field::key, record_buf::info::field::Value, RecordBuf};

let header = Header::default();

Expand Down
1 change: 1 addition & 0 deletions noodles-vcf/src/variant/record/info/field.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Variant record info field.

pub mod key;
pub mod value;

pub use self::value::Value;
21 changes: 11 additions & 10 deletions noodles-vcf/src/variant/record_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,9 @@ impl RecordBuf {
/// ```
/// use noodles_vcf::{
/// self as vcf,
/// variant::record_buf::{
/// info::field::{key, Value},
/// Info,
/// variant::{
/// record::info::field::key,
/// record_buf::{info::field::Value, Info},
/// },
/// };
///
Expand Down Expand Up @@ -347,10 +347,10 @@ impl RecordBuf {
/// ```
/// use noodles_vcf::{
/// self as vcf,
/// variant::record_buf::{
/// info::field::{key, Value},
/// Info,
/// },
/// variant::{
/// record::info::field::key,
/// record_buf::{info::field::Value, Info},
/// }
/// };
///
/// let info: Info = [
Expand Down Expand Up @@ -556,7 +556,7 @@ impl RecordBuf {
/// use noodles_core::Position;
/// use noodles_vcf::{
/// self as vcf,
/// variant::record_buf::info::field::{key, Value},
/// variant::{record::info::field::key, record_buf::info::field::Value},
/// };
///
/// let record = vcf::variant::RecordBuf::builder()
Expand Down Expand Up @@ -590,7 +590,8 @@ impl RecordBuf {
/// # Ok::<_, noodles_core::position::TryFromIntError>(())
/// ```
pub fn end(&self) -> Result<Position, EndError> {
use self::info::field::{key, Value};
use self::info::field::Value;
use super::record::info::field::key;

if let Some(Some(value)) = self.info().get(key::END_POSITION) {
match value {
Expand Down Expand Up @@ -675,7 +676,7 @@ mod tests {

#[test]
fn test_end() -> Result<(), Box<dyn std::error::Error>> {
use super::info::field::key;
use crate::variant::record::info::field::key;

let record = RecordBuf::builder()
.set_reference_sequence_name("sq0")
Expand Down
6 changes: 3 additions & 3 deletions noodles-vcf/src/variant/record_buf/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ impl Builder {
/// ```
/// use noodles_vcf::{
/// self as vcf,
/// variant::record_buf::{
/// info::field::{key, Value},
/// Info,
/// variant::{
/// record::info::field::key,
/// record_buf::{info::field::Value, Info},
/// },
/// };
///
Expand Down
Loading

0 comments on commit ccc8141

Please sign in to comment.