Module: Ms::Fasta::Ipi
- Defined in:
- lib/ms/fasta/ipi.rb,
lib/ms/fasta/ipi/dat.rb
Defined Under Namespace
Classes: Dat
Constant Summary collapse
- IPI_RE =
/IPI:([\w\.]+)\|/o
Class Method Summary collapse
-
.ipi(header) ⇒ Object
returns the ipi index for the header (.e.g, ipi0000093.1).
-
.parse(header) ⇒ Object
returns a hash of header information where the values are all strings (does NOT attempt to separate on ‘;’).
Class Method Details
.ipi(header) ⇒ Object
returns the ipi index for the header (.e.g, ipi0000093.1)
25 26 27 |
# File 'lib/ms/fasta/ipi.rb', line 25 def ipi(header) IPI_RE.match(header)[1] end |
.parse(header) ⇒ Object
returns a hash of header information where the values are all strings (does NOT attempt to separate on ‘;’). The gene description is held in the key ‘description’
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ms/fasta/ipi.rb', line 10 def parse(header) gap_index = header.index(' ') hash = {} header[0...gap_index].split('|').each do |str| (key, val) = str.split(':') hash[key] = val end pieces = header[gap_index..-1].split(' ') hash.store(*pieces.shift.split('=')) hash.store(*pieces.shift.split('=')) hash.store('description', pieces.join(' ')) hash end |