class Bio::Sequence::Format::NucFormatter::Embl
INTERNAL USE ONLY, YOU SHOULD NOT USE THIS CLASS. Embl
format output class for Bio::Sequence
.
Private Instance Methods
comments_format_embl(cmnts)
click to toggle source
CC line. Comments.
# File lib/bio/db/embl/format_embl.rb 138 def comments_format_embl(cmnts) 139 return '' if !cmnts or cmnts.empty? 140 cmnts = [ cmnts ] unless cmnts.kind_of?(Array) 141 a = [] 142 cmnts.each do |str| 143 a.push embl_wrap('CC ', str) 144 end 145 unless a.empty? then 146 a.push "XX " 147 a.push '' # dummy to put "\n" at the end of the string 148 end 149 a.join("\n") 150 end
embl_wrap(prefix, str)
click to toggle source
wrapping with EMBL
style
# File lib/bio/db/embl/format_embl.rb 22 def embl_wrap(prefix, str) 23 wrap(str.to_s, 80, prefix) 24 end
embl_wrap_words(prefix, array)
click to toggle source
Given words (an Array of String) are wrapping with EMBL
style. Each word is never splitted inside the word.
# File lib/bio/db/embl/format_embl.rb 28 def embl_wrap_words(prefix, array) 29 width = 80 30 result = [] 31 str = nil 32 array.each do |x| 33 if str then 34 if str.length + 1 + x.length > width then 35 str = nil 36 else 37 str.concat ' ' 38 str.concat x 39 end 40 end 41 unless str then 42 str = prefix + x 43 result.push str 44 end 45 end 46 result.join("\n") 47 end
mol_type_embl()
click to toggle source
moleculue type
# File lib/bio/db/embl/format_embl.rb 126 def mol_type_embl 127 if mt = molecule_type then 128 mt 129 elsif fe = (features or []).find { |f| f.feature == 'source' } and 130 qu = fe.qualifiers.find { |q| q.qualifier == 'mol_type' } then 131 qu.value 132 else 133 'NA' 134 end 135 end
reference_format_embl(ref, hash = nil)
click to toggle source
format reference
- ref
-
Bio::Reference
object - hash
-
(optional) a hash for RN (reference number) administration
# File lib/bio/db/embl/format_embl.rb 52 def reference_format_embl(ref, hash = nil) 53 lines = Array.new 54 if ref.embl_gb_record_number or hash then 55 refno = ref.embl_gb_record_number.to_i 56 hash ||= {} 57 if refno <= 0 or hash[refno] then 58 refno = hash.keys.sort[-1].to_i + 1 59 hash[refno] = true 60 end 61 lines << embl_wrap("RN ", "[#{refno}]") 62 end 63 if ref.comments then 64 ref.comments.each do |cmnt| 65 lines << embl_wrap("RC ", cmnt) 66 end 67 end 68 unless ref.sequence_position.to_s.empty? then 69 lines << embl_wrap("RP ", "#{ref.sequence_position}") 70 end 71 unless ref.doi.to_s.empty? then 72 lines << embl_wrap("RX ", "DOI; #{ref.doi}.") 73 end 74 unless ref.pubmed.to_s.empty? then 75 lines << embl_wrap("RX ", "PUBMED; #{ref.pubmed}.") 76 end 77 unless ref.authors.empty? then 78 auth = ref.authors.collect do |x| 79 y = x.to_s.strip.split(/\, *([^\,]+)\z/) 80 y[1].gsub!(/\. +/, '.') if y[1] 81 y.join(' ') 82 end 83 lastauth = auth.pop 84 auth.each { |x| x.concat ',' } 85 auth.push(lastauth.to_s + ';') 86 lines << embl_wrap_words('RA ', auth) 87 end 88 lines << embl_wrap('RT ', 89 (ref.title.to_s.empty? ? '' : 90 "\"#{ref.title}\"") + ';') 91 unless ref.journal.to_s.empty? then 92 volissue = "#{ref.volume.to_s}" 93 volissue = "#{volissue}(#{ref.issue})" unless ref.issue.to_s.empty? 94 rl = "#{ref.journal}" 95 rl += " #{volissue}" unless volissue.empty? 96 rl += ":#{ref.pages}" unless ref.pages.to_s.empty? 97 rl += "(#{ref.year})" unless ref.year.to_s.empty? 98 rl += '.' 99 lines << embl_wrap('RL ', rl) 100 end 101 lines << "XX" 102 return lines.join("\n") 103 end
seq_composition(seq)
click to toggle source
# File lib/bio/db/embl/format_embl.rb 116 def seq_composition(seq) 117 { :a => seq.count('aA'), 118 :c => seq.count('cC'), 119 :g => seq.count('gG'), 120 :t => seq.count('tTuU'), 121 :other => seq.count('^aAcCgGtTuU') 122 } 123 end
seq_format_embl(seq)
click to toggle source
# File lib/bio/db/embl/format_embl.rb 105 def seq_format_embl(seq) 106 counter = 0 107 result = seq.gsub(/.{1,60}/) do |x| 108 counter += x.length 109 x = x.gsub(/.{10}/, '\0 ') 110 sprintf(" %-66s%9d\n", x, counter) 111 end 112 result.chomp! 113 result 114 end