Converting multiple cram files to fastq files.
1
0
Entering edit mode
2.8 years ago
Rose • 0

Hello everyone, I need help with converting cram files to fastq files. I have many cram files with me and want to convert them to fastq files at once. I am using samtools for conversion. Is there any possible way to do that ??

cram fatsq • 1.4k views
ADD COMMENT
0
Entering edit mode

You can simply use a for loop to go through all files or submit parallel jobs if you are on a cluster and can use a job scheduler.

ADD REPLY
0
Entering edit mode

Can you please give the code with for loop, I am actually new to scripting and tried a lot but none of them working.

ADD REPLY
0
Entering edit mode

Do not delete posts that have received feedback. Show us something that you've tried and tell us how it failed.

ADD REPLY
0
Entering edit mode
2.8 years ago

using a Makefile

BAMS=$(shell find /path/to/dir -type f -name "*.cram" )
FASTQS=$(addsuffix .R1.fastq.gz,$(basename $(BAMS)))
REF=/path/to/ref.fa

%.R1.fastq.gz: %.cram
    samtools collate --reference $(REF) -O -u -f --no-PG $< |\
    samtools bam2fq -1 $@ -2 $(addsuffix .R2.fastq.gz,$(basename $<))


all: $(FASTQS)

invoke with make -j <number-of-threads>

ADD COMMENT

Login before adding your answer.

Traffic: 2487 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6