Code Monkey home page Code Monkey logo

Comments (14)

kirkmcclure avatar kirkmcclure commented on August 16, 2024

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)

from picard.

kirkmcclure avatar kirkmcclure commented on August 16, 2024

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()

from picard.

nh13 avatar nh13 commented on August 16, 2024

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.

from picard.

d-cameron avatar d-cameron commented on August 16, 2024

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.

from picard.

vdauwera avatar vdauwera commented on August 16, 2024

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.

from picard.

Jigyasa3 avatar Jigyasa3 commented on August 16, 2024

I am using version 2.19, but I still have the same error while using FixMateInformation. Has it been implemented in picard's newer versions?
If not, where can I find SamPairUtil.java to make the changes in pair alignment detection as mentioned in previous threads?
Thanks!

from picard.

yfarjoun avatar yfarjoun commented on August 16, 2024

are you setting IGNORE_MISSING_MATES=true?

from picard.

Jigyasa3 avatar Jigyasa3 commented on August 16, 2024

Yes, I am.
The code-
$java -Xms20g -Xmx42g -jar /work/jigyasa-arora/picard.jar FixMateInformation I=272-23-original-sorted.bam O=272-23-original-sorted-fixedmate.bam ADD_MATE_CIGAR=true IGNORE_MISSING_MATES=true ASSUME_SORTED=true

The error-
FixMateInformation INPUT=[272-23-original-sorted.bam] OUTPUT=272-23-original-sorted-fixedmate.bam ASSUME_SORTED=true ADD_MATE_CIGAR=true IGNORE_MISSING_MATES=true VERBOSITY=INFO QUIET=false VALIDATION_STRINGENCY=STRICT COMPRESSION_LEVEL=5 MAX_RECORDS_IN_RAM=500000 CREATE_INDEX=false CREATE_MD5_FILE=false GA4GH_CLIENT_SECRETS=client_secrets.json USE_JDK_DEFLATER=false USE_JDK_INFLATER=false
[Thu Apr 25 22:57:17 JST 2019] Executing as [email protected] on Linux 3.10.0-327.el7.x86_64 amd64; OpenJDK 64-Bit Server VM 1.8.0_65-b17; Deflater: Intel; Inflater: Intel; Provider GCS is not available; Picard version: 2.19.2-SNAPSHOT
INFO 2019-04-25 22:57:45 FixMateInformation Output will be sorted by coordinate
INFO 2019-04-25 22:57:49 FixMateInformation Traversing query name sorted records and fixing up mate pair information.
[Thu Apr 25 22:57:49 JST 2019] picard.sam.FixMateInformation done. Elapsed time: 0.54 minutes.
Runtime.totalMemory()=25949634560

from picard.

yfarjoun avatar yfarjoun commented on August 16, 2024

I don't see the error in the output you posted...

from picard.

Jigyasa3 avatar Jigyasa3 commented on August 16, 2024

sorry, here goes the whole output-
[Thu Apr 25 22:57:17 JST 2019] FixMateInformation INPUT=[272-23-original-sorted.bam] OUTPUT=272-23-original-sorted-fixedmate.bam ASSUME_SORTED=true ADD_MATE_CIGAR=true IGNORE_MISSING_MATES=true VERBOSITY=INFO QUIET=false VALIDATION_STRINGENCY=STRICT COMPRESSION_LEVEL=5 MAX_RECORDS_IN_RAM=500000 CREATE_INDEX=false CREATE_MD5_FILE=false GA4GH_CLIENT_SECRETS=client_secrets.json USE_JDK_DEFLATER=false USE_JDK_INFLATER=false
[Thu Apr 25 22:57:17 JST 2019] Executing as [email protected] on Linux 3.10.0-327.el7.x86_64 amd64; OpenJDK 64-Bit Server VM 1.8.0_65-b17; Deflater: Intel; Inflater: Intel; Provider GCS is not available; Picard version: 2.19.2-SNAPSHOT
INFO 2019-04-25 22:57:45 FixMateInformation Output will be sorted by coordinate
INFO 2019-04-25 22:57:49 FixMateInformation Traversing query name sorted records and fixing up mate pair information.
[Thu Apr 25 22:57:49 JST 2019] picard.sam.FixMateInformation done. Elapsed time: 0.54 minutes.
Runtime.totalMemory()=25949634560
To get help, see http://broadinstitute.github.io/picard/index.html#GettingHelp
Exception in thread "main" htsjdk.samtools.SAMException: Found two records that are paired, not supplementary, and first of the pair
at htsjdk.samtools.SamPairUtil$SetMateInfoIterator.advance(SamPairUtil.java:454)
at htsjdk.samtools.SamPairUtil$SetMateInfoIterator.next(SamPairUtil.java:501)
at htsjdk.samtools.SamPairUtil$SetMateInfoIterator.next(SamPairUtil.java:388)
at picard.sam.FixMateInformation.doWork(FixMateInformation.java:228)
at picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:295)
at picard.cmdline.PicardCommandLine.instanceMain(PicardCommandLine.java:103)
at picard.cmdline.PicardCommandLine.main(PicardCommandLine.java:113)

from picard.

yfarjoun avatar yfarjoun commented on August 16, 2024

I think that this is a different issue. your file has two primary (i.e. not secondary or supplementary) reads with the same name but are both marked "first in pair". this cannot be fixed with this tool.

from picard.

yfarjoun avatar yfarjoun commented on August 16, 2024

(what can be fixed is that the tool can be modified to show the readname on this error.)

from picard.

yfarjoun avatar yfarjoun commented on August 16, 2024

samtools/htsjdk#1358

from picard.

salpie avatar salpie commented on August 16, 2024

I think that this is a different issue. your file has two primary (i.e. not secondary or supplementary) reads with the same name but are both marked "first in pair". this cannot be fixed with this tool.

i've just encountered the same error, is there a best practice method to fix this?

from picard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.