epi2me-labs / modbam2bed

Other
47 stars 8 forks source link

[E::fai_retrieve] Failed to retrieve block: unexpected end of file #34

Closed PanZiwei closed 2 years ago

PanZiwei commented 2 years ago

Hi, Thanks for the amazing tool. I am trying to use the tool to get bed filles but got an unexpected error.

For modbam2bed, i am using the command below: modbam2bed -e -m 5mC --cpg -t ${THREAD} ${REF_FASTA} ${OUTPUT_BAM} > ${OUTPUT_BED}

The error message is:

Analysing: 5-methylcytosine (5mC, C>m)
[E::fai_retrieve] Failed to retrieve block: unexpected end of file
/cm/local/apps/slurm/var/spool/job16538506/slurm_script: line 47: 147304 Segmentation fault      modbam2bed -e -m 5mC --cpg -t ${THREAD} ${REF_FASTA} ${OUTPUT_BAM} > ${OUTPUT_BED}

Here is what I did: Guppy base-calling with modification model with --align_ref for fastq output -> Minimap2 to align fastq for sam files -> Use samtools to convert sam file to get bam file (sorted and indexed) -> Merged bam files -> Rerun samtools to sort and index the merged bam file -> Run modbam2bed on the bam file

Would really appreciate it if you can provide hints to solve the problem! I saw a similar issue on https://github.com/epi2me-labs/modbam2bed/issues/6 but am not sure about the solution.

cjw85 commented 2 years ago

Can you provide the command you are using without variables? I suspect something is incorrect in your arguments or your reference file is incorrect somehow

PanZiwei commented 2 years ago

@cjw85 Thanks for the reply! See the command below.

modbam2bed -e -m 5mC --cpg -t 30 /reference/T2T.fna /test/test.merged.sorted.bam > /test/test.bed
cjw85 commented 2 years ago

The message:

[E::fai_retrieve] Failed to retrieve block: unexpected end of file

suggests an error reading sequences from you T2T.fna file. Can you check that this file is complete, not currupt, and its corresponding index file is up to date.

PanZiwei commented 2 years ago

Thanks for the tips! I reprepare the .fna and .fna.fai and it indeed worked. Thanks again for your help! I will close the ticket.

PanZiwei commented 2 years ago

Sorry to interrupt again. One following question will be: I assume the alignment is done inside the Guppy when adding the --align_ref step so that the output bam file is aligned already? In other words, there is no need to do the minimap2 for alignment right?

cjw85 commented 2 years ago

Correct, the --align_ref option in Guppy enables alignment to a reference.