Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for displaying SNPs in "no_ref" CRAM files #4649

Merged
merged 3 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions plugins/alignments/src/BamAdapter/BamSlightlyLazyFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import { BamRecord } from '@gmod/bam'

// locals
import { getMismatches, parseCigar } from '../MismatchParser'
import { getMismatches } from '../MismatchParser'
import BamAdapter from './BamAdapter'

export default class BamSlightlyLazyFeature implements Feature {
Expand All @@ -20,17 +20,22 @@ export default class BamSlightlyLazyFeature implements Feature {
id() {
return `${this.adapter.id}-${this.record.id}`
}
get mismatches() {
return getMismatches(
this.record.CIGAR,
this.record.tags.MD as string | undefined,
this.record.seq,
this.ref,
this.record.qualRaw,
)
}

get(field: string): any {
return field === 'mismatches'
? getMismatches(
this.record.CIGAR,
this.record.tags.MD as string | undefined,
this.record.seq,
this.ref,
this.record.qualRaw,
)
: this.fields[field]
? this.mismatches
: field === 'qual'
? this.record.qual
: this.fields[field]
}

parent() {
Expand All @@ -41,21 +46,15 @@ export default class BamSlightlyLazyFeature implements Feature {
return undefined
}

get parsedCigar() {
return parseCigar(this.record.CIGAR)
}

get fields(): SimpleFeatureSerialized {
const r = this.record
const a = this.adapter
const p = r.isPaired()
return {
id: this.id(),
start: r.start,
name: r.name,
end: r.end,
score: r.score,
qual: r.qual,
strand: r.strand,
template_length: r.template_length,
flags: r.flags,
Expand Down Expand Up @@ -99,4 +98,3 @@ function cacheGetter<T>(ctor: { prototype: T }, prop: keyof T): void {
}

cacheGetter(BamSlightlyLazyFeature, 'fields')
cacheGetter(BamSlightlyLazyFeature, 'parsedCigar')
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ exports[`adapter can fetch features from volvox.bam 1`] = `
"CIGAR": "100M",
"end": 5540,
"flags": 16,
"id": "test-10158054",
"name": "ctgA_5060_5540_1:0:0_3:1:0_15a3",
"next_pos": undefined,
"next_ref": undefined,
"next_segment_position": undefined,
"pair_orientation": "",
"qual": "17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17",
"refName": "ctgA",
"score": 37,
"seq": "TACACTGGTTCGGAGACGGTTCGTGACGAGCGCGCTATATGTCGGCATCTGCGCCGCATGAGCGGCCGCTGACCGGCGGCACGACTAATATAGTGCAAGA",
Expand All @@ -36,13 +34,11 @@ exports[`adapter can fetch features from volvox.bam 1`] = `
"CIGAR": "100M",
"end": 5541,
"flags": 16,
"id": "test-10158322",
"name": "ctgA_4973_5541_1:0:0_1:0:0_1569",
"next_pos": undefined,
"next_ref": undefined,
"next_segment_position": undefined,
"pair_orientation": "",
"qual": "17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17",
"refName": "ctgA",
"score": 37,
"seq": "ACACTGGTTCGGAGACGGTTCATGACGAGCGCGCTATATGTCGGCATCTGCGCCCCATGAGCGGCCCCTGTCCGGCGGCACGAATAATATAGTGCAAGAA",
Expand All @@ -66,13 +62,11 @@ exports[`adapter can fetch features from volvox.bam 1`] = `
"CIGAR": "100M",
"end": 5544,
"flags": 0,
"id": "test-10158581",
"name": "ctgA_5445_5947_3:1:0_2:0:0_2b9",
"next_pos": undefined,
"next_ref": undefined,
"next_segment_position": undefined,
"pair_orientation": "",
"qual": "17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17",
"refName": "ctgA",
"score": 37,
"seq": "CTGGTTCGGAGACGGTTCATGACGACCGCGCTATATGTCGGCATCTGCGTCGCATGAGCGGCCGCTGTCCGGCGGCTCGAATAATATAGTGCAAGAAAAA",
Expand All @@ -96,13 +90,11 @@ exports[`adapter can fetch features from volvox.bam 1`] = `
"CIGAR": "100M",
"end": 5553,
"flags": 0,
"id": "test-10158847",
"name": "ctgA_5454_5906_0:1:0_2:0:0_d8a",
"next_pos": undefined,
"next_ref": undefined,
"next_segment_position": undefined,
"pair_orientation": "",
"qual": "17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17",
"refName": "ctgA",
"score": 37,
"seq": "AGACGGTTCATGACGAGCGCGCTATATGTCGGCATCTGCGCCGCATGAGCGGCCGCTGTCCGGCGGCACGAATAATATAGTGCAAGAAAAACCGAAGACT",
Expand All @@ -126,13 +118,11 @@ exports[`adapter can fetch features from volvox.bam 1`] = `
"CIGAR": "100M",
"end": 5554,
"flags": 0,
"id": "test-12607066",
"name": "ctgA_5455_5964_2:0:0_2:0:0_23e2",
"next_pos": undefined,
"next_ref": undefined,
"next_segment_position": undefined,
"pair_orientation": "",
"qual": "17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17",
"refName": "ctgA",
"score": 37,
"seq": "GACGGTTCATGACGAGCGCGCTATATGTCGGCATCTGCGCCCCATGAGCCGCCGCTGTCCGACGGCACGAATAATATAGTGCAAGAAAAACCGAAGACTA",
Expand All @@ -156,13 +146,11 @@ exports[`adapter can fetch features from volvox.bam 1`] = `
"CIGAR": "100M",
"end": 5559,
"flags": 16,
"id": "test-12607328",
"name": "ctgA_5153_5559_3:0:0_1:1:0_11ac",
"next_pos": undefined,
"next_ref": undefined,
"next_segment_position": undefined,
"pair_orientation": "",
"qual": "17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17",
"refName": "ctgA",
"score": 37,
"seq": "TTCATGACGAGCGCGCTATATGACGGCATCTGCGCCGCATGAGCGGCCGCTGTCCGGCGGCACGAATAATATAGTGCAAGAAAAACCGAAGACTACGGTT",
Expand All @@ -186,13 +174,11 @@ exports[`adapter can fetch features from volvox.bam 1`] = `
"CIGAR": "100M",
"end": 5560,
"flags": 0,
"id": "test-12607590",
"name": "ctgA_5461_5986_1:1:0_3:0:0_200e",
"next_pos": undefined,
"next_ref": undefined,
"next_segment_position": undefined,
"pair_orientation": "",
"qual": "17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17",
"refName": "ctgA",
"score": 37,
"seq": "TCATGACGAGCGCGCTATATGTCGGCATCTGCGCCGCATCAGCGGCCGCTGTCCGGCGGCACGAATAATATAGTGCAAGAAAAACCGAAGACTACGGTTA",
Expand All @@ -216,13 +202,11 @@ exports[`adapter can fetch features from volvox.bam 1`] = `
"CIGAR": "100M",
"end": 5568,
"flags": 0,
"id": "test-12607851",
"name": "ctgA_5469_5932_0:0:0_2:0:0_6f8",
"next_pos": undefined,
"next_ref": undefined,
"next_segment_position": undefined,
"pair_orientation": "",
"qual": "17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17",
"refName": "ctgA",
"score": 37,
"seq": "AGCGCGCTATATGTCGGCATCTGCGCCCCATGAGCGGCCGCTGTCCGGCGGCACGAATAATATAGTGCAAGAAAAACCGAAGACTACGGTTATATATGAT",
Expand All @@ -246,13 +230,11 @@ exports[`adapter can fetch features from volvox.bam 1`] = `
"CIGAR": "100M",
"end": 5594,
"flags": 16,
"id": "test-12608107",
"name": "ctgA_5079_5594_1:0:0_2:0:0_d64",
"next_pos": undefined,
"next_ref": undefined,
"next_segment_position": undefined,
"pair_orientation": "",
"qual": "17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17",
"refName": "ctgA",
"score": 37,
"seq": "CCCATGAGCGGCCGCTGTCCGGCGGCACGAATAATATAGTGCAAGAAAAACCTAAGACTACGGTTATATATGATGGAACGGCCCTCACAGCATTCTCACA",
Expand All @@ -276,13 +258,11 @@ exports[`adapter can fetch features from volvox.bam 1`] = `
"CIGAR": "100M",
"end": 5596,
"flags": 0,
"id": "test-12608367",
"name": "ctgA_5497_6082_1:0:0_2:0:0_b2",
"next_pos": undefined,
"next_ref": undefined,
"next_segment_position": undefined,
"pair_orientation": "",
"qual": "17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17",
"refName": "ctgA",
"score": 37,
"seq": "CATGAGCGGCCGCTGTCCGGCGGCACGAATAATATAGTGCAAGAAAAACCGAAGACTACGGTTATATATGATGGAACGGCCCTCACAGCATTGTAACAGG",
Expand Down
Loading
Loading