Method: Bio::DAS#get_features
- Defined in:
- lib/bio/io/das.rb
#get_features(dsn, segments = [], categorize = false, feature_ids = [], group_ids = []) ⇒ Object
Returns a Bio::DAS::GFF object. The ‘dsn’ can be a String or a Bio::DAS::DSN object. The ‘segments’ is optional and can be a Bio::DAS::SEGMENT object or an Array of Bio::DAS::SEGMENT
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/bio/io/das.rb', line 214 def get_features(dsn, segments = [], categorize = false, feature_ids = [], group_ids = []) # arguments 'type' and 'category' are deprecated gff = GFF.new 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 if categorize opts << "categorize=yes" # default is 'no' end feature_ids.each do |fid| opts << "feature_id=#{fid}" end group_ids.each do |gid| opts << "group_id=#{gid}" end result, = Bio::Command.post_form("#{@server}/das/#{dsn}/features", opts) doc = REXML::Document.new(result.body) doc.elements.each('/descendant::GFF') do |e| gff.version = e.attributes['version'] gff.href = e.attributes['href'] e.elements.each('SEGMENT') do |e| segment = SEGMENT.new segment.entry_id = e.attributes['id'] segment.start = e.attributes['start'] segment.stop = e.attributes['stop'] segment.version = e.attributes['version'] segment.label = e.attributes['label'] e.elements.each do |e| feature = FEATURE.new feature.entry_id = e.attributes['id'] feature.label = e.attributes['label'] e.elements.each do |e| case e.name when 'TYPE' type = TYPE.new type.entry_id = e.attributes['id'] type.category = e.attributes['category'] type.reference = e.attributes['referrence'] type.label = e.text feature.types << type when 'METHOD' feature.method_id = e.attributes['id'] feature.method = e.text when 'START' feature.start = e.text when 'STOP', 'END' feature.stop = e.text when 'SCORE' feature.score = e.text when 'ORIENTATION' feature.orientation = e.text when 'PHASE' feature.phase = e.text when 'NOTE' feature.notes << e.text when 'LINK' link = LINK.new link.href = e.attributes['href'] link.text = e.text feature.links << link when 'TARGET' target = TARGET.new target.entry_id = e.attributes['id'] target.start = e.attributes['start'] target.stop = e.attributes['stop'] target.name = e.text feature.targets << target when 'GROUP' group = GROUP.new group.entry_id = e.attributes['id'] group.label = e.attributes['label'] group.type = e.attributes['type'] e.elements.each do |e| case e.name when 'NOTE' # in GROUP group.notes << e.text when 'LINK' # in GROUP link = LINK.new link.href = e.attributes['href'] link.text = e.text group.links << link when 'TARGET' # in GROUP target = TARGET.new target.entry_id = e.attributes['id'] target.start = e.attributes['start'] target.stop = e.attributes['stop'] target.name = e.text group.targets << target end end feature.groups << group end end segment.features << feature end gff.segments << segment end end gff end |