[BioRuby-cvs] bioruby/lib/bio/db/pdb atom.rb, 1.5, 1.6 chain.rb, 1.3, 1.4 model.rb, 1.4, 1.5 pdb.rb, 1.11, 1.12 residue.rb, 1.7, 1.8 utils.rb, 1.4, 1.5

Naohisa Goto ngoto at pub.open-bio.org
Sun Jan 8 07:59:06 EST 2006


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

Modified Files:
	atom.rb chain.rb model.rb pdb.rb residue.rb utils.rb 
Log Message:
* added RDoc.
* Bio::PDB#seqres returns Bio::Sequence::NA object if the chain seems to be
  a nucleic acid sequence.
* Bio::PDB#inspect calls do_parse before inspect. 
* Bio::PDB#atom_seq is now an alias of Bio::PDB::Chain#aaseq.
* Bio::PDB#seqres and Bio::PDB::Chain#aaseq are changed to use
  Bio::AminoAcid.three2one(tlc).


Index: atom.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/pdb/atom.rb,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** atom.rb	18 Dec 2005 17:33:32 -0000	1.5
--- atom.rb	8 Jan 2006 12:59:04 -0000	1.6
***************
*** 1,8 ****
  #
! # bio/db/pdb/atom.rb - Coordinate and atom class for PDB
  #
! #   Copyright (C) 2004 Alex Gutteridge <alexg at ebi.ac.uk>
! #   Copyright (C) 2004 GOTO Naohisa <ngoto at gen-info.osaka-u.ac.jp>
  #
  #  This library is free software; you can redistribute it and/or
  #  modify it under the terms of the GNU Lesser General Public
--- 1,13 ----
  #
! # = bio/db/pdb/atom.rb - Coordinate class for PDB
  #
! # Copyright::  Copyright (C) 2004, 2006
! #              Alex Gutteridge <alexg at ebi.ac.uk>
! #              Naohisa Goto <ng at bioruby.org>
! # License:: LGPL
! #
! #  $Id$
  #
+ #--
  #  This library is free software; you can redistribute it and/or
  #  modify it under the terms of the GNU Lesser General Public
***************
*** 18,23 ****
  #  License along with this library; if not, write to the Free Software
  #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
  #
- #  $Id$
  
  require 'matrix'
--- 23,37 ----
  #  License along with this library; if not, write to the Free Software
  #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ #++
+ #
+ # = Bio::PDB::Coordinate
+ #
+ # Coordinate class for PDB.
+ #
+ # = Compatibility Note
+ #
+ # From bioruby 0.7.0, the Bio::PDB::Atom class is no longer available.
+ # Please use Bio::PDB::Record::ATOM and Bio::PDB::Record::HETATM instead.
  #
  
  require 'matrix'
***************
*** 27,55 ****
    class PDB
  
      class Coordinate < Vector
        def self.[](x,y,z)
          super
        end
  
        def self.elements(array, *a)
          raise 'Size of given array must be 3' if array.size != 3
          super
        end
!       
        def x; self[0]; end
        def y; self[1]; end
        def z; self[2]; end
        def x=(n); self[0]=n; end
        def y=(n); self[1]=n; end
        def z=(n); self[2]=n; end
  
        # Definition of 'to_ary' means objects of the class is
        # implicitly regarded as an array.
        def to_ary; self.to_a; end
  
        def xyz; self; end
!       
        def distance(object2)
!         Utils::to_xyz(object2)
          (self - object2).r
        end
--- 41,88 ----
    class PDB
  
+     # Bio::PDB::Coordinate is a class to store a 3D coordinate.
+     # It inherits Vector (in bundled library in Ruby).
+     #
      class Coordinate < Vector
+       # same as Vector.[x,y,z]
        def self.[](x,y,z)
          super
        end
  
+       # same as Vector.elements
        def self.elements(array, *a)
          raise 'Size of given array must be 3' if array.size != 3
          super
        end
! 
!       # x
        def x; self[0]; end
+       # y
        def y; self[1]; end
+       # z
        def z; self[2]; end
+       # x=(n)
        def x=(n); self[0]=n; end
+       # y=(n)
        def y=(n); self[1]=n; end
+       # z=(n)
        def z=(n); self[2]=n; end
  
+       # Implicit conversion to an array.
+       #
+       # Note that this method would be deprecated in the future.
+       #
+       #--
        # Definition of 'to_ary' means objects of the class is
        # implicitly regarded as an array.
+       #++
        def to_ary; self.to_a; end
  
+       # returns self.
        def xyz; self; end
! 
!       # distance between <em>object2</em>.
        def distance(object2)
!         Utils::convert_to_xyz(object2)
          (self - object2).r
        end

Index: residue.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/pdb/residue.rb,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** residue.rb	4 Jan 2006 15:41:50 -0000	1.7
--- residue.rb	8 Jan 2006 12:59:04 -0000	1.8
***************
*** 1,7 ****
  #
! # bio/db/pdb/residue.rb - residue class for PDB
  #
! #   Copyright (C) 2004 Alex Gutteridge <alexg at ebi.ac.uk>
  #
  #  This library is free software; you can redistribute it and/or
  #  modify it under the terms of the GNU Lesser General Public
--- 1,13 ----
  #
! # = bio/db/pdb/residue.rb - residue class for PDB
  #
! # Copyright::  Copyright (C) 2004, 2006
! #              Alex Gutteridge <alexg at ebi.ac.uk>
! #              Naohisa Goto <ng at bioruby.org>
! # License:: LGPL
! #
! #  $Id$
  #
+ #--
  #  This library is free software; you can redistribute it and/or
  #  modify it under the terms of the GNU Lesser General Public
***************
*** 17,22 ****
  #  License along with this library; if not, write to the Free Software
  #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
  #
- #  $Id$
  
  require 'bio/db/pdb'
--- 23,32 ----
  #  License along with this library; if not, write to the Free Software
  #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ #++
+ #
+ # = Bio::PDB::Residue
+ #
+ # = Bio::PDB::Heterogen
  #
  
  require 'bio/db/pdb'
***************
*** 26,30 ****
    class PDB
  
!     #Residue class - id is a composite of resSeq and iCode
      class Residue
        
--- 36,42 ----
    class PDB
  
!     # Bio::PDB::Residue is a class to store a residue.
!     # The object would contain some atoms (Bio::PDB::Record::ATOM objects).
!     #
      class Residue
        
***************
*** 63,67 ****
        attr_accessor :resName
  
!       # residue id (String or nil)
        attr_reader   :residue_id
  
--- 75,80 ----
        attr_accessor :resName
  
!       # residue id (String or nil).
!       # The id is a composite of resSeq and iCode.
        attr_reader   :residue_id
  
***************
*** 135,138 ****
--- 148,153 ----
        end
  
+       # Always returns false.
+       #
        # If the residue is HETATM, returns true.
        # Otherwise, returns false.
***************
*** 142,149 ****
--- 157,171 ----
      end #class Residue
  
+     # Bio::PDB::Heterogen is a class to store a heterogen.
+     # It inherits Bio::PDB::Residue and most of the methods are the same.
+     #
+     # The object would contain some HETATMs
+     # (Bio::PDB::Record::HETATM objects).
      class Heterogen < Residue
  
        include HetatmFinder
  
+       # Always returns true.
+       #
        # If the residue is HETATM, returns true.
        # Otherwise, returns false.
***************
*** 155,158 ****
--- 177,181 ----
        alias each_hetatm each
  
+       # Alias needed for HeterogenFinder.
        alias hetatms atoms
      end #class Heterogen

Index: model.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/pdb/model.rb,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** model.rb	5 Jan 2006 09:24:54 -0000	1.4
--- model.rb	8 Jan 2006 12:59:04 -0000	1.5
***************
*** 1,7 ****
  #
! # bio/db/pdb/model.rb - model class for PDB
  #
! #   Copyright (C) 2004 Alex Gutteridge <alexg at ebi.ac.uk>
  #
  #  This library is free software; you can redistribute it and/or
  #  modify it under the terms of the GNU Lesser General Public
--- 1,13 ----
  #
! # = bio/db/pdb/model.rb - model class for PDB
  #
! # Copyright:: Copyright (C) 2004, 2006
! #             Alex Gutteridge <alexg at ebi.ac.uk>
! #             Naohisa Goto <ng at bioruby.org>
! # License:: LGPL
! #
! #  $Id$
  #
+ #--
  #  This library is free software; you can redistribute it and/or
  #  modify it under the terms of the GNU Lesser General Public
***************
*** 17,22 ****
  #  License along with this library; if not, write to the Free Software
  #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
  #
- #  $Id$
  
  require 'bio/db/pdb'
--- 23,32 ----
  #  License along with this library; if not, write to the Free Software
  #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ #++
+ #
+ # = Bio::PDB::Model
+ #
+ # Please refer Bio::PDB::Model.
  #
  
  require 'bio/db/pdb'
***************
*** 26,30 ****
    class PDB
  
!     # Model class
      class Model
        
--- 36,42 ----
    class PDB
  
!     # Bio::PDB::Model is a class to store a model.
!     #
!     # The object would contain some chains (Bio::PDB::Chain objects).
      class Model
        
***************
*** 52,56 ****
        attr_reader :chains
  
!       # (OBSOLETE) solvents in this model
        attr_reader :solvents
  
--- 64,68 ----
        attr_reader :chains
  
!       # (OBSOLETE) solvents (water, HOH) in this model
        attr_reader :solvents
  
***************
*** 61,65 ****
        alias model_serial serial
  
!       # (deprecated)
        attr_reader :structure
       
--- 73,77 ----
        alias model_serial serial
  
!       # (reserved for future extension)
        attr_reader :structure
       

Index: utils.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/pdb/utils.rb,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** utils.rb	5 Jan 2006 11:10:10 -0000	1.4
--- utils.rb	8 Jan 2006 12:59:04 -0000	1.5
***************
*** 1,8 ****
  #
! # bio/db/pdb/utils.rb - Utility modules for PDB
  #
! #   Copyright (C) 2004 Alex Gutteridge <alexg at ebi.ac.uk>
! #   Copyright (C) 2004 GOTO Naohisa <ngoto at gen-info.osaka-u.ac.jp>
  #
  #  This library is free software; you can redistribute it and/or
  #  modify it under the terms of the GNU Lesser General Public
--- 1,13 ----
  #
! # = bio/db/pdb/utils.rb - Utility modules for PDB
  #
! # Copyright::  Copyright (C) 2004, 2006
! #              Alex Gutteridge <alexg at ebi.ac.uk>
! #              Naohisa Goto <ng at bioruby.org>
! # License:: LGPL
  #
+ #  $Id$
+ #
+ #--
  #  This library is free software; you can redistribute it and/or
  #  modify it under the terms of the GNU Lesser General Public
***************
*** 18,23 ****
  #  License along with this library; if not, write to the Free Software
  #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
  #
- #  $Id$
  
  require 'matrix'
--- 23,56 ----
  #  License along with this library; if not, write to the Free Software
  #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ #++
+ #
+ # = Bio::PDB::Utils
+ #
+ # Bio::PDB::Utils
+ #
+ # = Bio::PDB::ModelFinder
+ #
+ # Bio::PDB::ModelFinder
+ #
+ # = Bio::PDB::ChainFinder
+ #
+ # Bio::PDB::ChainFinder
+ #
+ # = Bio::PDB::ResidueFinder
+ #
+ # Bio::PDB::ResidueFinder
+ #
+ # = Bio::PDB::AtomFinder
+ #
+ # Bio::PDB::AtomFinder
+ #
+ # = Bio::PDB::HeterogenFinder
+ #
+ # Bio::PDB::HeterogenFinder
+ #
+ # = Bio::PDB::HetatmFinder
+ #
+ # Bio::PDB::HetatmFinder
  #
  
  require 'matrix'
***************
*** 27,32 ****
  
    # Utility methods for PDB data.
-   #
    # The methods in this mixin should be applicalbe to all PDB objects.
    module Utils
      
--- 60,67 ----
  
    # Utility methods for PDB data.
    # The methods in this mixin should be applicalbe to all PDB objects.
+   #
+   # Bio::PDB::Utils is included by Bio::PDB, Bio::PDB::Model,
+   # Bio::PDB::Chain, Bio::PDB::Residue, and Bio::PDB::Heterogen classes.
    module Utils
      
***************
*** 203,206 ****
--- 238,244 ----
    #
    # XXX#each_model must be defined.
+   #
+   # Bio::PDB::ModelFinder is included by Bio::PDB::PDB.
+   #
    module ModelFinder
      # returns an array containing all chains for which given block
***************
*** 225,228 ****
--- 263,269 ----
    #
    # XXX#each_model must be defined.
+   #
+   # Bio::PDB::ChainFinder is included by Bio::PDB::PDB and Bio::PDB::Model.
+   #
    module ChainFinder
  
***************
*** 253,256 ****
--- 294,301 ----
    #
    # XXX#each_chain must be defined.
+   #
+   # Bio::PDB::ResidueFinder is included by Bio::PDB::PDB, Bio::PDB::Model,
+   # and Bio::PDB::Chain.
+   #
    module ResidueFinder
  
***************
*** 308,311 ****
--- 353,360 ----
    #
    # XXX#each_heterogen must be defined.
+   #
+   # Bio::PDB::HetatmFinder is included by Bio::PDB::PDB, Bio::PDB::Model,
+   # Bio::PDB::Chain, and Bio::PDB::Heterogen.
+   #
    module HetatmFinder
      # returns an array containing all HETATMs for which given block
***************
*** 335,338 ****
--- 384,391 ----
    #
    # XXX#each_chain must be defined.
+   #
+   # Bio::PDB::HeterogenFinder is included by Bio::PDB::PDB, Bio::PDB::Model,
+   # and Bio::PDB::Chain.
+   #
    module HeterogenFinder
      # returns an array containing all heterogens for which given block

Index: pdb.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/pdb/pdb.rb,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** pdb.rb	5 Jan 2006 11:10:10 -0000	1.11
--- pdb.rb	8 Jan 2006 12:59:04 -0000	1.12
***************
*** 1,8 ****
  #
! # bio/db/pdb/pdb.rb - PDB database class for PDB file format
  #
! #   Copyright (C) 2003,2004 GOTO Naohisa <ngoto at gen-info.osaka-u.ac.jp>
! #   Copyright (C) 2004 Alex Gutteridge <alexg at ebi.ac.uk>
  #
  #  This library is free software; you can redistribute it and/or
  #  modify it under the terms of the GNU Lesser General Public
--- 1,13 ----
  #
[...1339 lines suppressed...]
- 
- --- Bio::PDB::Record#"anything"
- 
-  Same as Bio::PDB::Record#[](:anything) after do_parse.
-  For example, r.helixID is same as r.do_parse; r[:helixID] .
- 
- 
- = Bio::PDB::FieldDef
- 
-  Internal use only.
-  Format definition of each record.
- 
- = References
- 
- * ((<URL:http://www.rcsb.org/pdb/>))
- * PDB File Format Contents Guide Version 2.2 (20 December 1996)
-   ((<URL:http://www.rcsb.org/pdb/docs/format/pdbguide2.2/guide2.2_frame.html>))
- 
- =end
--- 1819,1820 ----

Index: chain.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/pdb/chain.rb,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** chain.rb	4 Jan 2006 15:41:50 -0000	1.3
--- chain.rb	8 Jan 2006 12:59:04 -0000	1.4
***************
*** 1,7 ****
  #
! # bio/db/pdb/chain.rb - chain class for PDB
  #
! #   Copyright (C) 2004 Alex Gutteridge <alexg at ebi.ac.uk>
  #
  #  This library is free software; you can redistribute it and/or
  #  modify it under the terms of the GNU Lesser General Public
--- 1,13 ----
  #
! # = bio/db/pdb/chain.rb - chain class for PDB
  #
! # Copyright:: Copyright (C) 2004, 2006
! #             Alex Gutteridge <alexg at ebi.ac.uk>
! #             Naohisa Goto <ng at bioruby.org>
! # License:: LGPL
! # 
! #  $Id$
  #
+ #--
  #  This library is free software; you can redistribute it and/or
  #  modify it under the terms of the GNU Lesser General Public
***************
*** 17,22 ****
  #  License along with this library; if not, write to the Free Software
  #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
  #
- #  $Id$
  
  require 'bio/db/pdb'
--- 23,32 ----
  #  License along with this library; if not, write to the Free Software
  #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ #++
+ #
+ # = Bio::PDB::Chain
+ # 
+ # Please refer Bio::PDB::Chain.
  #
  
  require 'bio/db/pdb'
***************
*** 26,29 ****
--- 36,44 ----
    class PDB
  
+     # Bio::PDB::Chain is a class to store a chain.
+     #
+     # The object would contain some residues (Bio::PDB::Residue objects)
+     # and some heterogens (Bio::PDB::Heterogen objects).
+     # 
      class Chain
        
***************
*** 37,41 ****
        include Enumerable
        include Comparable
!       
        def initialize(id = nil, model = nil)
          
--- 52,57 ----
        include Enumerable
        include Comparable
! 
!       # Creates a new chain object.
        def initialize(id = nil, model = nil)
          
***************
*** 48,56 ****
        end
  
        attr_accessor :chain_id
!       attr_reader :model
! 
        alias id chain_id
  
        # residues in this chain
        attr_reader :residues
--- 64,75 ----
        end
  
+       # Identifier of this chain
        attr_accessor :chain_id
!       # alias
        alias id chain_id
  
+       # the model to which this chain belongs.
+       attr_reader :model
+ 
        # residues in this chain
        attr_reader :residues
***************
*** 113,134 ****
        end
  
!       # gets an amino acid sequence of the chain
!       def atom_seq
!         string = ""
!         last_residue_num = nil
!         @residues.each do |residue|
!           if last_residue_num and 
!               (x = (residue.resSeq.to_i - last_residue_num).abs) > 1 then
!             x.times { string << 'X' }
!           end
!           tlc = residue.resName.capitalize
!           olc = AminoAcid.names.invert[tlc]
!           if !olc
!             olc = 'X'
            end
!           string << olc
          end
!         Bio::Sequence::AA.new(string)
        end
        
      end #class Chain
--- 132,155 ----
        end
  
!       # gets an amino acid sequence of this chain from ATOM records
!       def aaseq
!         unless defined? @aaseq
!           string = ""
!           last_residue_num = nil
!           @residues.each do |residue|
!             if last_residue_num and 
!                 (x = (residue.resSeq.to_i - last_residue_num).abs) > 1 then
!               x.times { string << 'X' }
!             end
!             tlc = residue.resName.capitalize
!             olc = (Bio::AminoAcid.three2one(tlc) or 'X')
!             string << olc
            end
!           @aaseq = Bio::Sequence::AA.new(string)
          end
!         @aaseq
        end
+       # for backward compatibility
+       alias atom_seq aaseq
        
      end #class Chain



More information about the bioruby-cvs mailing list