Method: Bio::Alignment::OriginalAlignment#store
- Defined in:
- lib/bio/alignment.rb
#store(key, seq) ⇒ Object
stores a sequence with key (name or definition of the sequence). Unlike __store__
method, the method doesn’t allow same keys. If the key is already used, returns nil. When succeeded, returns key.
1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 |
# File 'lib/bio/alignment.rb', line 1628 def store(key, seq) #(Hash-like) returns key instead of seq if @seqs.has_key?(key) then # don't allow same key # New key is discarded, while existing key is preserved. key = nil end unless key then unless defined?(@serial) @serial = 0 end @serial = @seqs.size if @seqs.size > @serial while @seqs.has_key?(@serial) @serial += 1 end key = @serial end self.__store__(key, seq) key end |