class Seq
attr_accessor :seq_name, :seq, :type, :qual
+ # Method that generates all possible oligos of a specifed length and type.
+ def self.generate_oligos(length, type)
+ raise SeqError, "Cannot generate negative oligo length: #{length}" if length <= 0
+
+ case type.downcase
+ when /dna/ then alph = DNA
+ when /rna/ then alph = RNA
+ when /protein/ then alph = PROTEIN
+ else
+ raise SeqError, "Unknown sequence type: #{type}"
+ end
+
+ oligos = [""]
+
+ (1 .. length).each do
+ list = []
+
+ oligos.each do |oligo|
+ alph.each do |char|
+ list << oligo + char
+ end
+ end
+
+ oligos = list
+ end
+
+ oligos
+ end
+
# Initialize a sequence object with the following arguments:
# - seq_name: Name of the sequence.
# - seq: The sequence.
end
end
- # Method that generates a random sequence of a given length.
+ # Method that generates a random sequence of a given length and type.
def generate(length,type)
raise SeqError, "Cannot generate negative sequence length: #{length}" if length <= 0