ucagenomix / sicelore-2.1

MIT License
13 stars 2 forks source link

java.lang.IllegalArgumentException in step3 #7

Open yuchen345 opened 1 year ago

yuchen345 commented 1 year ago

I'm getting the following error from running Step 3 - UMI assignment :

$java -jar -Xmx60G Jar/NanoporeBC_UMI_finder-2.1.jar assignumis --inFileNanopore ${mappingdir}passed.bam -o ${umidir}passedParsed.bam --annotationFile /data/chenz/genome/gencode.v42.refFlat -p

ERROR

...................................Exception in thread "Thread-3" java.lang.IllegalArgumentException: Alignments added out of order in SAMFileWriterImpl.addAlignment for file:///data/chenz/nanopore/sicelore/m1019/umis/passedParsed.bam. Sort order is coordinate. Offending records are at [chrM:14747] and [chrM:14747] at htsjdk.samtools.SAMFileWriterImpl.assertPresorted(SAMFileWriterImpl.java:212) at htsjdk.samtools.SAMFileWriterImpl.addAlignment(SAMFileWriterImpl.java:199) at htsjdk.samtools.AsyncSAMFileWriter.synchronouslyWrite(AsyncSAMFileWriter.java:36) at htsjdk.samtools.AsyncSAMFileWriter.synchronouslyWrite(AsyncSAMFileWriter.java:16) at htsjdk.samtools.util.AbstractAsyncWriter$WriterRunnable.run(AbstractAsyncWriter.java:123) at java.base/java.lang.Thread.run(Thread.java:833)

The passed.bam was sorted in step2. It seems like it failed on sorted reads saying they were not sorted?

RainerWaldmann commented 1 year ago

Could you share the chrM bam file ?

Rainer

yuchen345 commented 1 year ago

Actually, it's not convenient to share the bam file . Is there any reason for this problem and have you ever encountered the same question? Thanks

RainerWaldmann commented 1 year ago

Actually, it's not convenient to share the bam file . Is there any reason for this problem and have you ever encountered the same question? Thanks

The error is that samtools complains that the bam is not sorted. We never encountered this for sorted bams.

yuchen345 commented 1 year ago

It's weird. I'll share the chrM bam file with you. Please check your email.

RainerWaldmann commented 1 year ago

Sorry for the late reply. Since I don't get an error when I parse your bam file, I was searching for possible reasons why you get the "Sort order is coordinate. However I did not find an explanation yet. Offending records are at [chrM:14747] and [chrM:14747]" error. Both the BAM you shared and the BAM generated when I parsed it are correctly sorted. The reading and writing of the BAM files is using the samtools/htsjdk library. It should not complain that two records at the same location are out of order. I am still trying to figure out why you get this error.

Tijs-dot commented 1 year ago

Hi, I have the same issue. I was curious if this is still being investigated.

Best, Tijs

RainerWaldmann commented 1 year ago

Hi Tijs,

Can you post the exception you are getting ?

Rainer

Tijs-dot commented 1 year ago

...............Exception in thread "Thread-3" java.lang.IllegalArgumentException: Alignments added out of order in SAMFileWriterImpl.addAlignment for file:///home/twatzeels/sicelore2_tryout/outputdir_a/umis/passedParsed.bam. Sort order is coordinate. Offending records are at [chr1_KI270706v1_random:665] and [chr1_KI270706v1_random:665] at htsjdk.samtools.SAMFileWriterImpl.assertPresorted(SAMFileWriterImpl.java:212) at htsjdk.samtools.SAMFileWriterImpl.addAlignment(SAMFileWriterImpl.java:199) at htsjdk.samtools.AsyncSAMFileWriter.synchronouslyWrite(AsyncSAMFileWriter.java:36) at htsjdk.samtools.AsyncSAMFileWriter.synchronouslyWrite(AsyncSAMFileWriter.java:16) at htsjdk.samtools.util.AbstractAsyncWriter$WriterRunnable.run(AbstractAsyncWriter.java:123) at java.base/java.lang.Thread.run(Thread.java:1623)

RainerWaldmann commented 1 year ago

It is an issue with the htsjdk (samtools) library I guess. It is complaining about chr1_KI270706v1_random:665 and chr1_KI270706v1_random:665 being out of order which is weird since it is the same position. With the chrM bam file @yuchen345 shared with me I could not reproduce the error. I have an improved version of the software. Since it uses a more recent version of the htsjdk jar, it is possible that this fixes your issue.