lib/PDB.rb
# Open PDB file and create Molecule
Open PDB file and create Molecule
Open PDB file and create Molecule
def openPDBFile(filename, flags={})
      puts "OPENING {filename}"
      PDB::report_log("OPENING {filename}")
      pdbLines=[]
      open(filename){|x| pdbLines = x.readlines}
      ssLines = getSS(pdbLines) 
      pdbLines.select!{ |x| x =~ /^ATOM/} 
      pdbLines.collect!{|x| PDB::Atom.new(x) }  includes atoms that are in alternate locations
       group atoms by chains organized by collection of residues
      current_chain = pdbLines[0].chain
      @molecules[current_chain.to_sym] = PDB::Molecule.new
      pdbLines.each do |atom|
        if (atom.chain != current_chain)
          current_chain = atom.chain
          @molecules[current_chain.to_sym] = PDB::Molecule.new
          puts "chain {current_chain}"
        end
         strip out waters
        if atom.residue == "HOH"
          @molecules[:HOH] ||= PDB::Molecule.new
          atom.chain = "HOH"  set chain to WAT
          @molecules[:HOH].addAtom(atom)
        else
           don't include ACE capping modification as a residue
          if (atom.residue != 'ACE' && atom.resid > 0)
            @molecules[current_chain.to_sym].addAtom(atom)
          end
        end
      end  end pdbLines loop
       assign secondary structure based on PDB assignment
       default should be OTHER
      @molecules.each_value do |val|
        val.residues.each do |residue|
           if resid of residue is within range of ss
          residue.setSecondaryStructure("OTHER", 0)
          residue.validate
        end
      end
       iterate through residues in chain and assign SS
      ssLines.each do |assignment|
        startIndex = assignment.start
        endIndex = assignment.end
        ch = assignment.chain
        ssType = assignment.type
         puts "ASSIGNMENT {ch} {startIndex} {endIndex}"
        residues =  @molecules.has_key?(ch.to_sym) ? @molecules[ch.to_sym].residues : Array.new
        residues.each do |resi|
          if (resi.resid == startIndex && startIndex <= endIndex)
            resi.setSecondaryStructure(ssType, assignment.ss_subclass)
            startIndex+=1
          elsif (startIndex > endIndex)
            break
          end
        end
      end  end ssLines
      @molecules.each_pair do |k,v|
        v.extractSequence
        v.getMass
      end
       create working set based on selection (flags)
      if flags.size == 0
        fillActiveSet
      else
        @active_set.clear
         :CA => false
         :CA => true
        selectAtomsByAttribute(flags)
      end
    end
def openPDBFile ( filename , flags = { } ) puts "OPENING #{filename}" PDB :: report_log ( "OPENING #{filename}" ) pdbLines = [ ] open ( filename ) { | x | pdbLines = x . readlines } ssLines = getSS ( pdbLines ) pdbLines . select! { | x | x =~ / ^ATOM / } pdbLines . collect! { | x | PDB :: Atom . new ( x ) } current_chain = pdbLines [ 0 ] . chain @molecules [ current_chain . to_sym ] = PDB :: Molecule . new pdbLines . each do | atom | if ( atom . chain != current_chain ) current_chain = atom . chain @molecules [ current_chain . to_sym ] = PDB :: Molecule . new puts "chain #{current_chain}" end if atom . residue == "HOH" @molecules [ :HOH ] ||= PDB :: Molecule . new atom . chain = "HOH" @molecules [ :HOH ] . addAtom ( atom ) else if ( atom . residue != 'ACE' && atom . resid > 0 ) @molecules [ current_chain . to_sym ] . addAtom ( atom ) end end end @molecules . each_value do | val | val . residues . each do | residue | residue . setSecondaryStructure ( "OTHER" , 0 ) residue . validate end end ssLines . each do | assignment | startIndex = assignment . start endIndex = assignment . end ch = assignment . chain ssType = assignment . type residues = @molecules . has_key? ( ch . to_sym ) ? @molecules [ ch . to_sym ] . residues : Array . new residues . each do | resi | if ( resi . resid == startIndex && startIndex <= endIndex ) resi . setSecondaryStructure ( ssType , assignment . ss_subclass ) startIndex += 1 elsif ( startIndex > endIndex ) break end end end @molecules . each_pair do | k , v | v . extractSequence v . getMass end if flags . size == 0 fillActiveSet else @active_set . clear selectAtomsByAttribute ( flags ) end end
Open PDB file and create Molecule
Open PDB file and create Molecule
# assign secondary structure to each residue # returns array of SSOBject # # includes atoms that are in alternate locations # group atoms by chains organized by collection of residues # strip out waters # set chain to WAT # don't include ACE capping modification as a residue # end pdbLines loop # assign secondary structure based on PDB assignment # default should be OTHER # if resid of residue is within range of ss # iterate through residues in chain and assign SS # puts "ASSIGNMENT #{ch} #{startIndex} #{endIndex}" # end ssLines # create working set based on selection (flags) # :CA => false # :CA => true
filename
<not_specific>
flags
<not_specific>