Skip to content

Commit 69beb85

Browse files
committed
Merge remote-tracking branch 'origin/main' into madhava/libs
2 parents fc18e99 + 3e4a69b commit 69beb85

2 files changed

Lines changed: 45 additions & 1 deletion

File tree

rust/bioscript-formats/src/inspect.rs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,17 @@ fn inspect_from_bcf(
444444
duration_ms: u128,
445445
) -> FileInspection {
446446
let (has_index, index_path) = detect_index(path, DetectedKind::Bcf, options);
447+
let path_lower = path.to_string_lossy().to_ascii_lowercase();
448+
let source_context = selected_entry
449+
.as_ref()
450+
.map(|entry| format!("{path_lower}\n{}", entry.to_ascii_lowercase()))
451+
.unwrap_or(path_lower);
447452
FileInspection {
448453
path: path.to_path_buf(),
449454
container,
450455
detected_kind: DetectedKind::Bcf,
451456
confidence: DetectionConfidence::Authoritative,
452-
source: None,
457+
source: detect_source(&source_context, &[], DetectedKind::Bcf),
453458
assembly: Some(Assembly::Grch38),
454459
phased: None,
455460
selected_entry,
@@ -657,6 +662,38 @@ mod tests {
657662
Some("nested/sample.vcf.gz")
658663
);
659664

665+
let cursor = Cursor::new(Vec::new());
666+
let mut bcf_zip_writer = zip::ZipWriter::new(cursor);
667+
bcf_zip_writer
668+
.start_file(
669+
"23andMe_R6/chr1.bcf",
670+
zip::write::SimpleFileOptions::default(),
671+
)
672+
.unwrap();
673+
bcf_zip_writer.write_all(b"bcf placeholder").unwrap();
674+
let bcf_zip_bytes = bcf_zip_writer.finish().unwrap().into_inner();
675+
let bcf_zip_inspection = inspect_bytes(
676+
"sample_23andMe_R6.zip",
677+
&bcf_zip_bytes,
678+
&InspectOptions::default(),
679+
)
680+
.unwrap();
681+
assert_eq!(bcf_zip_inspection.detected_kind, DetectedKind::Bcf);
682+
assert_eq!(
683+
bcf_zip_inspection
684+
.source
685+
.as_ref()
686+
.and_then(|source| source.vendor.as_deref()),
687+
Some("23andMe")
688+
);
689+
assert_eq!(
690+
bcf_zip_inspection
691+
.source
692+
.as_ref()
693+
.and_then(|source| source.platform_version.as_deref()),
694+
Some("r6")
695+
);
696+
660697
let missing = read_zip_sample_lines_from_bytes(&zip_bytes, "missing.vcf").unwrap_err();
661698
assert!(missing.to_string().contains("failed to open zip entry"));
662699

rust/bioscript-formats/src/inspect/heuristics.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ pub(crate) fn detect_source(
152152
} else if normalized.contains(" v5 ") || lower_name.contains("/v5/") {
153153
platform_version = Some("v5".to_owned());
154154
evidence.push("v5 token".to_owned());
155+
} else if normalized.contains(" v6 ")
156+
|| normalized.contains(" r6 ")
157+
|| lower_name.contains("/v6/")
158+
|| lower_name.contains("/r6/")
159+
{
160+
platform_version = Some("r6".to_owned());
161+
evidence.push("v6/r6 token".to_owned());
155162
}
156163
} else if normalized.contains("ancestrydna") || normalized.contains("ancestry com dna") {
157164
vendor = Some("AncestryDNA".to_owned());

0 commit comments

Comments
 (0)