From ad496507a37910273c672e4a4155545bf00d58dd Mon Sep 17 00:00:00 2001 From: martinahansen Date: Wed, 5 Dec 2012 10:20:05 +0000 Subject: [PATCH] renamed patternmatcher to dynamic git-svn-id: http://biopieces.googlecode.com/svn/trunk@2031 74ccb610-7750-0410-82ae-013aeee3265d --- code_ruby/lib/maasha/seq/backtrack.rb | 28 ++++++++++++++----- .../seq/{patternmatcher.rb => dynamic.rb} | 0 2 files changed, 21 insertions(+), 7 deletions(-) rename code_ruby/lib/maasha/seq/{patternmatcher.rb => dynamic.rb} (100%) diff --git a/code_ruby/lib/maasha/seq/backtrack.rb b/code_ruby/lib/maasha/seq/backtrack.rb index 1d09c30..ab2c00f 100644 --- a/code_ruby/lib/maasha/seq/backtrack.rb +++ b/code_ruby/lib/maasha/seq/backtrack.rb @@ -40,6 +40,20 @@ module BackTrack MAX_INS = 5 # Maximum number of insertions allowed MAX_DEL = 5 # Maximum number of deletions allowed + # ------------------------------------------------------------------------------ + # str.patmatch(pattern[, start|[start, stop][, max_mis[, max_ins[, max_del]]]]) + # -> Match + # str.patmatch(pattern[, start|[start, stop][, max_mis[, max_ins[, max_del]]]]) { |match| + # block + # } + # -> Match + # + # ------------------------------------------------------------------------------ + # Method to iterate through a sequence from a given start position to the end of + # the sequence or to a given stop position to locate a pattern allowing for a + # maximum number of mismatches, insertions, and deletions. Insertions are + # nucleotides found in the pattern but not in the sequence. Deletions are + # nucleotides found in the sequence but not in the pattern. def patmatch(pattern, start = 0, max_mismatches = 0, max_insertions = 0, max_deletions = 0) self.patscan(pattern, start, max_mismatches, max_insertions, max_deletions) do |m| if block_given? @@ -59,9 +73,9 @@ module BackTrack end # ------------------------------------------------------------------------------ - # str.scan(pattern[, start|[start, stop][, max_mismatches[, max_insertions[, max_deletions]]]]) + # str.patscan(pattern[, start|[start, stop][, max_mis[, max_ins[, max_del]]]]) # -> Array - # str.scan(pattern[, start|[start, stop][, max_mismatches[, max_insertions[, max_deletions]]]]) { |match| + # str.patscan(pattern[, start|[start, stop][, max_mis[, max_ins[, max_del]]]]) { |match| # block # } # -> Match @@ -82,11 +96,11 @@ module BackTrack end raise BackTrackError, "Bad pattern: #{pattern}" unless pattern.downcase =~ OK_PATTERN -# raise BackTrackError, "start: #{start} out of range (0 .. #{self.length - 1})" unless (0 .. self.length).include? start -# raise BackTrackError, "stop: #{stop} out of range (0 .. #{self.length - 1})" unless (0 .. self.length).include? stop -# raise BackTrackError, "max_mismatches: #{max_mismatches} out of range (0 .. #{MAX_MIS})" unless (0 .. MAX_MIS).include? max_mismatches -# raise BackTrackError, "max_insertions: #{max_insertions} out of range (0 .. #{MAX_INS})" unless (0 .. MAX_INS).include? max_insertions -# raise BackTrackError, "max_deletions: #{max_deletions} out of range (0 .. #{MAX_DEL})" unless (0 .. MAX_DEL).include? max_deletions + raise BackTrackError, "start: #{start} out of range (0 .. #{self.length - 1})" unless (0 .. self.length).include? start + raise BackTrackError, "stop: #{stop} out of range (0 .. #{self.length - 1})" unless (0 .. self.length).include? stop + raise BackTrackError, "max_mismatches: #{max_mismatches} out of range (0 .. #{MAX_MIS})" unless (0 .. MAX_MIS).include? max_mismatches + raise BackTrackError, "max_insertions: #{max_insertions} out of range (0 .. #{MAX_INS})" unless (0 .. MAX_INS).include? max_insertions + raise BackTrackError, "max_deletions: #{max_deletions} out of range (0 .. #{MAX_DEL})" unless (0 .. MAX_DEL).include? max_deletions matches = [] diff --git a/code_ruby/lib/maasha/seq/patternmatcher.rb b/code_ruby/lib/maasha/seq/dynamic.rb similarity index 100% rename from code_ruby/lib/maasha/seq/patternmatcher.rb rename to code_ruby/lib/maasha/seq/dynamic.rb -- 2.39.5