ngless-toolkit / ngless-toolkit/ngless
mapstats() should error with position sorted sam/bam files
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 152
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Description
Fixing this to handle position sorted bam/sam files will require a similar approach to #72 and keeping an index of read headers in-memory.
An easier solution is to detect if the file is positionally sorted and error informing the user that a name sorted (or unsorted) file is required.
According to this biostars question the HD field can provide this info.
From a local test:
% head -n 1 texpected-unsorted.sam
@SQ SN:122_DCM_0d2-0d45_scaffold97490_1_gene122702 LN:30803
% head -n 2 texpected-pos_sorted.sam
@HD VN:1.3 SO:coordinate
@SQ SN:122_DCM_0d2-0d45_scaffold97490_1_gene122702 LN:30803
% head -n 2 texpected-name_sorted.sam
@HD VN:1.3 SO:queryname
@SQ SN:122_DCM_0d2-0d45_scaffold97490_1_gene122702 LN:30803
The question above also mentions:
% samtools view -H 5_110118_FC62VT6AAXX-hg18-unsort.bam
@HD VN:1.0 SO:unsorted
but it seems this field isn't always present in unsorted files.
Regardless, failing in the case of SO:coordinate safeguards the user from erroneous results.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating mapstats() and review issue #72 for the similar in-memory read-header approach. Inspect SAM/BAM header handling, including the HD field and SO:coordinate value, then use the issue's sorted and unsorted examples to verify that position-sorted input is rejected while name-sorted or unsorted input remains supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- bioinformatics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100