]> git.donarmstrong.com Git - biopieces.git/commitdiff
refactoring of ruby code s/has_key?/[]/
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 28 Feb 2013 14:17:03 +0000 (14:17 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 28 Feb 2013 14:17:03 +0000 (14:17 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@2108 74ccb610-7750-0410-82ae-013aeee3265d

36 files changed:
bp_bin/analyze_assembly
bp_bin/analyze_seq
bp_bin/bin_vals
bp_bin/blast_seq_pair
bp_bin/bwa_seq
bp_bin/calc_N50
bp_bin/cat_seq
bp_bin/clip_seq
bp_bin/denoise_seq
bp_bin/digest_seq
bp_bin/duplicate_record
bp_bin/find_barcodes
bp_bin/find_homopolymers
bp_bin/join_seq
bp_bin/length_seq
bp_bin/mask_seq
bp_bin/patscan_seq
bp_bin/pcr_seq
bp_bin/plot_distribution
bp_bin/progress_meter
bp_bin/read_embl
bp_bin/read_fasta
bp_bin/read_genbank
bp_bin/read_sff
bp_bin/remove_indel_columns
bp_bin/remove_primers
bp_bin/replace_vals
bp_bin/scores_to_dec
bp_bin/shred_seq
bp_bin/swapcase_seq
bp_bin/trim_seq
bp_bin/uclust_seq
bp_bin/usearch_seq
bp_bin/write_fasta_files
bp_bin/write_fastq
bp_bin/write_fastq_files

index 3b9748db523c20c412ea21e52edd9c206402b25b..a9a6d12960fa9d743f784451a7a61d3749be4406 100755 (executable)
@@ -53,7 +53,7 @@ outfile = File.join(tmpdir, "out.prodigal")
 Fasta.open(infile, mode="w") do |fasta_output|
   Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
     input.each_record do |record|
-      if record.has_key? :SEQ
+      if record[:SEQ]
         seq = Seq.new_bp(record)
 
         total   += record[:SEQ].length
index f54b9054ea8d96862d77298fdd11b5770c3755b8..c2b96a5070b252bbe89f9e2e1c1fbd63055432a0 100755 (executable)
@@ -38,7 +38,7 @@ options = Biopieces.options_parse(ARGV, casts)
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_record do |record|
-    if record.has_key? :SEQ
+    if record[:SEQ]
       seq  = Seq.new(record[:SEQ_NAME], record[:SEQ], record[:SEQ_TYPE], record[:SCORE])
       comp = seq.composition
 
index e5e73c7b4c1e5ecef4831543886b0c95825c1e5f..a0bad392a8c6f6bb58499e3d9f5b11ebabc7db17 100755 (executable)
@@ -39,7 +39,7 @@ options = Biopieces.options_parse(ARGV, casts)
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_record do |record|
-    if record.has_key? options[:key].to_sym
+    if record[options[:key].to_sym]
       record[(options[:key] + "_BIN").to_sym] = (record[options[:key].to_sym].to_i / options[:bin_size]) * options[:bin_size]
     end
 
index d0488c2571a492fcf4f6e3729c3a465f069e9fcb..1963eafc4b128d94579d6d02e86cddf14964962c 100755 (executable)
@@ -164,7 +164,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_record do |record|
     output.puts record
 
-    if record.has_key? :SEQ_NAME and record.has_key? :SEQ
+    if record[:SEQ_NAME] and record[:SEQ]
       seq = Seq.new_bp(record)
 
       unless got1
index 4fd89a253427fa7ab8f24c52785317cbf1fc1de3..fd807821dac3dfe3728a8b34dae9f7ee1ec25fc3 100755 (executable)
@@ -102,7 +102,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
     input.each_record do |record|
       output.puts record
 
-      if record.has_key? :SEQ_NAME and record.has_key? :SEQ and record.has_key? :SCORES
+      if record[:SEQ_NAME] and record[:SEQ] and record[:SCORES]
         entry = Seq.new_bp(record)
 
         io_fq.puts entry.to_fastq
index 3e56af9a35c184143676034c560d5f4c957801dc..13c8240e29274b9adef5e6860187154646c3914f 100755 (executable)
@@ -44,7 +44,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_record do |record|
     output.puts record unless options[:no_stream]
 
-    if record.has_key? :SEQ
+    if record[:SEQ]
       total   += record[:SEQ].length
       lengths << record[:SEQ].length
     end
index 88e9d24fa7e566c1edb01d4844731cf6ebca1699..67cf39753c6dde527a40f1cb86621d374c824b97 100755 (executable)
@@ -41,7 +41,7 @@ seq = ""
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_record do |record|
-    seq << record[:SEQ] if record.has_key? :SEQ
+    seq << record[:SEQ] if record[:SEQ]
     output.puts record unless options[:no_stream]
   end
 
index 45a96c74cd094f1141b9c40443af27ea9a7e106a..44d1e508e1b007a0a8ae50b4ba67f37bc88bb20c 100755 (executable)
@@ -37,7 +37,7 @@ options = Biopieces.options_parse(ARGV, casts)
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_record do |record|
-    if record.has_key? :SEQ
+    if record[:SEQ]
       trim_beg = 0
       trim_end = record[:SEQ].length
 
@@ -53,7 +53,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
 
       record[:SEQ]     = record[:SEQ][trim_beg ... trim_end]
       record[:SEQ_LEN] = record[:SEQ].length
-      record[:SCORES]  = record[:SCORES][trim_beg ... trim_end] if record.has_key? :SCORES
+      record[:SCORES]  = record[:SCORES][trim_beg ... trim_end] if record[:SCORES]
     end
 
     output.puts record
index 0129c47f2fb0b081ac888d6583359289feb3da63..baa62ad7eb6102e724f7ad7b02d842ceb9d2d2d3 100755 (executable)
@@ -72,7 +72,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   Fasta.open(fasta_file, "w") do |fasta_io|
     Fastq.open(fastq_file, "w") do |fastq_io|
       input.each_record do |record|
-        if record.has_key? :SEQ and record.has_key? :SCORES
+        if record[:SEQ] and record[:SCORES]
           entry = Seq.new_bp(record)
           entry.seq_name = seq_count.to_s
 
index b4451342da493e456e0f25e9521fa7371a7f8fdd..2aa9ff9837fded6ad832d44fffacf99b08f96742 100755 (executable)
@@ -39,7 +39,7 @@ options = Biopieces.options_parse(ARGV, casts)
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_record do |record|
-    if record.has_key? :SEQ_NAME and record.has_key? :SEQ
+    if record[:SEQ_NAME] and record[:SEQ]
       seq = Seq.new_bp(record)
 
       seq.each_digest(options[:pattern].to_s, options[:cut_pos]) do |digest|
index af3d112f92c99b6ceb15fdd6c43582e83a2f0f59..9caa8646e1d51d29809fd8f2fe7b95b5dad5b4b2 100755 (executable)
@@ -39,7 +39,7 @@ key     = options[:key].to_sym
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_record do |record|
-    if record.has_key? key
+    if record[key]
       (0 ... record[key].to_i).each { output.puts record }
     else
       output.puts record
index b994c0d71815b6b53107ed8baecad605e5548d47..3cad732c0b83bc5a21ca268c47f8680b0133047a 100755 (executable)
@@ -287,7 +287,7 @@ class BarCodeFinder
       hamming_dist = 0
       barcode      = seq[@pos ... @pos + size].upcase.to_sym
 
-      if @barcode_hash.has_key? barcode
+      if @barcode_hash[barcode]
         return BarCode.new(barcode, @barcode_hash[barcode], @pos, size, hamming_dist)
       elsif @max_mismatches > 0
         @barcode_hash.each_key do |key|
@@ -352,7 +352,7 @@ bc_finder.load_barcodes(RLMID_HASH)             if options[:rlmids]
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_record do |record|
-    if record.has_key? :SEQ
+    if record[:SEQ]
       if barcode = bc_finder.find_barcode(record[:SEQ])
         record.merge!(barcode.to_hash)
 
index 3cad86f505fd60a28a251dbe7967561347ed4098..89b8e8c1d03c3360fe1463855c437b31ee9318c8 100755 (executable)
@@ -39,7 +39,7 @@ options = Biopieces.options_parse(ARGV, casts)
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_record do |record|
-    if record.has_key? :SEQ
+    if record[:SEQ]
       seq = Seq.new(nil, record[:SEQ])
 
       record[:HOMOPOL_MAX] = seq.homopol_max(options[:min])
index ce36e5944a665753c2e43aae8b660a0935dcd81e..b2749e984aea9d94e533cf444dde24290681ff94 100755 (executable)
@@ -42,7 +42,7 @@ seq = Seq.new(nil, "")
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_record do |record|
-    if record.has_key? :SEQ
+    if record[:SEQ]
       unless seq.seq_name 
         seq.seq_name = record[:SEQ_NAME]
       end
index e9f87269e0a5d944e31a7e3296bfd02af36ef896..04384db3660c7762ccb1b99f9500d8a2e4bd3dc5 100755 (executable)
@@ -37,7 +37,7 @@ options = Biopieces.options_parse(ARGV, casts)
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_record do |record|
-    record[:SEQ_LEN] = record[:SEQ].length if record.has_key? :SEQ
+    record[:SEQ_LEN] = record[:SEQ].length if record[:SEQ]
     output.puts record
   end
 end
index 3cd162a264aae007105932017a4a59636e19ddfb..d9dd01a71e1e5b1019bf1dcf24634aefc51bb430 100755 (executable)
@@ -39,7 +39,7 @@ options = Biopieces.options_parse(ARGV, casts)
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_record do |record|
-    if record.has_key? :SEQ
+    if record[:SEQ]
       entry = Seq.new_bp(record)
 
       options[:hardmask] ? entry.mask_seq_hard!(options[:cutoff]) : entry.mask_seq_soft!(options[:cutoff])
index 1b533a9ebee71f22ed6b769371bcc7b607d4bcfa..c8ff36237213c67a483a5663f00e345a33238efb 100755 (executable)
@@ -141,7 +141,7 @@ seq_type       = nil
 Biopieces.open(options[:stream_in], tmp_file) do |input, output|
   Fasta.open(in_file, mode="w") do |fasta_io|
     input.each_record do |record|
-      if record.has_key? :SEQ_NAME
+      if record[:SEQ_NAME]
         seq_name_hash[seq_name_count] = record[:SEQ_NAME]
         record[:SEQ_NAME] = seq_name_count
         seq_name_count += 1
@@ -166,12 +166,12 @@ results = patscan.results_parse
 
 Biopieces.open(tmp_file, options[:stream_out]) do |input, output|
   input.each_record do |record|
-    if record.has_key? :SEQ_NAME
+    if record[:SEQ_NAME]
       key = record[:SEQ_NAME].to_i
       record[:SEQ_NAME] = seq_name_hash[key]
 
       if options[:inline]
-        if results.has_key? key
+        if results[key]
           results[key].each do |result|
             record[:PATTERN]   = options[:pattern]
             record[:MATCH]     = result.match
index 57eb447b3684d51f7346bb6a111c2c386937b776..f6c874e7e9555e021c83f5213f6277e2f8f591ff 100755 (executable)
@@ -177,7 +177,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
     input.each_record do |record|
       output.puts record
 
-      if record.has_key? :SEQ
+      if record[:SEQ]
         entry = Seq.new_bp(record)
         ios.puts entry.to_fasta
       end
index 02f802ee611ea1146c88a7de878705358f982f10..175ca595377d4e3824d2c51620af5654e2114fd3 100755 (executable)
@@ -54,7 +54,7 @@ count_hash = Hash.new(0)
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_record do |record|
-    if record.has_key? key
+    if record[key]
       count_hash[record[key].to_i] += 1
     end
 
index 49003a2d7cdb34b3223d717ecb16f2af5d09e194..43cdd771d0b8e38d1d5733e83404082fde78d310 100755 (executable)
@@ -39,7 +39,7 @@ options = Biopieces.options_parse(ARGV, casts)
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_with_index do |record, count|
-    output.puts record unless options.has_key? :no_stream
+    output.puts record unless options[:no_stream]
     $stderr.printf "\n% 9d ", count if (count % (options[:count] * 100)) == 0
     $stderr.print "." if (count % options[:count]) == 0
   end
index 91f6728070a3acb1d4a027144edd9ce497d3c12f..0a3558cd2e19bece6b8da8a1c00d5bbd3f91e147 100755 (executable)
@@ -52,7 +52,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   num  = 0
   last = false
 
-  if options.has_key? :data_in
+  if options[:data_in]
     options[:data_in].each do |file|
       EMBL.open(file, mode='r') do |embl_io|
         embl_io.each(hash_keys, hash_feats, hash_quals) do |entry|
@@ -60,7 +60,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
 
           num += 1
 
-          if options.has_key? :num and options[:num] == num
+          if options[:num] and options[:num] == num
             last = true
             break
           end
index 0508ceb712f828209966196a85d929244f9e110e..8bc5874f55dc0a6399e78c6a29167af9fdb773c1 100755 (executable)
@@ -47,14 +47,14 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   num  = 0
   last = false
 
-  if options.has_key? :data_in
+  if options[:data_in]
     options[:data_in].each do |file|
       Fasta.open(file, mode='r') do |fasta|
         fasta.each do |entry|
           output.puts entry.to_bp
           num += 1
 
-          if options.has_key? :num and options[:num] == num
+          if options[:num] and options[:num] == num
             last = true
             break
           end
index d40f1aafec1d6659b9f0847668185ab23de12702..7cabf2bf0adcbd1071cd6438b6fc86f211061445 100755 (executable)
@@ -53,7 +53,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   num  = 0
   last = false
 
-  if options.has_key? :data_in
+  if options[:data_in]
     options[:data_in].each do |file|
       Genbank.open(file, mode='r') do |gb|
         gb.each(hash_keys, hash_feats, hash_quals) do |entry|
@@ -61,7 +61,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
 
           num += 1
 
-          if options.has_key? :num and options[:num] == num
+          if options[:num] and options[:num] == num
             last = true
             break
           end
index 3de8b2ea1afea9e5a7e9213eac4913e8b7a01f01..cd9d58a88ab872630b5055ca5910c9ce7a2c5c32 100755 (executable)
@@ -47,7 +47,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   num  = 0
   last = false
 
-  if options.has_key? :data_in
+  if options[:data_in]
     options[:data_in].each do |file|
       SFF.open(file, mode='r') do |sff|
         sff.each do |entry|
@@ -56,7 +56,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
           output.puts entry.to_bp
           num += 1
 
-          if options.has_key? :num and options[:num] == num
+          if options[:num] and options[:num] == num
             last = true
             break
           end
index 5de6c0bf062c947a400fcbc1d057fb50a8223286..193c7862dac4aeec77896ba2abe7b8108753c4be 100755 (executable)
@@ -40,7 +40,7 @@ count        = 0
 
 Biopieces.open(options[:stream_in], file_records) do |input, output|
   input.each do |record|
-    if record.has_key? :SEQ
+    if record[:SEQ]
       na_mask = NArray.int(record[:SEQ].length) unless na_mask
       na_seq  = NArray.to_na(record[:SEQ], "byte")
       na_mask += na_seq.eq('-'.ord) 
@@ -61,7 +61,7 @@ sum = na_mask.sum
 
 Biopieces.open(file_records, options[:stream_out]) do |input, output|
   input.each do |record|
-    if sum > 0 and record.has_key? :SEQ
+    if sum > 0 and record[:SEQ]
       na_seq           = NArray.to_na(record[:SEQ], "byte")
       record[:SEQ]     = na_seq[na_mask].to_s
       record[:SEQ_LEN] = record[:SEQ].length
index eef824840b9eeed5f28c2b9ba961a2e4b5fcdc2b..1f7b7b216ab3fc9f089848b9303771d62d36a77f 100755 (executable)
@@ -47,7 +47,7 @@ options = Biopieces.options_parse(ARGV, casts)
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each do |record|
-    if record.has_key? :SEQ
+    if record[:SEQ]
       forward = false
       reverse = false
       seq = Seq.new_bp(record)
index a8105598c0533d92a75438dc8c4227ced087353f..860b913156962b29c581141442e244ca9982b05d 100755 (executable)
@@ -60,7 +60,7 @@ if options[:file]
         k      = fields[options[:search_col] - 1]
         v      = fields[options[:replace_col] - 1]
 
-        raise RuntimeError, "duplicate key: #{k} found in file" if replace_hash.has_key? k
+        raise RuntimeError, "duplicate key: #{k} found in file" if replace_hash[k]
 
         replace_hash[k] = v
       end
@@ -70,8 +70,8 @@ end
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_record do |record|
-    if record.has_key? key
-      if replace_hash.has_key? record[key]
+    if record[key]
+      if replace_hash[record[key]]
         record[key] = replace_hash[record[key]]
       end
     end
index 2d91c2bda001f24767f1208d5930291fe24d014b..b93587f3db97f5af3557e853b2472aaa549063d8 100755 (executable)
@@ -36,7 +36,7 @@ class Hash
   # Method to convert scores from ASCII encode string to
   # a semi-colon seperated string of decimal values.
   def scores2dec!
-    if self.has_key? :SCORES
+    if self[:SCORES]
       self[:SCORES].gsub! /./ do |score|
         score = (score.ord - Seq::SCORE_BASE).to_s + ";"
       end
index 465f08855bec36eb769bf319e34b5c5ff25d0d61..ffd79cb9252bef5dbf2f95258779c1960ef41cf7 100755 (executable)
@@ -83,7 +83,7 @@ options = Biopieces.options_parse(ARGV, casts)
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_record do |record|
-    if record.has_key? :SEQ and record[:SEQ].length >= options[:size]
+    if record[:SEQ] and record[:SEQ].length >= options[:size]
       entry      = Seq.new(record[:SEQ_NAME], record[:SEQ], record[:SCORES])
       entry.type = 'dna'
 
index bc1cdeda30a8f89558cafc86406ed02ba9af393c..b1fafa2ccd74cafe9783c3c9008b141426331296 100755 (executable)
@@ -35,7 +35,7 @@ options = Biopieces.options_parse(ARGV)
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_record do |record|
-    record[:SEQ].swapcase! if record.has_key? :SEQ
+    record[:SEQ].swapcase! if record[:SEQ]
     output.puts record
   end
 end
index d6c1a0933dfe8a1dce77403c81414184d2f382bf..7afec9c7051bc763cd7b6dc211baf74517624564 100755 (executable)
@@ -41,7 +41,7 @@ options = Biopieces.options_parse(ARGV, casts)
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_record do |record|
-    if record.has_key? :SEQ and record.has_key? :SCORES
+    if record[:SEQ] and record[:SCORES]
       entry = Seq.new_bp(record)
 
       case options[:trim]
index 695d3cfdb984ff30b5917a56d429a2f6c92c11c5..936d642909eb06c2da7075913c81c54bd44ab5bd 100755 (executable)
@@ -49,7 +49,7 @@ Biopieces.open(options[:stream_in], file_records) do |input, output|
     input.each_record do |record|
       output.puts record
 
-      if record.has_key? :SEQ_NAME and record.has_key? :SEQ
+      if record[:SEQ_NAME] and record[:SEQ]
         fasta_io.puts Seq.new_bp(record).to_fasta
       end
     end
@@ -68,8 +68,8 @@ end
 
 Biopieces.open(file_records, options[:stream_out]) do |input, output|
   input.each_record do |record|
-    if record.has_key? :SEQ_NAME and record.has_key? :SEQ
-      if hash.has_key? record[:SEQ_NAME].to_sym
+    if record[:SEQ_NAME] and record[:SEQ]
+      if hash[record[:SEQ_NAME].to_sym]
         us = hash[record[:SEQ_NAME].to_sym]
         record[:CLUSTER] = us[:CLUSTER].to_i
         record[:IDENT]   = us[:IDENT].to_i
index 20752854a1e2ef281bc3d2c0e7559a72313cedee..c390708a46fc8535a43b1b7f2b76d538334a01b8 100755 (executable)
@@ -50,7 +50,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
     input.each_record do |record|
       output.puts record
 
-      if record.has_key? :SEQ_NAME and record.has_key? :SEQ
+      if record[:SEQ_NAME] and record[:SEQ]
         fasta_io.puts Seq.new_bp(record).to_fasta
       end
     end
index debea31cb5c073f3ed6cbbacdb22a3096c7cd201..36011ed411fad74d891f2f12f7108bfc02eb91a2 100755 (executable)
@@ -48,7 +48,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
     if record[:SEQ_NAME] and record[:SEQ] and record[key]
       seq = Seq.new_bp(record)
 
-      if fh_hash.has_key? record[key].to_sym
+      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")
index f6050f38555071932cab4ad91eaba821c8d84a83..796e187708e52affcf8747e95149a97e986d62f7 100755 (executable)
@@ -62,7 +62,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
       io_out.puts entry.to_fastq
     end
 
-    output.puts record unless options.has_key? :no_stream
+    output.puts record unless options[:no_stream]
   end
 
   io_out.close
index eab5a870aedb7a5622efc4e68b8200e79ddf5cf9..a116040b78b5a497b3c0165db8b920bd21d74b28 100755 (executable)
@@ -48,7 +48,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
     if record[:SEQ_NAME] and record[:SEQ] and record[:SCORES] and record[key]
       seq = Seq.new_bp(record)
 
-      if fh_hash.has_key? record[key].to_sym
+      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")