[BioRuby-cvs] bioruby/lib/bio sequence.rb,0.36,0.37

Katayama Toshiaki k at pub.open-bio.org
Sun Aug 7 04:19:31 EDT 2005


Update of /home/repository/bioruby/bioruby/lib/bio
In directory pub.open-bio.org:/tmp/cvs-serv18079/lib/bio

Modified Files:
	sequence.rb 
Log Message:
* Bio::NucleicAcid, Bio::AminoAcid classes are refactored to have Data module
  and this module is included and extended to make methods as both of
  instance methods and extend methods
* Bio::Sequence::NA class is rewrited (molecular_weight, to_re methods)
  to use Bio::NucleicAcid
* molecular_weight method is fixed to subtract two hydrogens for each base


Index: sequence.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/sequence.rb,v
retrieving revision 0.36
retrieving revision 0.37
diff -C2 -d -r0.36 -r0.37
*** sequence.rb	23 Aug 2004 23:46:57 -0000	0.36
--- sequence.rb	7 Aug 2005 08:19:28 -0000	0.37
***************
*** 239,277 ****
  
        # NucleicAcid is defined in bio/data/na.rb
!       def molecular_weight(hash = nil)
! 	nw = NucleicAcid.weight
! 	if self.rna?
! 	  hash = {
! 	    'g' => nw[:guanine]  + nw[:ribose_phosphate] - nw[:water],
! 	    'c' => nw[:cytosine] + nw[:ribose_phosphate] - nw[:water],
! 	    'a' => nw[:adenine]  + nw[:ribose_phosphate] - nw[:water],
! 	    'u' => nw[:uracil]   + nw[:ribose_phosphate] - nw[:water],
! 	  }
! 	else
! 	  hash = {
! 	    'g' => nw[:guanine]  + nw[:deoxyribose_phosphate] - nw[:water],
! 	    'c' => nw[:cytosine] + nw[:deoxyribose_phosphate] - nw[:water],
! 	    'a' => nw[:adenine]  + nw[:deoxyribose_phosphate] - nw[:water],
! 	    't' => nw[:thymine]  + nw[:deoxyribose_phosphate] - nw[:water],
! 	  }
! 	end unless hash
! 	total(hash) + nw[:water]
        end
  
        # NucleicAcid is defined in bio/data/na.rb
        def to_re
- 	hash = NucleicAcid.names
  	if self.rna?
! 	  NucleicAcid.names.each {|k,v| hash[k] = v.tr('t', 'u')}
! 	end
! 	re = ''
! 	self.each_byte do |x|
! 	  if hash[x.chr]
! 	    re += hash[x.chr]
! 	  else
! 	    re += '.'
! 	  end
! 	end
! 	return Regexp.new(re)
        end
  
--- 239,257 ----
  
        # NucleicAcid is defined in bio/data/na.rb
!       def molecular_weight
!         if self.rna?
!           NucleicAcid.weight(self, true)
!         else
!           NucleicAcid.weight(self)
!         end
        end
  
        # NucleicAcid is defined in bio/data/na.rb
        def to_re
  	if self.rna?
!           NucleicAcid.to_re(self.dna)
!         else
!           NucleicAcid.to_re(self)
!         end
        end
  



More information about the bioruby-cvs mailing list