This is a test version of Biostars. For the public version, visit https://www.biostars.org.
[E::idx_find_and_load] Could not retrieve index file for Singularity /NextFlow

Hi I am writing my first code is dsl2 Nextflow using Singularity container as below main.nf

 process pbc_varicall {
        publishDir "/data/shared/clinical/LongRead/Data/resources/"
        container 'docker://google/deepvariant:1.5.0'

        input:
        path bam
        output:
        file "*"
        path 'out_m84011_220902_175841_Chr20.vcf.gz'

        script:
        """
        run_deepvariant  --model_type PACBIO --ref ${params.ref_genome} --reads ${bam} --output_vcf ${params.data_input}out_m84011_220902_175841_Chr20.vcf.gz --num_shards 20 --regions chr20
        """
}

workflow {
        bam=channel.fromPath("${params.data_input}/m84011_220902_175841_Aln.bam")
        pbc_varicall(bam)
}

when i execute the above command with Absolute PATH for BAM file in Script section it works file, but if i pass as $bam from Input and Abs path from Workflow bam channel it gives following error

  `ValueError: FAILED_PRECONDITION: Cannot query without an index
  [E::idx_find_and_load] Could not retrieve index file for 'm84011_220902_175841_Aln.bam'

I have BAI FAI index files for Ref and BAM, i had same issue while passing $Ref thats fixed by passing ${params.ref_genome} instead of $ref from input channel

dsl2 nextflow singularity

1 answer

You're passing in the bam, but not the bai file.

Options

  1. pass in the bai file (its a file, just like you do with your bam file)
  2. create a new bai in the process using samtools (might be slow)

I already have Index file for BAM, how to pass bai to Script command as it takes only BAM

Just make a second channel with the index and provide it to the process. Many ways of doing that, e.g. via a tuple to permanently have bam and bai in the same object/variable, but this here is the simplest:

input:
path bam
path bai

Then it gets staged and is available to the process.

I tried with above but it doesnt work unless it is paired and passed to workflow as below then it works perfectly Channel.fromFilePairs('/data/shared/clinical/LongRead/Data/*_{Aln2.bam,Aln2.bam.bai}') .map { it[1] } .set { ch_bam_bai }

from.path only takes BAM then script gives index error,, So it need to be paired if one wants to pass in Workflow,, if direct BAM path is given in script: it works, not throught workflow channel

Log in to answer this question.