[BioRuby-cvs] bioruby/lib/bio/db/pdb pdb.rb, 1.9, 1.10 model.rb, 1.3, 1.4

Naohisa Goto ngoto at pub.open-bio.org
Thu Jan 5 04:24:56 EST 2006


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

Modified Files:
	pdb.rb model.rb 
Log Message:
* pdb.rb
  * fixed failure to get model serial number
  * added Bio::PDB::ATOM#ter, #sigatm, #anisou, Bio::PDB::ANISOU#siguij
    to get a corresponding recorord.
* model.rb
  * Now, model_serial is an alias of serial.
  * added RDoc.


Index: model.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/pdb/model.rb,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** model.rb	4 Jan 2006 15:41:50 -0000	1.3
--- model.rb	5 Jan 2006 09:24:54 -0000	1.4
***************
*** 26,30 ****
    class PDB
  
!     #Model class
      class Model
        
--- 26,30 ----
    class PDB
  
!     # Model class
      class Model
        
***************
*** 40,96 ****
        include Comparable
        
!       attr_accessor :model_serial
!       attr_reader :structure
!       attr_reader :solvents
! 
!       def initialize(model_serial = nil, structure = nil)
!         
!         @model_serial = model_serial
!         
!         @structure    = structure
!         
!         @chains       = Array.new
!         @solvents     = Chain.new('', self)
          
        end
  
        attr_reader :chains
        attr_reader :solvents
!       
!       #Adds a chain
        def addChain(chain)
!         raise "Expecting a Bio::PDB::Chain" if not chain.is_a? Bio::PDB::Chain
          @chains.push(chain)
          self        
        end
        
!       #adds a solvent molecule
        def addSolvent(solvent)
!         raise "Expecting a Bio::PDB::Residue" if not solvent.is_a? Bio::PDB::Residue
          @solvents.addResidue(solvent)
        end
  
        def removeSolvent
          @solvents = nil
        end
  
!       #Chain iterator
        def each(&x) #:yields: chain
          @chains.each(&x)
        end
!       #Alias to override ChainFinder#each_chain
        alias each_chain each
       
!       #Sorts models based on serial number
        def <=>(other)
!         return @model_serial <=> other.model_serial
        end
        
!       #Keyed access to chains
        def [](key)
          chain = @chains.find{ |chain| key == chain.id }
        end
        
!       #stringifies to chains
        def to_s
          string = ""
--- 40,103 ----
        include Comparable
        
!       # Creates a new Model object
!       def initialize(serial = nil, structure = nil)
          
+         @serial = serial
+         @structure = structure
+         @chains = []
+         @solvents = Chain.new('', self)
        end
  
+       # chains in this model
        attr_reader :chains
+ 
+       # (OBSOLETE) solvents in this model
        attr_reader :solvents
! 
!       # serial number of this model. (Integer or nil)
!       attr_accessor :serial
! 
!       # for backward compatibility
!       alias model_serial serial
! 
!       # (deprecated)
!       attr_reader :structure
!      
!       # Adds a chain to this model
        def addChain(chain)
!         raise "Expecting a Bio::PDB::Chain" unless chain.is_a? Bio::PDB::Chain
          @chains.push(chain)
          self        
        end
        
!       # (OBSOLETE) Adds a solvent molecule to this model
        def addSolvent(solvent)
!         raise "Expecting a Bio::PDB::Residue" unless solvent.is_a? Bio::PDB::Residue
          @solvents.addResidue(solvent)
        end
  
+       # (OBSOLETE) not recommended to use this method
        def removeSolvent
          @solvents = nil
        end
  
!       # Iterates over each chain
        def each(&x) #:yields: chain
          @chains.each(&x)
        end
!       # Alias to override ChainFinder#each_chain
        alias each_chain each
       
!       # Operator aimed to sort models based on serial number
        def <=>(other)
!         return @serial <=> other.model_serial
        end
        
!       # Keyed access to chains
        def [](key)
          chain = @chains.find{ |chain| key == chain.id }
        end
        
!       # stringifies to chains
        def to_s
          string = ""
***************
*** 99,105 ****
          end
          @chains.each{ |chain| string << chain.to_s }
!         if solvent
!           string << @solvent.to_s
!         end
          if model_serial
            string << "ENDMDL"
--- 106,112 ----
          end
          @chains.each{ |chain| string << chain.to_s }
!         #if solvent
!         #  string << @solvent.to_s
!         #end
          if model_serial
            string << "ENDMDL"
***************
*** 110,114 ****
      end #class Model
  
!   end
  
! end
--- 117,121 ----
      end #class Model
  
!   end #class PDB
  
! end #module Bio

Index: pdb.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/pdb/pdb.rb,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** pdb.rb	4 Jan 2006 15:41:50 -0000	1.9
--- pdb.rb	5 Jan 2006 09:24:54 -0000	1.10
***************
*** 840,843 ****
--- 840,852 ----
          attr_accessor :residue
  
+         # SIGATM record
+         attr_accessor :sigatm
+ 
+         # ANISOU record
+         attr_accessor :anisou
+ 
+         # TER record
+         attr_accessor :ter
+ 
          #Returns a Coordinate class instance of the xyz positions
          def xyz
***************
*** 914,917 ****
--- 923,931 ----
                  )
  
+       class ANISOU
+         # SIGUIJ record
+         attr_accessor :siguij
+       end #class ANISOU
+ 
        SIGUIJ =
          def_rec([  7, 11, Pdb_Integer,      :serial ],
***************
*** 1220,1223 ****
--- 1234,1238 ----
        cResidue  = nil #Residue.new
        cLigand   = nil #Heterogen.new
+       c_atom    = nil
  
        #Goes through each line and replace that line with a PDB::Record
***************
*** 1260,1263 ****
--- 1275,1279 ----
          case key
          when 'ATOM'
+           c_atom = f
            residueID = Residue.get_residue_id_from_atom(f)
  
***************
*** 1280,1283 ****
--- 1296,1300 ----
  
          when 'HETATM'
+           c_atom = f
            residueID = Heterogen.get_residue_id_from_atom(f)
  
***************
*** 1304,1312 ****
  
          when 'MODEL'
!           if cModel.model_serial
              self.addModel(cModel)
            end
!           model_serial = line[6,5]
!           cModel = Model.new(model_serial)
          end
          f
--- 1321,1361 ----
  
          when 'MODEL'
!           c_atom = nil
!           if cModel.model_serial or cModel.chains.size > 0 then
              self.addModel(cModel)
            end
!           cModel = Model.new(f.serial)
! 
!         when 'TER'
!           if c_atom
!             c_atom.ter = f
!           else
!             #$stderr.puts "Warning: stray TER?"
!           end
!         when 'SIGATM'
!           if c_atom
!             #$stderr.puts "Warning: duplicated SIGATM?" if c_atom.sigatm
!             c_atom.sigatm = f
!           else
!             #$stderr.puts "Warning: stray SIGATM?"
!           end
!         when 'ANISOU'
!           if c_atom
!             #$stderr.puts "Warning: duplicated ANISOU?" if c_atom.anisou
!             c_atom.anisou = f
!           else
!             #$stderr.puts "Warning: stray ANISOU?"
!           end
!         when 'SIGUIJ'
!           if c_atom and c_atom.anisou
!             #$stderr.puts "Warning: duplicated SIGUIJ?" if c_atom.anisou.siguij
!             c_atom.anisou.siguij = f
!           else
!             #$stderr.puts "Warning: stray SIGUIJ?"
!           end
! 
!         else
!           c_atom = nil
! 
          end
          f



More information about the bioruby-cvs mailing list