# HG changeset patch
# User devteam
# Date 1390832901 18000
# Node ID bc9269529e88241e8e8ede65a4781644e38c91cc
Imported from capsule None
diff -r 000000000000 -r bc9269529e88 fastq_to_tabular.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/fastq_to_tabular.py Mon Jan 27 09:28:21 2014 -0500
@@ -0,0 +1,38 @@
+#Dan Blankenberg
+import sys
+from galaxy_utils.sequence.fastq import fastqReader
+
+def stop_err( msg ):
+ sys.stderr.write( msg )
+ sys.exit()
+
+def main():
+ if len(sys.argv) != 5:
+ stop_err("Wrong number of arguments. Expect: fasta tabular desrc_split [type]")
+ input_filename = sys.argv[1]
+ output_filename = sys.argv[2]
+ descr_split = int( sys.argv[3] ) - 1
+ if descr_split < 0:
+ stop_err("Bad description split value (should be 1 or more)")
+ input_type = sys.argv[4] or 'sanger' #input type should ordinarily be unnecessary
+
+ num_reads = None
+ fastq_read = None
+ out = open( output_filename, 'wb' )
+ if descr_split == 0:
+ #Don't divide the description into multiple columns
+ for num_reads, fastq_read in enumerate( fastqReader( open( input_filename ), format = input_type ) ):
+ out.write( "%s\t%s\t%s\n" % ( fastq_read.identifier[1:].replace( '\t', ' ' ), fastq_read.sequence.replace( '\t', ' ' ), fastq_read.quality.replace( '\t', ' ' ) ) )
+ else:
+ for num_reads, fastq_read in enumerate( fastqReader( open( input_filename ), format = input_type ) ):
+ words = fastq_read.identifier[1:].replace( '\t', ' ' ).split(None, descr_split)
+ #pad with empty columns if required
+ words += [""]*(descr_split-len(words))
+ out.write( "%s\t%s\t%s\n" % ("\t".join(words), fastq_read.sequence.replace( '\t', ' ' ), fastq_read.quality.replace( '\t', ' ' ) ) )
+ out.close()
+ if num_reads is None:
+ print "No valid FASTQ reads could be processed."
+ else:
+ print "%i FASTQ reads were converted to Tabular." % ( num_reads + 1 )
+
+if __name__ == "__main__": main()
diff -r 000000000000 -r bc9269529e88 fastq_to_tabular.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/fastq_to_tabular.xml Mon Jan 27 09:28:21 2014 -0500
@@ -0,0 +1,104 @@
+
+ converter
+
+ galaxy_sequence_utils
+
+ fastq_to_tabular.py '$input_file' '$output_file' $descr_columns '${input_file.extension[len( 'fastq' ):]}'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+**What it does**
+
+This tool converts FASTQ sequencing reads to a Tabular file.
+
+It is conventional to take the first word of the FASTQ "@" title line as the identifier, and any remaining text to be a free form description.
+It is therefore often useful to split this text into two columns in Galaxy (identifier and any description) by setting **How many columns to divide title string into?** to **2**.
+In some cases the description can be usefully broken up into more columns -- see the examples .
+
+Tab characters, if present in the source FASTQ title, will be converted to spaces.
+
+-----
+
+**Example**
+
+Consider the following two 454 reads in Sanger FASTQ format (using line wrapping for display, but do note not all tools will accept line wrapped FASTQ files)::
+
+ @FSRRS4401BE7HA [length=395] [gc=36.46] [flows=800] [phred_min=0] [phred_max=40] [trimmed_length=95]
+ tcagTTAAGATGGGATAATATCCTCAGATTGCGTGATGAACTTTGTTCTGGTGGAGGAGAAGGAAGTGCATTCGACGTAT
+ GCCCGTTTGTCGATATTTGtatttaaagtaatccgtcacaaatcagtgacataaatattatttagatttcgggagcaact
+ ttatttattccacaagcaggtttaaattttaaatttaaattattgcagaagactttaaattaacctcgttgtcggagtca
+ tttgttcggttattggtcgaaagtaaccncgggaagtgccgaaaactaacaaacaaaagaagatagtgaaattttaatta
+ aaanaaatagccaaacgtaactaactaaaacggacccgtcgaggaactgccaacggacgacacagggagtagnnn
+ +FSRRS4401BE7HA [length=395] [gc=36.46] [flows=800] [phred_min=0] [phred_max=40] [trimmed_length=95]
+ FFFDDDDDDDA666?688FFHGGIIIIIIIIIIIIIIIIIIHHHIIIIIIIIIGHGFFFFF====DFFFFFFFFFFFFFF
+ D???:3104/76=:5...4.3,,,366////4<ABBAAA=CCFDDDDDDDD:666CDFFFF=<ABA=;:333111<===9
+ 9;B889FFFFFFDDBDBDDD=8844231..,,,-,,,,,,,,1133..---17111,,,,,22555131121.--.,333
+ 11,.,,3--,,.,,--,3511123..--!,,,,--,----9,,,,8=,,-,,,-,,,,---26:9:5-..1,,,,11//,
+ ,,,!,,1917--,,,,-3.,--,,17,,,,---+11113.030000,,,044400036;96662.//;7><;!!!
+ @FSRRS4401BRRTC [length=145] [gc=38.62] [flows=800] [phred_min=0] [phred_max=38] [trimmed_length=74]
+ tcagCCAGCAATTCCGACTTAATTGTTCTTCTTCCATCATTCATCTCGACTAACAGTTCTACGATTAATGAGTTTGGCtt
+ taatttgttgttcattattgtcacaattacactactgagactgccaaggcacncagggataggnn
+ +FSRRS4401BRRTC [length=145] [gc=38.62] [flows=800] [phred_min=0] [phred_max=38] [trimmed_length=74]
+ FFFFFFFFFDDDDFFFFGFDDDDBAAAAA=<4444@@B=555:BBBBB@@?8:8<?<89898<84442;==3,,,514,,
+ ,11,,,.,,21777555513,..--1115758.//34488><<;;;;9944/!/4,,,57855!!
+
+By default this is converted into a 3 column tabular file, with the full FASTQ title used as column 1:
+
+=================================================================================================== ============== ==============
+FSRRS4401BE7HA [length=395] [gc=36.46] [flows=800] [phred_min=0] [phred_max=40] [trimmed_length=95] tcagTTAA...nnn FFFDDDDD...!!!
+FSRRS4401BRRTC [length=145] [gc=38.62] [flows=800] [phred_min=0] [phred_max=38] [trimmed_length=74] tcagCCAG...gnn FFFFFFFF...5!!
+=================================================================================================== ============== ==============
+
+If you specified the title should be turned into 2 columns, you'd get 4 columns in total:
+
+============== ==================================================================================== ============== ==============
+FSRRS4401BE7HA [length=395] [gc=36.46] [flows=800] [phred_min=0] [phred_max=40] [trimmed_length=95] tcagTTAA...nnn FFFDDDDD...!!!
+FSRRS4401BRRTC [length=145] [gc=38.62] [flows=800] [phred_min=0] [phred_max=38] [trimmed_length=74] tcagCCAG...gnn FFFFFFFF...5!!
+============== ==================================================================================== ============== ==============
+
+Similarly, for this example treating the title string as 7 columns makes sense:
+
+============== ============ ========== =========== ============= ============== =================== ============== ==============
+FSRRS4401BE7HA [length=395] [gc=36.46] [flows=800] [phred_min=0] [phred_max=40] [trimmed_length=95] tcagTTAA...nnn FFFDDDDD...!!!
+FSRRS4401BRRTC [length=145] [gc=38.62] [flows=800] [phred_min=0] [phred_max=38] [trimmed_length=74] tcagCCAG...gnn FFFFFFFF...5!!
+============== ============ ========== =========== ============= ============== =================== ============== ==============
+
+Note the sequences and quality strings have been truncated for display purposes in the above tables.
+
+------
+
+**Citation**
+
+If you use this tool, please cite `Blankenberg D, Gordon A, Von Kuster G, Coraor N, Taylor J, Nekrutenko A; Galaxy Team. Manipulation of FASTQ data with Galaxy. Bioinformatics. 2010 Jul 15;26(14):1783-5. <http://www.ncbi.nlm.nih.gov/pubmed/20562416>`_
+
+
+
+
diff -r 000000000000 -r bc9269529e88 test-data/fastq_to_tabular_out_1.tabular
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/fastq_to_tabular_out_1.tabular Mon Jan 27 09:28:21 2014 -0500
@@ -0,0 +1,2 @@
+FAKE0001 Original version has PHRED scores from 0 to 93 inclusive (in that order) ACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTAC !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
+FAKE0002 Original version has PHRED scores from 93 to 0 inclusive (in that order) CATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCA ~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"!
diff -r 000000000000 -r bc9269529e88 test-data/fastq_to_tabular_out_2.tabular
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/fastq_to_tabular_out_2.tabular Mon Jan 27 09:28:21 2014 -0500
@@ -0,0 +1,2 @@
+FAKE0001 Original version has PHRED scores from 0 to 93 inclusive (in that order) G2131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
+FAKE0002 Original version has PHRED scores from 93 to 0 inclusive (in that order) G3131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131 ~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"!
diff -r 000000000000 -r bc9269529e88 test-data/fastq_to_tabular_out_3.tabular
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/fastq_to_tabular_out_3.tabular Mon Jan 27 09:28:21 2014 -0500
@@ -0,0 +1,2 @@
+FAKE0001 Original version has PHRED scores from 0 to 93 inclusive (in that order) ACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTAC !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
+FAKE0002 Original version has PHRED scores from 93 to 0 inclusive (in that order) CATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCA ~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"!
diff -r 000000000000 -r bc9269529e88 test-data/sanger_full_range_as_cssanger.fastqcssanger
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/sanger_full_range_as_cssanger.fastqcssanger Mon Jan 27 09:28:21 2014 -0500
@@ -0,0 +1,8 @@
+@FAKE0001 Original version has PHRED scores from 0 to 93 inclusive (in that order)
+G2131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131
++
+!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
+@FAKE0002 Original version has PHRED scores from 93 to 0 inclusive (in that order)
+G3131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131
++
+~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"!
diff -r 000000000000 -r bc9269529e88 test-data/sanger_full_range_original_sanger.fastqsanger
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/sanger_full_range_original_sanger.fastqsanger Mon Jan 27 09:28:21 2014 -0500
@@ -0,0 +1,8 @@
+@FAKE0001 Original version has PHRED scores from 0 to 93 inclusive (in that order)
+ACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTAC
++
+!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
+@FAKE0002 Original version has PHRED scores from 93 to 0 inclusive (in that order)
+CATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCATGCA
++
+~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"!
diff -r 000000000000 -r bc9269529e88 tool_dependencies.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_dependencies.xml Mon Jan 27 09:28:21 2014 -0500
@@ -0,0 +1,6 @@
+
+
+
+
+
+