From: martinahansen Date: Fri, 14 Jan 2011 20:30:41 +0000 (+0000) Subject: fixed license text X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=a688871b29335f089aecc6888080b7f34c9624fc;p=biopieces.git fixed license text git-svn-id: http://biopieces.googlecode.com/svn/trunk@1205 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/code_ruby/Maasha/lib/align.rb b/code_ruby/Maasha/lib/align.rb index 5c0b9f5..a494b4d 100644 --- a/code_ruby/Maasha/lib/align.rb +++ b/code_ruby/Maasha/lib/align.rb @@ -1,6 +1,6 @@ raise "Ruby 1.9 or later required" if RUBY_VERSION < "1.9" -# Copyright (C) 2007-2010 Martin A. Hansen. +# Copyright (C) 2007-2011 Martin A. Hansen. # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/code_ruby/Maasha/lib/bitarray.rb b/code_ruby/Maasha/lib/bitarray.rb index 5533c52..e3f1a12 100644 --- a/code_ruby/Maasha/lib/bitarray.rb +++ b/code_ruby/Maasha/lib/bitarray.rb @@ -1,3 +1,27 @@ +# Copyright (C) 2007-2011 Martin A. Hansen. + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# http://www.gnu.org/copyleft/gpl.html + +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +# This software is part of the Biopieces framework (www.biopieces.org). + +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + BitsInChar = 8 # Error class for all exceptions to do with BitArray. @@ -11,7 +35,7 @@ class BitArray def initialize(size) @size = size @byte_array = init_byte_array - @count_table = init_count_table + @count_array = init_count_array end # Method to set a bit to 1 at a given position in the bit array. @@ -30,23 +54,12 @@ class BitArray (@byte_array[byte_pos(pos)].ord & bit_pos(pos)) != 0 end - # Method that returns the number of bits set "on" in a bit array. - def bits_on1 - bits_on = 0 - - (0 ... @size).each do |pos| - bits_on += 1 if bit_set?(pos) - end - - bits_on - end - # Method that returns the number of bits set "on" in a bit array. def bits_on bits_on = 0 (0 ... self.byte_array.size).each do |byte| - bits_on += @count_table[byte] + bits_on += @count_array[self.byte_array[byte].ord] end bits_on @@ -130,19 +143,27 @@ class BitArray byte_array end - # Method that creates a table with number of bits set. - def init_count_table - count_table = [] + # Method that returns an array where the element index value is + # the number of bits set for that index value. + def init_count_array + count_array = [] + (0 ... (2 ** BitsInChar)).each do |i| + count_array << bits_in_char(i) + end + + count_array + end + + # Method that returns the number of set bits in a byte. + def bits_in_char(char) bits = 0 - (0 ... BitsInChar).each do |i| - (0 ... BitsInChar).each do |c| - bits += 1 - end + (0 ... BitsInChar).each do |pos| + bits += 1 if ((char & bit_pos(pos)) != 0) end - puts bits + bits end # Method that returns the byte position in the byte array for a given bit position. diff --git a/code_ruby/Maasha/lib/fasta.rb b/code_ruby/Maasha/lib/fasta.rb index bd551be..26e6d73 100644 --- a/code_ruby/Maasha/lib/fasta.rb +++ b/code_ruby/Maasha/lib/fasta.rb @@ -1,3 +1,5 @@ +# Copyright (C) 2007-2011 Martin A. Hansen. + # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 diff --git a/code_ruby/Maasha/lib/fastq.rb b/code_ruby/Maasha/lib/fastq.rb index b8ce35e..fc2863a 100644 --- a/code_ruby/Maasha/lib/fastq.rb +++ b/code_ruby/Maasha/lib/fastq.rb @@ -1,3 +1,5 @@ +# Copyright (C) 2007-2011 Martin A. Hansen. + # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 diff --git a/code_ruby/Maasha/lib/genbank.rb b/code_ruby/Maasha/lib/genbank.rb index f52505f..f83e8b7 100644 --- a/code_ruby/Maasha/lib/genbank.rb +++ b/code_ruby/Maasha/lib/genbank.rb @@ -1,3 +1,5 @@ +# Copyright (C) 2007-2010 Martin A. Hansen. + # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 diff --git a/code_ruby/Maasha/lib/seq.rb b/code_ruby/Maasha/lib/seq.rb index 04dfdeb..893b854 100644 --- a/code_ruby/Maasha/lib/seq.rb +++ b/code_ruby/Maasha/lib/seq.rb @@ -1,3 +1,26 @@ +# Copyright (C) 2007-2011 Martin A. Hansen. + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# http://www.gnu.org/copyleft/gpl.html + +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +# This software is part of the Biopieces framework (www.biopieces.org). + +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< # Residue alphabets DNA = %w[a t c g]