Method: Bio::DAS#get_sequence
- Defined in:
- lib/bio/io/das.rb
#get_sequence(dsn, segments) ⇒ Object
Returns an Array of Bio::DAS::SEQUENCE. The ‘dsn’ can be a String or a Bio::DAS::DSN object. The ‘segments’ can be a Bio::DAS::SEGMENT object or an Array of Bio::DAS::SEGMENT
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/bio/io/das.rb', line 135 def get_sequence(dsn, segments) ary = [] dsn = dsn.source if dsn.instance_of?(DSN) segments = [segments] if segments.instance_of?(SEGMENT) opts = [] segments.each do |s| opts << "segment=#{s.entry_id}:#{s.start},#{s.stop}" end result = Bio::Command.post_form("#{@server}/das/#{dsn}/sequence", opts) doc = REXML::Document.new(result.body) doc.elements.each('/descendant::SEQUENCE') do |e| sequence = SEQUENCE.new sequence.entry_id = e.attributes['id'] sequence.start = e.attributes['start'] sequence.stop = e.attributes['stop'] sequence.moltype = e.attributes['moltype'] sequence.version = e.attributes['version'] case sequence.moltype when /dna|rna/i # 'DNA', 'ssRNA', 'dsRNA' sequence.sequence = Bio::Sequence::NA.new(e.text) when /protein/i # 'Protein sequence.sequence = Bio::Sequence::AA.new(e.text) else sequence.sequence = e.text end ary << sequence end ary end |