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

give BWA-spark better default read filters #4286

Merged
merged 1 commit into from
Jan 30, 2018

Conversation

lbergelson
Copy link
Member

Wellformed is too strict for BWA since it asserts things about the alignment. It also doesn't correctly remove secondary and supplementary alignments like we should we performing a new alignment.

@droazen droazen self-assigned this Jan 29, 2018
Copy link
Contributor

@droazen droazen left a comment

Choose a reason for hiding this comment

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

Review complete, back to @lbergelson for changes. Merge after addressing comments.

@@ -45,6 +48,12 @@ public boolean requiresReads() {
return true;
}

@Override
public List<ReadFilter> getDefaultReadFilters() {
// 1) unmapped or neither secondary nor supplementary and 2) has some sequence
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment seems a little off here -- shouldn't this say "primary" rather than "unmapped"?

Copy link
Member Author

Choose a reason for hiding this comment

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

clarified

@@ -121,6 +122,9 @@ public void close() {
this.bwaMemIndex = BwaMemIndexCache.getInstance(indexFileName);
this.readsHeader = readsHeader;
this.alignsPairs = alignsPairs;
if ( alignsPairs && readsHeader.getSortOrder() != SAMFileHeader.SortOrder.queryname ) {
throw new UserException("Input must be queryname sorted unless you use single-ended alignment mode.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a test that exercises this case?

Copy link
Contributor

Choose a reason for hiding this comment

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

What if it is "unsorted" but with group order "queryname"?

Copy link
Member Author

Choose a reason for hiding this comment

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

@magicDGS That's a very good point. That should allowed as well. I'll update it.

if (alignsPairs && (nReads & 1) != 0 ) {
throw new GATKException("We're supposed to be aligning paired reads, but there are an odd number of them.");
if ( alignsPairs ) {
if ( (nReads & 1) != 0 ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you using bitwise-AND instead of the mod operator to check whether the number is odd? Mod is more straightforward I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

Because Ted Sharpe. Changed.

final String readName1 = inputReads.get(idx).getName();
final String readName2 = inputReads.get(idx+1).getName();
if ( !Objects.equals(readName1,readName2) ) {
throw new GATKException("Read pair has varying template name: "+readName1+" .vs "+readName2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this one be a UserException, since it's a problem with the input?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

throw new GATKException("We're supposed to be aligning paired reads, but there are an odd number of them.");
if ( alignsPairs ) {
if ( (nReads & 1) != 0 ) {
throw new GATKException("We're supposed to be aligning paired reads, but there are an odd number of them.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a UserException?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes it should, fixed

@@ -88,6 +88,7 @@ else if ( alwaysGenerateASandXS ) {
samRecord.setReadBases(SAMRecord.NULL_SEQUENCE);
samRecord.setBaseQualities(SAMRecord.NULL_QUALS);
}
//TODO: there ought to be a way to indicate a set of tag names that ought to be copied -- we're just doing RG
if ( readGroup != null ) samRecord.setAttribute(SAMTag.RG.name(), readGroup);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add curly braces around if statement body.

Copy link
Member Author

Choose a reason for hiding this comment

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

done, although I didn't hit the rest of the file

@@ -60,5 +61,4 @@ public void testSingleEnd() throws Exception {

SamAssertionUtils.assertSamsEqual(new File(output, "part-r-00000.bam"), expectedSam);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Aren't there any additional tests for BwaSpark that pass with this fix and failed without it? If not, can you add one?

@droazen droazen assigned lbergelson and unassigned droazen Jan 29, 2018
@droazen
Copy link
Contributor

droazen commented Jan 30, 2018

@lbergelson Please address the code review comments in a separate PR, since they mainly have to do with comments and testing -- I'm merging this as-is for now.

@droazen droazen merged commit 668a6ec into master Jan 30, 2018
@droazen droazen deleted the lb_improve_bwaspark_marginally branch January 30, 2018 15:03
lbergelson added a commit that referenced this pull request Jan 31, 2018
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.

4 participants