require 'maasha/digest'
require 'maasha/patternmatcher'
+require 'maasha/bits'
#require 'maasha/patscan'
# Residue alphabets
unless wrap.nil?
seq.gsub!(/(.{#{wrap}})/) do |match|
- match << "\n"
+ match << $/
end
seq.chomp!
end
- ">#{seq_name}\n#{seq}\n"
+ ">" + seq_name + $/ + seq + $/
+ end
+
+ # Method that given a Seq entry returns a FASTQ entry (a string).
+ def to_fastq
+ raise SeqError, "Missing seq_name" if self.seq_name.nil?
+ raise SeqError, "Missing seq" if self.seq.nil?
+ raise SeqError, "Missing qual" if self.qual.nil?
+
+ seq_name = self.seq_name
+ seq = self.seq
+ qual = self.qual
+
+ "@" + seq_name + $/ + seq + $/ + "+" + $/ + qual + $/
end
# Method that generates a unique key for a
end
end
+ # Method to determine the Hamming Distance between
+ # two Sequence objects (case insensitive).
+ def hamming_distance(seq)
+ self.seq.upcase.hamming_distance(seq.seq.upcase)
+ end
+
# Method that generates a random sequence of a given length and type.
def generate(length, type)
raise SeqError, "Cannot generate sequence length < 1: #{length}" if length <= 0
def convert_phred2illumina!
self.qual.gsub!(/./) do |score|
score_phred = score.ord - SCORE_PHRED
- raise SeqError, "Bad Phred score: #{score} (#{score_phred})" unless (0 .. 40).include? score_phred
+ raise SeqError, "Bad Phred score: #{score} (#{score_phred})" unless (0 .. 41).include? score_phred
score_illumina = score_phred + SCORE_ILLUMINA
score = score_illumina.chr
end