]> git.donarmstrong.com Git - biopieces.git/commitdiff
fixed license text
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 14 Jan 2011 20:30:41 +0000 (20:30 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 14 Jan 2011 20:30:41 +0000 (20:30 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1205 74ccb610-7750-0410-82ae-013aeee3265d

code_ruby/Maasha/lib/align.rb
code_ruby/Maasha/lib/bitarray.rb
code_ruby/Maasha/lib/fasta.rb
code_ruby/Maasha/lib/fastq.rb
code_ruby/Maasha/lib/genbank.rb
code_ruby/Maasha/lib/seq.rb

index 5c0b9f536462da9ced09e8e5e88057e96c60d6b3..a494b4dd954611112e817f77c17938eb17be9707 100644 (file)
@@ -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
index 5533c522b3f08a31555fbd4426ccfc9937534c21..e3f1a12d49bc87c9eb0021a875610d20e0a30b0e 100644 (file)
@@ -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.
index bd551bec6ceb1b75ec715c04c0728eb239ed3aa2..26e6d735e4a74cc47be9074ea30c06ac5e96823c 100644 (file)
@@ -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
index b8ce35eb69c285350d94a717969bac72ab4c1198..fc2863a781a2a59726010c55530d98d4d53d81f9 100644 (file)
@@ -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
index f52505fac958ef0cc68da7b92d2e7f90cc8eef15..f83e8b7f5f490128395f0b2054989452d4dba25f 100644 (file)
@@ -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
index 04dfdeb4ce6b02e8bd1522ed5bf60fa0e27bf5d5..893b854aec918163cf01d473cf256a6229a5968b 100644 (file)
@@ -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]