# HG changeset patch # User peterjc # Date 1415103118 18000 # Node ID 14ff32f355f0001db2d9d30728130332323f3bcc # Parent 27135d7637b6c9469a00e92f3c54ac45ad6c079d Uploaded v0.0.2, pair aware bam2fq with pre-sorting diff -r 27135d7637b6 -r 14ff32f355f0 test-data/sam_spec_padded.bam2fq_pairs.fastq --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/sam_spec_padded.bam2fq_pairs.fastq Tue Nov 04 07:11:58 2014 -0500 @@ -0,0 +1,4 @@ +>r001/1 +TTAGATAAAGGATACTG +>r001/2 +ATGCCGCTG diff -r 27135d7637b6 -r 14ff32f355f0 test-data/sam_spec_padded.bam2fq_singles.fastq --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/sam_spec_padded.bam2fq_singles.fastq Tue Nov 04 07:11:58 2014 -0500 @@ -0,0 +1,8 @@ +>r002 +AAAAGATAAGGATA +>r003 +AGCTAA +>r004 +ATAGCTTCAGC +>ref +AGCATGTTAGATAAGATAGCTGTGCTAGTAGGCAGTCAGCGCCAT diff -r 27135d7637b6 -r 14ff32f355f0 tools/samtools_bam2fq/README.rst --- a/tools/samtools_bam2fq/README.rst Tue Nov 04 06:07:53 2014 -0500 +++ b/tools/samtools_bam2fq/README.rst Tue Nov 04 07:11:58 2014 -0500 @@ -49,6 +49,7 @@ Version Changes ------- ---------------------------------------------------------------------- v0.0.1 - Initial public release, tested with samtools v1.1. +v0.0.2 - Defaults to pair-aware mode which requires pre-sorting by read name. ======= ====================================================================== @@ -61,7 +62,7 @@ For making the "Galaxy Tool Shed" http://toolshed.g2.bx.psu.edu/ tarball use the following command from the Galaxy root folder:: - $ tar -czf samtools_bam2fq.tar.gz tools/samtools_bam2fq/README.rst tools/samtools_bam2fq/samtools_bam2fq.xml tools/samtools_bam2fq/tool_dependencies.xml test-data/sam_spec_padded.bam test-data/sam_spec_padded.sam test-data/sam_spec_padded.depad.bam test-data/sam_spec_padded.bam2fq.fastq test-data/sam_spec_padded.bam2fq_no_suf.fastq + $ tar -czf samtools_bam2fq.tar.gz tools/samtools_bam2fq/README.rst tools/samtools_bam2fq/samtools_bam2fq.xml tools/samtools_bam2fq/tool_dependencies.xml test-data/sam_spec_padded.bam test-data/sam_spec_padded.sam test-data/sam_spec_padded.depad.bam test-data/sam_spec_padded.bam2fq.fastq test-data/sam_spec_padded.bam2fq_no_suf.fastq test-data/sam_spec_padded.bam2fq_singles.fastq test-data/sam_spec_padded.bam2fq_pairs.fastq Check this worked:: @@ -74,6 +75,8 @@ test-data/sam_spec_padded.depad.bam test-data/sam_spec_padded.bam2fq.fastq test-data/sam_spec_padded.bam2fq_no_suf.fastq + test-data/sam_spec_padded.bam2fq_singles.fastq + test-data/sam_spec_padded.bam2fq_pairs.fastq Licence (MIT) diff -r 27135d7637b6 -r 14ff32f355f0 tools/samtools_bam2fq/samtools_bam2fq.xml --- a/tools/samtools_bam2fq/samtools_bam2fq.xml Tue Nov 04 06:07:53 2014 -0500 +++ b/tools/samtools_bam2fq/samtools_bam2fq.xml Tue Nov 04 07:11:58 2014 -0500 @@ -1,22 +1,47 @@ - + samtools bam2fq samtools samtools samtools 2>&1 | grep -i "Version:" - samtools bam2fq $suffices $orig_qual "$input_bam" > "$out_fastq" + + #if $action_mode.mode == "pairs": + ## Sort by name for pair-aware output (should give nice interlaced FASTQ) + ## Galaxy has a tendancy to automatically apply co-ordindate sorting, + ## so just do this every time. If it was name sorted, pay an IO overhead. + ## Note requiring -T is samtools issue 295 + samtools sort -n -O bam -T TEMP_SORT "$input_bam" | samtools bam2fq -s "$singletons_fastq" - > "$pairs_fastq" + #else + ## Naive conversion using order in the input file + samtools bam2fq $suffices $orig_qual "$input_bam" > "$out_fastq" + #end if + - - + + - + + + + + + + - + + (action_mode['mode'] == 'pairs') + + + (action_mode['mode'] == 'pairs') + + + (action_mode['mode'] == 'naive') + @@ -28,33 +53,59 @@ + + + + + + + + + + + + + + + + + + + + + **What it does** This tool runs the ``samtools bam2fq`` command in the SAMtools toolkit. +By default this will pre-sort your SAM/BAM file by read name and split your +reads into an interlaced FASTQ file for paired reads, and a separate FASTQ +file for singlton reads. A naive conversion is also offered which gives a +single FASTQ file with the reads ordered as in the input SAM/BAM file. + It is quite common to wish to remap high-throughput sequencing data. If you only have the mapped reads in SAM/BAM format, this tool can "unmap" them to recover FASTQ format reads to input into an alternative mapping tool.