Skip to content

add bedregion option to samInfo mapq#1124

Merged
craiglowe merged 8 commits intomainfrom
bedRegionMapq
Mar 2, 2026
Merged

add bedregion option to samInfo mapq#1124
craiglowe merged 8 commits intomainfrom
bedRegionMapq

Conversation

@sweavs111
Copy link
Copy Markdown
Contributor

@sweavs111 sweavs111 commented Feb 23, 2026

Description

This is a follow up PR to the one that got merged in yesterday. It adds an option to the saminfo mapq function where the user can specify a bed region and only alignments overlapping that bed region will be analyzed for the mapping quality histogram.

The consequential function to look at is the bedRegionsOnly sub function. All other code should be the same as before, but I had to break it up into multiple sub-functions so that both bedRegionsOnly  and the original wholeGenome functions could use the sub functions.

lmk if you have any questions!

🐛 Bug Report

Testing

None

Checklist before requesting a review

  • I performed a self-review of my code
  • If it this a core feature, I added thorough tests
  • The command go fmt or make clean was used on all files included

Comment thread cmd/samInfo/coverage.go
var countNinDepth *bool = coverageFlags.Bool("countNinDepth", true, "If true, count 'N' reads towards total depth of pileups.")
var verbose *int = coverageFlags.Int("verbose", 0, "Set to 1 to reveal debug prints. Verbose in this program reports Poisson parameter lambda.")
var highEndFilter *float64 = coverageFlags.Float64("highEndFilter", 0.001, "Percent threshold from right end of distribution to be filtered out")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to fix a bug in the "coverage" subcommand where the optional arguments weren't defined until after the logfatal check for number of arguments. So previously they weren't printed out when the user types ~/go/bin/samInfo coverage

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 23, 2026

Codecov Report

❌ Patch coverage is 65.00000% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.13%. Comparing base (d0c56ba) to head (8928427).

Files with missing lines Patch % Lines
cmd/samInfo/mapq.go 72.22% 13 Missing and 2 partials ⚠️
cmd/samInfo/coverage.go 0.00% 6 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1124   +/-   ##
=======================================
  Coverage   66.13%   66.13%           
=======================================
  Files         443      443           
  Lines      172452   172481   +29     
=======================================
+ Hits       114049   114070   +21     
- Misses      56803    56810    +7     
- Partials     1600     1601    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sweavs111 sweavs111 marked this pull request as ready for review February 24, 2026 15:21
Comment thread cmd/samInfo/mapq.go

//open up the alinment file with a bam reader (more efficient search for overlapped regions)
br, _ := sam.OpenBam(s.InFile)
bai := sam.ReadBai(s.InFile + ".bai")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a check for the existence of a valid bai file that log fatals if the check fails?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ReadBai function would log fatal if the .bai file didn't exist. But I created some safer and more specific error handling. Thanks!

Copy link
Copy Markdown
Contributor

@hcnapier hcnapier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@craiglowe craiglowe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@craiglowe craiglowe merged commit 0925219 into main Mar 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants