- # Method that returns a subsequence of from a given start position
- # and of a given length.
- def subseq(start, length = self.length - start)
- raise SeqError, "subsequence start: #{start} < 0" if start < 0
- raise SeqError, "subsequence length: #{length} < 0" if length < 0
- raise SeqError, "subsequence start + length > Seq.length: #{start} + #{length} > #{self.length}" if start + length > self.length
-
- if length == 0
- seq = ""
- qual = "" unless self.qual.nil?
- else
- stop = start + length - 1
-
- seq = self.seq[start .. stop]
- qual = self.qual[start .. stop] unless self.qual.nil?
- end
+ # Index method for Seq objects.
+ def [](*args)
+ entry = Seq.new
+ entry.seq_name = self.seq_name.dup if self.seq_name
+ entry.seq = self.seq[*args]
+ entry.type = self.type
+ entry.qual = self.qual[*args] unless self.qual.nil?