Piping Input Into Picard Sortsam
2
2
Entering edit mode
11.5 years ago
eva.knig ▴ 70

Hello everyone,

does it make any sense to (Unix) pipe input into Picard SortSam, or will SortSam wait for all the input before starting?

For example, if I have the command

samtools view -Shu in.sam | \
java -Xmx4g SortSam.jar I=/dev/stdin O=sorted.bam SO=coordinate VALIDATION_STRINGENCY=SILENT

Will SortSam already do some work on the reads it gets from samtools view (e.g. by putting new reads in place) or will it wait for ALL reads from samtools until it starts sorting? In the latter case I would have SortSam running and blocking memory without doing something for the execution time of samtools view. Does anybody know?

Thanks

picard bam • 13k views
ADD COMMENT
2
Entering edit mode

I=/dev/stdin : very useful, thanks !

ADD REPLY
6
Entering edit mode
10.6 years ago
Caddymob ▴ 1000

Yes, picard (and most java apps should) take pipes. I do query sorts to FASTQs like this as one example:

java -Xmx30g -jar ${PICARD}/SortSam.jar \
I=$IN_BAM \
TMP_DIR=${TMP} \
MAX_RECORDS_IN_RAM=7000000 \
VALIDATION_STRINGENCY=LENIENT \
COMPRESSION_LEVEL=0 \
O=/dev/stdout \
SORT_ORDER=queryname | \ # NOTE PIPE HERE
java -Xmx12g -jar ${PICARD}/SamToFastq.jar \
I=/dev/stdin \
MAX_RECORDS_IN_RAM=3000000 \
VALIDATION_STRINGENCY=LENIENT \
F=$OUT.R1.fq \
F2=$OUT.R2.fq

O=/dev/stdout and I=/dev/stdin are quite handy :) I havent run time comparisons, but I like pipes wherever I can.

ADD COMMENT
1
Entering edit mode
11.5 years ago
Irsan ★ 7.8k

I don't know by experience by you can try it and use

[your_command_prompt]$ top

To see if both samtools and java SortSam.jar are running at the same time

ADD COMMENT
0
Entering edit mode

Good idea thanks. So I was running the command and from the CPU usage one can see that both programs acutally are running (and computing) something at the same time.

ADD REPLY

Login before adding your answer.

Traffic: 1501 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