]> git.donarmstrong.com Git - biopieces.git/commitdiff
added prefix option to write_fasta_files and write_fastq_files
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 26 Sep 2013 08:09:07 +0000 (08:09 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 26 Sep 2013 08:09:07 +0000 (08:09 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@2218 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/write_fasta_files
bp_bin/write_fastq_files
bp_test/out/write_fasta_files.out.4/Length_test1.fasta [new file with mode: 0644]
bp_test/out/write_fasta_files.out.4/Length_test2.fasta [new file with mode: 0644]
bp_test/out/write_fasta_files.out.4/Length_test3.fasta [new file with mode: 0644]
bp_test/out/write_fastq_files.out.3/Name_test.fastq [new file with mode: 0644]
bp_test/out/write_fastq_files.out.3/Name_test2.fastq [new file with mode: 0644]
bp_test/test/test_write_fasta_files
bp_test/test/test_write_fastq_files

index a0e20a50545643b2183ee2fdf229ba08ab2d68df..dfeabb20a5555517af240461eb574cb79ed2f125 100755 (executable)
@@ -35,6 +35,7 @@ require 'pp'
 casts = []
 casts << {long: 'key',       short: 'k', type: 'string', mandatory: true,  default: nil, allowed: nil,               disallowed: nil}
 casts << {long: 'dir',       short: 'd', type: 'dir!',   mandatory: true,  default: nil, allowed: nil,               disallowed: nil}
+casts << {long: 'prefix',    short: 'p', type: 'string', mandatory: false, default: nil, allowed: nil,               disallowed: nil}
 casts << {long: 'wrap',      short: 'w', type: 'uint',   mandatory: false, default: nil, allowed: nil,               disallowed: "0"}
 casts << {long: 'compress',  short: 'Z', type: 'string', mandatory: false, default: nil, allowed: "gzip,bzip,bzip2", disallowed: nil}
 casts << {long: 'no_stream', short: 'x', type: 'flag',   mandatory: false, default: nil, allowed: nil,               disallowed: nil}
@@ -53,7 +54,12 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
       if fh_hash[record[key].to_sym]
         fasta_io = fh_hash[record[key].to_sym]
       else
-        fasta_file = File.join(options[:dir], record[key] + ".fasta")
+        if options[:prefix]
+          fasta_file = File.join(options[:dir], [options[:prefix], record[key]].join("_") + ".fasta")
+        else
+          fasta_file = File.join(options[:dir], record[key] + ".fasta")
+        end
+
         fasta_file << ".gz"  if compress == :gzip
         fasta_file << ".bz2" if compress == :bzip or compress == :bzip2
         fasta_io   = Fasta.open(fasta_file, "w", compress: compress)
index 5e36a38eb44134c1d024c5d1467e0cb212aaf91a..b475b121eeec6cead74d03a9c767023d640870ef 100755 (executable)
@@ -37,6 +37,7 @@ allowed_enc = 'base_33,base_64'
 casts = []
 casts << {long: 'key',       short: 'k', type: 'string', mandatory: true,  default: nil,       allowed: nil,               disallowed: nil}
 casts << {long: 'dir',       short: 'd', type: 'dir!',   mandatory: true,  default: nil,       allowed: nil,               disallowed: nil}
+casts << {long: 'prefix',    short: 'p', type: 'string', mandatory: false, default: nil,       allowed: nil,               disallowed: nil}
 casts << {long: 'no_stream', short: 'x', type: 'flag',   mandatory: false, default: nil,       allowed: nil,               disallowed: nil}
 casts << {long: 'compress',  short: 'Z', type: 'string', mandatory: false, default: nil,       allowed: "gzip,bzip,bzip2", disallowed: nil}
 casts << {long: 'encoding',  short: 'e', type: 'string', mandatory: false, default: 'base_33', allowed: allowed_enc,       disallowed: nil}
@@ -59,7 +60,12 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
       if fh_hash[record[key].to_sym]
         fastq_io = fh_hash[record[key].to_sym]
       else
-        fastq_file = File.join(options[:dir], record[key] + ".fastq")
+        if options[:prefix]
+          fastq_file = File.join(options[:dir], [options[:prefix], record[key]].join("_") + ".fastq")
+        else
+          fastq_file = File.join(options[:dir], record[key] + ".fastq")
+        end
+
         fastq_file << ".gz"  if compress == :gzip
         fastq_file << ".bz2" if compress == :bzip or compress == :bzip2
         fastq_io   = Fastq.open(fastq_file, "w", compress: compress)
diff --git a/bp_test/out/write_fasta_files.out.4/Length_test1.fasta b/bp_test/out/write_fasta_files.out.4/Length_test1.fasta
new file mode 100644 (file)
index 0000000..cb5bc10
--- /dev/null
@@ -0,0 +1,2 @@
+>test1
+GACATCGAC
diff --git a/bp_test/out/write_fasta_files.out.4/Length_test2.fasta b/bp_test/out/write_fasta_files.out.4/Length_test2.fasta
new file mode 100644 (file)
index 0000000..10f6659
--- /dev/null
@@ -0,0 +1,2 @@
+>test2
+ACGACTACAGT
diff --git a/bp_test/out/write_fasta_files.out.4/Length_test3.fasta b/bp_test/out/write_fasta_files.out.4/Length_test3.fasta
new file mode 100644 (file)
index 0000000..aa9e884
--- /dev/null
@@ -0,0 +1,2 @@
+>test3
+GCACACAGAGC
diff --git a/bp_test/out/write_fastq_files.out.3/Name_test.fastq b/bp_test/out/write_fastq_files.out.3/Name_test.fastq
new file mode 100644 (file)
index 0000000..56cbf76
--- /dev/null
@@ -0,0 +1,4 @@
+@test
+TAGGGAATCTTGCACAATGGAGGAAACTCTGATGCAGCGA
++
+<???9?BBBDBDDBDDFFFFFFHHHIFHFHHIHHFHHHHE
diff --git a/bp_test/out/write_fastq_files.out.3/Name_test2.fastq b/bp_test/out/write_fastq_files.out.3/Name_test2.fastq
new file mode 100644 (file)
index 0000000..b13400f
--- /dev/null
@@ -0,0 +1,8 @@
+@test2
+TAGGGAATCTTGCACAATGGGGGAAACCCTGATGCAGCGA
++
+5<???B-<-?<BBBBBFFF;>CEEECC;EFFH=EGBE=CE
+@test2
+TGGGGAATTTTGCGCAATGGGCGAAAGCCTGACGCAGCAA
++
+55?????B?BB<-5@BC9CFFB>+C>C>E?@B=>,>5>FE
index 9332864ba2ec84ac3e61baa39c96c6f430085ae7..d7775c39901a1cccb0441ec59ad920d153812b6e 100755 (executable)
@@ -33,3 +33,9 @@ run "$bp -I $in -d $tmp_dir -k SEQ_LEN -w 4 -x"
 assert_no_diff_dir $tmp_dir $out.3
 clean
 rm -rf $tmp_dir
+
+mkdir $tmp_dir
+run "$bp -I $in -d $tmp_dir -k SEQ_NAME -p Length -x"
+assert_no_diff_dir $tmp_dir $out.4
+clean
+rm -rf $tmp_dir
index 7babe73dccbeda5bb338317055595ab927f637bd..8a0f386a2de766fdc9014aa4f5793dbe576632bf 100755 (executable)
@@ -33,3 +33,9 @@ bunzip2 $tmp_dir/*.bz2
 assert_no_diff_dir $tmp_dir $out.2
 clean
 rm -rf $tmp_dir
+
+mkdir $tmp_dir
+run "$bp -I $in -d $tmp_dir -k SEQ_NAME -p Name -x"
+assert_no_diff_dir $tmp_dir $out.3
+clean
+rm -rf $tmp_dir