nvnieuwk / nft-bam

An nf-test plugin for reading the contents of SAM/BAM/CRAM files in assertions
https://nvnieuwk.github.io/nft-bam/
MIT License
6 stars 2 forks source link

SAM validation error #3

Closed fellen31 closed 4 months ago

fellen31 commented 4 months ago

Hi, I'm trying to use nft-bam on some files where the read group does not exist in the header. Would it be possible for nft-bam to ignore this error?

 htsjdk.samtools.SAMFormatException: SAM validation error: ERROR::READ_GROUP_NOT_FOUND:Record 1, Read name m84039_230117_233243_s1/163973658/ccs, RG ID on SAMRecord not found in header: 92af947f/0--0
nvnieuwk commented 4 months ago

Hi @fellen31, can you give me a file I can use to test this out? I'll see if I can somehow do this using HTSJDK :)

fellen31 commented 4 months ago

Sure, thanks!

https://www.dropbox.com/scl/fi/w9yinzj4uhbba65xdtz3f/HG002_Revio_A.bam?rlkey=2fgjfawm7h9swf5mgan7wjk01&st=4pw0ose7&dl=0

nvnieuwk commented 4 months ago

Thanks for the file! However I don't get the error you posted when trying this out myself. Do you have an example of the code you used?

fellen31 commented 4 months ago

Hm, I'm trying to snapshot the reads, or md5s.

https://github.com/genomic-medicine-sweden/nallo/blob/f5dd4ca8559b8d47c98cf2818b0e8cf12e8af402/tests/main.nf.test#L163-L174

The error I get is:

      -[genomic-medicine-sweden/nallo] Pipeline completed successfully
      Stop plugin 'nf-validation@1.1.3'

    htsjdk.samtools.SAMFormatException: SAM validation error: ERROR::READ_GROUP_NOT_FOUND:Record 1, Read name m84039_230117_233243_s1/163973658/ccs, RG ID on SAMRecord not found in header: 92af947f/0--0
FAILED (262.751s)

  Assertion failed:

  1 of 100 assertions failed

Assertion failed:

1 of 100 assertions failed

        at com.askimed.nf.test.lang.extensions.GlobalMethods.assertAll(GlobalMethods.java:48)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
        at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:44)
        at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.callStatic(StaticMetaMethodSite.java:100)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:55)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:217)
        at main_nf$_run_closure1$_closure3$_closure62.doCall(main.nf.test:164)
        at main_nf$_run_closure1$_closure3$_closure62.doCall(main.nf.test)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:274)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1030)
        at groovy.lang.Closure.call(Closure.java:427)
        at groovy.lang.Closure.call(Closure.java:406)
        at com.askimed.nf.test.lang.TestCode.execute(TestCode.java:16)
        at com.askimed.nf.test.lang.pipeline.PipelineTest.execute(PipelineTest.java:135)
        at com.askimed.nf.test.core.TestExecutionEngine.execute(TestExecutionEngine.java:214)
        at com.askimed.nf.test.commands.RunTestsCommand.execute(RunTestsCommand.java:184)
        at com.askimed.nf.test.commands.AbstractCommand.call(AbstractCommand.java:43)
        at com.askimed.nf.test.commands.AbstractCommand.call(AbstractCommand.java:18)
        at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
        at picocli.CommandLine.access$1300(CommandLine.java:145)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
        at picocli.CommandLine.execute(CommandLine.java:2078)
        at com.askimed.nf.test.App.run(App.java:44)
        at com.askimed.nf.test.App.main(App.java:51)
  Nextflow stdout:

  Nextflow stderr:

FAILURE: Executed 1 tests in 262.759s (1 failed)
nvnieuwk commented 4 months ago

Aha I tried it with .getHeader(). That seems to work, but .getReads() fails. I'll see what I can do about it

nvnieuwk commented 4 months ago

Although it does look like you are missing a readgroup ID in your header that's present in the reads. I'm not sure this is intended?

fellen31 commented 4 months ago

Yes, there is a readgroup present in the reads that's not in the header. I actually didn't know it was there before I tried no snapshot the reads. No downstream tools (including samtools) complains though, and the SAM format doesn't strictly require a RG line in the header.

nvnieuwk commented 4 months ago

Allright I'm currently testing out a way to set the stringency of the HTSJDK validation which should allow you to ignore these errors. I'll let you know once that works :)

nvnieuwk commented 4 months ago

Hi can you try it out with this new (unreleased) version?

nft-bam-0.2.1.jar.gz

Just add this option to the bam() function: bam(..., stringency: 'lenient') (You can also set it to 'silent' if you also don't want the warnings

Then run the new plugin using this command:

nf-test test --plugins nft-bam-0.2.1.jar <your other options>
nvnieuwk commented 4 months ago

@fellen31 any news on this? This new feature is ready to release once you can confirm that it works on your side :)

fellen31 commented 4 months ago

I’ll have a look today!

fellen31 commented 4 months ago

Looks good!

nvnieuwk commented 4 months ago

Awesome! I'll release this then :)

fellen31 commented 4 months ago

Thank you!

nvnieuwk commented 4 months ago

release v0.3.0 contains these changes