Skip to content

Commit

Permalink
Refactor bam features
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Nov 7, 2024
1 parent 3636c75 commit d3ac72f
Show file tree
Hide file tree
Showing 12 changed files with 809 additions and 1,207 deletions.
11 changes: 4 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
## [2.0.4](https://github.com/GMOD/bam-js/compare/v2.0.3...v2.0.4) (2024-08-09)



## [2.0.3](https://github.com/GMOD/bam-js/compare/v2.0.2...v2.0.3) (2024-07-23)


### Reverts

* Revert "Migrate to eslint9" ([65adcbb](https://github.com/GMOD/bam-js/commit/65adcbb2793243659682d30694f8604d241a5337))
* Revert "Run format" ([2a02535](https://github.com/GMOD/bam-js/commit/2a02535db4df80f245232522cdba771cbf5ea214))


- Revert "Migrate to eslint9"
([65adcbb](https://github.com/GMOD/bam-js/commit/65adcbb2793243659682d30694f8604d241a5337))
- Revert "Run format"
([2a02535](https://github.com/GMOD/bam-js/commit/2a02535db4df80f245232522cdba771cbf5ea214))

## [2.0.2](https://github.com/GMOD/bam-js/compare/v2.0.1...v2.0.2) (2024-02-21)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ feature.get('end') // 0-based half open end coordinate
feature.get('name') // QNAME
feature.get('seq') // feature sequence
feature.get('qual') // qualities
feature.get('cigar') // cigar string
feature.get('CIGAR') // CIGAR string
feature.get('MD') // MD string
feature.get('SA') // supplementary alignments
feature.get('template_length') // TLEN
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
"dependencies": {
"@gmod/abortable-promise-cache": "^2.0.0",
"@gmod/bgzf-filehandle": "^1.4.4",
"buffer": "^6.0.3",
"crc": "^4.3.2",
"generic-filehandle": "^3.0.0",
"long": "^4.0.0",
"quick-lru": "^4.0.0"
},
"devDependencies": {
Expand All @@ -53,8 +55,8 @@
"eslint": "^9.9.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-unicorn": "^55.0.0",
"prettier": "^3.2.5",
"eslint-plugin-unicorn": "^56.0.0",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"standard-changelog": "^6.0.0",
"typescript": "^5.0.4",
Expand Down
20 changes: 10 additions & 10 deletions src/bamFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,12 @@ export default class BamFile {

const recs = [] as BAMFeature[]
for (const feature of records) {
if (feature.seq_id() === chrId) {
if (feature.get('start') >= max) {
if (feature.ref_id === chrId) {
if (feature.start >= max) {
// past end of range, can stop iterating
done = true
break
} else if (feature.get('end') >= min) {
} else if (feature.end >= min) {
// must be in range
recs.push(feature)
}
Expand All @@ -319,8 +319,8 @@ export default class BamFile {
feats.map(ret => {
const readNames: Record<string, number> = {}
for (const element of ret) {
const name = element.name()
const id = element.id()
const name = element.name
const id = element.id
if (!readNames[name]) {
readNames[name] = 0
}
Expand All @@ -337,10 +337,10 @@ export default class BamFile {
const matePromises: Promise<Chunk[]>[] = []
feats.map(ret => {
for (const f of ret) {
const name = f.name()
const start = f.get('start')
const pnext = f._next_pos()
const rnext = f._next_refid()
const name = f.name
const start = f.start
const pnext = f.next_pos
const rnext = f.next_refid
if (
this.index &&
unmatedPairs[name] &&
Expand Down Expand Up @@ -377,7 +377,7 @@ export default class BamFile {
dpositions,
chunk,
)) {
if (unmatedPairs[feature.get('name')] && !readIds[feature.id()]) {
if (unmatedPairs[feature.name] && !readIds[feature.id]) {
mateRecs.push(feature)
}
}
Expand Down
Loading

0 comments on commit d3ac72f

Please sign in to comment.