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

FixMateInformation crashes on supplemental alignments where the mate is missing #201

Closed
vdauwera opened this Issue Apr 28, 2015 · 5 comments

Comments

Projects
None yet
4 participants
@vdauwera
Contributor

vdauwera commented Apr 28, 2015

Looks like this might be an unhandled case. Data snippet is available for testing.

Originally reported in #161.

This Issue was generated from your forums

@kirkmcclure

This comment has been minimized.

Show comment
Hide comment
@kirkmcclure

kirkmcclure Sep 26, 2015

The symptom can be created by setting the supplementary alignment flag for the first segment of a pair.
A simple contrived example:

>java -jar picard.jar ViewSam I=issue161example.bam
@HD VN:1.5  SO:coordinate
@SQ SN:xx   LN:100
@RG ID:grp1 PL:ILLUMINA LB:Library 1    DS:Group 1  SM:Sample
a1  2179    xx  1   1   10M =   41  50  AAAAAAAAAA  **********  MC:Z:10M    RG:Z:grp1   NM:i:0  MQ:i:1
a1  147 xx  41  1   10M =   1   -50 TTTTTTTTTT  **********  MC:Z:10M    RG:Z:grp1   NM:i:0  MQ:i:1
[Sat Sep 26 15:28:51 PDT 2015] picard.sam.ViewSam done. Elapsed time: 0.01 minutes.

>java -jar picard.jar ValidateSamFile I=issue161example.bam
ERROR: Read name a1, Mate not found for paired read
[Sat Sep 26 15:38:13 PDT 2015] picard.sam.ValidateSamFile done. Elapsed time: 0.01 minutes.

>java -jar picard.jar FixMateInformation I=issue161example.bam O=fixed.bam
... Picard version: 1.139(8ceee52414e8ab9d13e350ff9cd86d48825dd64d_1442240108) JdkDeflater
INFO    2015-09-26 15:42:20 FixMateInformation  Sorting input into query name order.
INFO    2015-09-26 15:42:20 FixMateInformation  Sorting by queryname complete.
INFO    2015-09-26 15:42:20 FixMateInformation  Output will be sorted by coordinate
INFO    2015-09-26 15:42:20 FixMateInformation  Traversing query name sorted records and fixing up mate pair information.
[Sat Sep 26 15:42:20 PDT 2015] picard.sam.FixMateInformation done. Elapsed time: 0.01 minutes.
Runtime.totalMemory()=16121856
To get help, see http://broadinstitute.github.io/picard/index.html#GettingHelp
Exception in thread "main" java.lang.NullPointerException
    at htsjdk.samtools.SamPairUtil.setMateInformationOnSupplementalAlignment(SamPairUtil.java:300)
    at htsjdk.samtools.SamPairUtil$SetMateInfoIterator.advance(SamPairUtil.java:445)
    at htsjdk.samtools.SamPairUtil$SetMateInfoIterator.next(SamPairUtil.java:454)
    at htsjdk.samtools.SamPairUtil$SetMateInfoIterator.next(SamPairUtil.java:360)
    at picard.sam.FixMateInformation.doWork(FixMateInformation.java:195)
    at picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:206)
    at picard.cmdline.PicardCommandLine.instanceMain(PicardCommandLine.java:95)
    at picard.cmdline.PicardCommandLine.main(PicardCommandLine.java:105)

kirkmcclure commented Sep 26, 2015

The symptom can be created by setting the supplementary alignment flag for the first segment of a pair.
A simple contrived example:

>java -jar picard.jar ViewSam I=issue161example.bam
@HD VN:1.5  SO:coordinate
@SQ SN:xx   LN:100
@RG ID:grp1 PL:ILLUMINA LB:Library 1    DS:Group 1  SM:Sample
a1  2179    xx  1   1   10M =   41  50  AAAAAAAAAA  **********  MC:Z:10M    RG:Z:grp1   NM:i:0  MQ:i:1
a1  147 xx  41  1   10M =   1   -50 TTTTTTTTTT  **********  MC:Z:10M    RG:Z:grp1   NM:i:0  MQ:i:1
[Sat Sep 26 15:28:51 PDT 2015] picard.sam.ViewSam done. Elapsed time: 0.01 minutes.

>java -jar picard.jar ValidateSamFile I=issue161example.bam
ERROR: Read name a1, Mate not found for paired read
[Sat Sep 26 15:38:13 PDT 2015] picard.sam.ValidateSamFile done. Elapsed time: 0.01 minutes.

>java -jar picard.jar FixMateInformation I=issue161example.bam O=fixed.bam
... Picard version: 1.139(8ceee52414e8ab9d13e350ff9cd86d48825dd64d_1442240108) JdkDeflater
INFO    2015-09-26 15:42:20 FixMateInformation  Sorting input into query name order.
INFO    2015-09-26 15:42:20 FixMateInformation  Sorting by queryname complete.
INFO    2015-09-26 15:42:20 FixMateInformation  Output will be sorted by coordinate
INFO    2015-09-26 15:42:20 FixMateInformation  Traversing query name sorted records and fixing up mate pair information.
[Sat Sep 26 15:42:20 PDT 2015] picard.sam.FixMateInformation done. Elapsed time: 0.01 minutes.
Runtime.totalMemory()=16121856
To get help, see http://broadinstitute.github.io/picard/index.html#GettingHelp
Exception in thread "main" java.lang.NullPointerException
    at htsjdk.samtools.SamPairUtil.setMateInformationOnSupplementalAlignment(SamPairUtil.java:300)
    at htsjdk.samtools.SamPairUtil$SetMateInfoIterator.advance(SamPairUtil.java:445)
    at htsjdk.samtools.SamPairUtil$SetMateInfoIterator.next(SamPairUtil.java:454)
    at htsjdk.samtools.SamPairUtil$SetMateInfoIterator.next(SamPairUtil.java:360)
    at picard.sam.FixMateInformation.doWork(FixMateInformation.java:195)
    at picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:206)
    at picard.cmdline.PicardCommandLine.instanceMain(PicardCommandLine.java:95)
    at picard.cmdline.PicardCommandLine.main(PicardCommandLine.java:105)
@kirkmcclure

This comment has been minimized.

Show comment
Hide comment
@kirkmcclure

kirkmcclure Sep 29, 2015

A simple solution is to subordinate supplementary-alignment processing, i.e.

            // Set mate information on supplemental records
            if (containsSupplementalRecord) {
              ...
            }

to the condition (immediately preceding) that both pair-alignments have been identified -

            // we must find both records to update the mate info
            if (null != firstPrimaryRecord && null != secondPrimaryRecord) {

in SamPairUtil.java advance()

kirkmcclure commented Sep 29, 2015

A simple solution is to subordinate supplementary-alignment processing, i.e.

            // Set mate information on supplemental records
            if (containsSupplementalRecord) {
              ...
            }

to the condition (immediately preceding) that both pair-alignments have been identified -

            // we must find both records to update the mate info
            if (null != firstPrimaryRecord && null != secondPrimaryRecord) {

in SamPairUtil.java advance()

@nh13

This comment has been minimized.

Show comment
Hide comment
@nh13

nh13 Sep 29, 2015

Collaborator

I think it is odd that a tool that is trying to fix mate information should be OK with the case where one end of a pair is missing. Nonetheless, this is the current behavior, so I added an option to allow for the case where we want to catch this. This requires a htsjdk and picard update.

Collaborator

nh13 commented Sep 29, 2015

I think it is odd that a tool that is trying to fix mate information should be OK with the case where one end of a pair is missing. Nonetheless, this is the current behavior, so I added an option to allow for the case where we want to catch this. This requires a htsjdk and picard update.

@vdauwera vdauwera removed the 1 - Ready label Feb 12, 2016

@d-cameron

This comment has been minimized.

Show comment
Hide comment
@d-cameron

d-cameron Aug 20, 2016

Is it possible for FixMateInformation to fix the mate information for a read for which no mate is found? That is, strip mate information and remove SAM flags indicating that it is paired.

It seems strange (and contrary to the usage I was just attempting) that after running FixMateInformation, there would still be reads with incorrect mate information left.

d-cameron commented Aug 20, 2016

Is it possible for FixMateInformation to fix the mate information for a read for which no mate is found? That is, strip mate information and remove SAM flags indicating that it is paired.

It seems strange (and contrary to the usage I was just attempting) that after running FixMateInformation, there would still be reads with incorrect mate information left.

@vdauwera

This comment has been minimized.

Show comment
Hide comment
@vdauwera

vdauwera Jan 19, 2017

Contributor

The original issue has been fixed.

@d-cameron Sorry for the late response. I think there are indeed some things that FMI doesn't address but I don't know the details. @nh13 may be able to tell you more.

Contributor

vdauwera commented Jan 19, 2017

The original issue has been fixed.

@d-cameron Sorry for the late response. I think there are indeed some things that FMI doesn't address but I don't know the details. @nh13 may be able to tell you more.

@vdauwera vdauwera closed this Jan 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment