This is the main PDB class which takes care of parsing, annotations and is the entry way to the co-ordinate data held in models.
There are many related classes.
Bio::PDB::Model Bio::PDB::Chain Bio::PDB::Residue Bio::PDB::Heterogen Bio::PDB::Record::ATOM Bio::PDB::Record::HETATM Bio::PDB::Record::* Bio::PDB::Coordinate
DELIMITER | = | RS = nil | delimiter for reading via Bio::FlatFile | |
Coordinate_fileds | = | { 'MODEL' => true, :MODEL => true, 'ENDMDL' => true, :ENDMDL => true, 'ATOM' => true, :ATOM => true, 'HETATM' => true, :HETATM => true, 'SIGATM' => true, :SIGATM => true, 'SIGUIJ' => true, :SIGUIJ => true, 'ANISOU' => true, :ANISOU => true, 'TER' => true, :TER => true, } |
data | [R] | all records in this entry as an array. |
hash | [R] | all records in this entry as an hash accessed by record names. |
models | [R] | models in this entry (array). |
Creates a new Bio::PDB object from given str.
# File lib/bio/db/pdb/pdb.rb, line 1444 1444: def initialize(str) 1445: #Aha! Our entry into the world of PDB parsing, we initialise a PDB 1446: #object with the whole PDB file as a string 1447: #each PDB has an array of the lines of the original file 1448: #a bit memory-tastic! A hash of records and an array of models 1449: #also has an id 1450: 1451: @data = str.split(/[\r\n]+/) 1452: @hash = {} 1453: @models = [] 1454: @id = nil 1455: 1456: #Flag to say whether the current line is part of a continuation 1457: cont = false 1458: 1459: #Empty current model 1460: cModel = Model.new 1461: cChain = nil #Chain.new 1462: cResidue = nil #Residue.new 1463: cLigand = nil #Heterogen.new 1464: c_atom = nil 1465: 1466: #Goes through each line and replace that line with a PDB::Record 1467: @data.collect! do |line| 1468: #Go to next if the previous line was contiunation able, and 1469: #add_continuation returns true. Line is added by add_continuation 1470: next if cont and cont = cont.add_continuation(line) 1471: 1472: #Make the new record 1473: f = Record.get_record_class(line).new.initialize_from_string(line) 1474: #p f 1475: #Set cont 1476: cont = f if f.continue? 1477: #Set the hash to point to this record either by adding to an 1478: #array, or on it's own 1479: key = f.record_name 1480: if a = @hash[key] then 1481: a << f 1482: else 1483: @hash[key] = [ f ] 1484: end 1485: 1486: # Do something for ATOM and HETATM 1487: if key == 'ATOM' or key == 'HETATM' then 1488: if cChain and f.chainID == cChain.id 1489: chain = cChain 1490: else 1491: if chain = cModel[f.chainID] 1492: cChain = chain unless cChain 1493: else 1494: # If we don't have chain, add a new chain 1495: newChain = Chain.new(f.chainID, cModel) 1496: cModel.addChain(newChain) 1497: cChain = newChain 1498: chain = newChain 1499: end 1500: # chain might be changed, clearing cResidue and cLigand 1501: cResidue = nil 1502: cLigand = nil 1503: end 1504: end 1505: 1506: case key 1507: when 'ATOM' 1508: c_atom = f 1509: residueID = Residue.get_residue_id_from_atom(f) 1510: 1511: if cResidue and residueID == cResidue.id 1512: residue = cResidue 1513: else 1514: if residue = chain.get_residue_by_id(residueID) 1515: cResidue = residue unless cResidue 1516: else 1517: # add a new residue 1518: newResidue = Residue.new(f.resName, f.resSeq, f.iCode, chain) 1519: chain.addResidue(newResidue) 1520: cResidue = newResidue 1521: residue = newResidue 1522: end 1523: end 1524: 1525: f.residue = residue 1526: residue.addAtom(f) 1527: 1528: when 'HETATM' 1529: c_atom = f 1530: residueID = Heterogen.get_residue_id_from_atom(f) 1531: 1532: if cLigand and residueID == cLigand.id 1533: ligand = cLigand 1534: else 1535: if ligand = chain.get_heterogen_by_id(residueID) 1536: cLigand = ligand unless cLigand 1537: else 1538: # add a new heterogen 1539: newLigand = Heterogen.new(f.resName, f.resSeq, f.iCode, chain) 1540: chain.addLigand(newLigand) 1541: cLigand = newLigand 1542: ligand = newLigand 1543: #Each model has a special solvent chain. (for compatibility) 1544: if f.resName == 'HOH' 1545: cModel.addSolvent(newLigand) 1546: end 1547: end 1548: end 1549: 1550: f.residue = ligand 1551: ligand.addAtom(f) 1552: 1553: when 'MODEL' 1554: c_atom = nil 1555: cChain = nil 1556: cResidue = nil 1557: cLigand = nil 1558: if cModel.model_serial or cModel.chains.size > 0 then 1559: self.addModel(cModel) 1560: end 1561: cModel = Model.new(f.serial) 1562: 1563: when 'TER' 1564: if c_atom 1565: c_atom.ter = f 1566: else 1567: #$stderr.puts "Warning: stray TER?" 1568: end 1569: when 'SIGATM' 1570: if c_atom 1571: #$stderr.puts "Warning: duplicated SIGATM?" if c_atom.sigatm 1572: c_atom.sigatm = f 1573: else 1574: #$stderr.puts "Warning: stray SIGATM?" 1575: end 1576: when 'ANISOU' 1577: if c_atom 1578: #$stderr.puts "Warning: duplicated ANISOU?" if c_atom.anisou 1579: c_atom.anisou = f 1580: else 1581: #$stderr.puts "Warning: stray ANISOU?" 1582: end 1583: when 'SIGUIJ' 1584: if c_atom and c_atom.anisou 1585: #$stderr.puts "Warning: duplicated SIGUIJ?" if c_atom.anisou.siguij 1586: c_atom.anisou.siguij = f 1587: else 1588: #$stderr.puts "Warning: stray SIGUIJ?" 1589: end 1590: 1591: else 1592: c_atom = nil 1593: 1594: end 1595: f 1596: end #each 1597: #At the end we need to add the final model 1598: self.addModel(cModel) 1599: @data.compact! 1600: end
Provides keyed access to the models based on serial number returns nil if it‘s not there
# File lib/bio/db/pdb/pdb.rb, line 1632 1632: def [](key) 1633: @models.find{ |model| key == model.model_serial } 1634: end
Same as Bio::PDB#entry_id.
# File lib/bio/db/pdb/pdb.rb, line 1886 1886: def accession 1887: self.entry_id 1888: end
Adds a Bio::Model object to the current strucutre. Adds a model to the current structure. Returns self.
# File lib/bio/db/pdb/pdb.rb, line 1614 1614: def addModel(model) 1615: raise "Expecting a Bio::PDB::Model" if not model.is_a? Bio::PDB::Model 1616: @models.push(model) 1617: self 1618: end
Classification in "HEADER".
# File lib/bio/db/pdb/pdb.rb, line 1862 1862: def classification 1863: f = self.record('HEADER').first 1864: f ? f.classification : nil 1865: end
Gets DBREF records. Returns an array of Bio::PDB::Record::DBREF objects.
If chainID is given, it returns corresponding DBREF records.
# File lib/bio/db/pdb/pdb.rb, line 1847 1847: def dbref(chainID = nil) 1848: if chainID then 1849: self.record('DBREF').find_all { |f| f.chainID == chainID } 1850: else 1851: self.record('DBREF') 1852: end 1853: end
Title of this entry in "TITLE".
# File lib/bio/db/pdb/pdb.rb, line 1891 1891: def definition 1892: f = self.record('TITLE').first 1893: f ? f.title : nil 1894: end
Gets HELIX records. If no arguments are given, it returns all HELIX records. (Returns an array of Bio::PDB::Record::HELIX instances.) If helixID is given, it only returns records corresponding to given helixID. (Returns an Bio::PDB::Record::HELIX instance.)
# File lib/bio/db/pdb/pdb.rb, line 1748 1748: def helix(helixID = nil) 1749: if helixID then 1750: self.record('HELIX').find { |f| f.helixID == helixID } 1751: else 1752: self.record('HELIX') 1753: end 1754: end
returns a string containing human-readable representation of this object.
# File lib/bio/db/pdb/pdb.rb, line 1904 1904: def inspect 1905: "#<#{self.class.to_s} entry_id=#{entry_id.inspect}>" 1906: end
Gets JRNL records. If no arguments, it returns all JRNL records as a hash. If sub record name is specified, it returns only corresponding records as an array of Bio::PDB::Record instances.
# File lib/bio/db/pdb/pdb.rb, line 1729 1729: def jrnl(sub_record = nil) 1730: unless defined?(@jrnl) 1731: @jrnl = make_hash(self.record('JRNL'), :sub_record) 1732: end 1733: sub_record ? @jrnl[sub_record] : @jrnl 1734: end
Keywords in "KEYWDS". Returns an array of string.
# File lib/bio/db/pdb/pdb.rb, line 1857 1857: def keywords 1858: self.record('KEYWDS').collect { |f| f.keywds }.flatten 1859: end
Gets all records whose record type is name. Returns an array of Bio::PDB::Record::* objects.
if name is nil, returns hash storing all record data.
Example: p pdb.record(‘HETATM’) p pdb.record[‘HETATM’]
# File lib/bio/db/pdb/pdb.rb, line 1695 1695: def record(name = nil) 1696: name ? (@hash[name] || []) : @hash 1697: end
Gets REMARK records. If no arguments, it returns all REMARK records as a hash. If remark number is specified, returns only corresponding REMARK records. If number == 1 or 2 ("REMARK 1" or "REMARK 2"), returns an array of Bio::PDB::Record instances. Otherwise, returns an array of strings.
# File lib/bio/db/pdb/pdb.rb, line 1710 1710: def remark(nn = nil) 1711: unless defined?(@remark) 1712: h = make_hash(self.record('REMARK'), :remarkNum) 1713: h.each do |i, a| 1714: a.shift # remove first record (= space only) 1715: if i != 1 and i != 2 then 1716: a.collect! { |f| f.text.gsub(/\s+\z/, '') } 1717: end 1718: end 1719: @remark = h 1720: end 1721: nn ? @remark[nn] : @remark 1722: end
Amino acid or nucleic acid sequence of backbone residues in "SEQRES". If chainID is given, it returns corresponding sequence as an array of string. Otherwise, returns a hash which contains all sequences.
# File lib/bio/db/pdb/pdb.rb, line 1801 1801: def seqres(chainID = nil) 1802: unless defined?(@seqres) 1803: h = make_hash(self.record('SEQRES'), :chainID) 1804: newHash = {} 1805: h.each do |k, a| 1806: a.collect! { |f| f.resName } 1807: a.flatten! 1808: # determine nuc or aa? 1809: tmp = Hash.new(0) 1810: a[0,13].each { |x| tmp[x.to_s.strip.size] += 1 } 1811: if tmp[3] >= tmp[1] then 1812: # amino acid sequence 1813: a.collect! do |aa| 1814: #aa is three letter code: i.e. ALA 1815: #need to look up with Ala 1816: aa = aa.capitalize 1817: (begin 1818: Bio::AminoAcid.three2one(aa) 1819: rescue ArgumentError 1820: nil 1821: end || 'X') 1822: end 1823: seq = Bio::Sequence::AA.new(a.to_s) 1824: else 1825: # nucleic acid sequence 1826: a.collect! do |na| 1827: na = na.delete('^a-zA-Z') 1828: na.size == 1 ? na : 'n' 1829: end 1830: seq = Bio::Sequence::NA.new(a.to_s) 1831: end 1832: newHash[k] = seq 1833: end 1834: @seqres = newHash 1835: end 1836: if chainID then 1837: @seqres[chainID] 1838: else 1839: @seqres 1840: end 1841: end
Gets SHEET records. If no arguments are given, it returns all SHEET records as an array of arrays of Bio::PDB::Record::SHEET instances. If sheetID is given, it returns an array of Bio::PDB::Record::SHEET instances.
# File lib/bio/db/pdb/pdb.rb, line 1776 1776: def sheet(sheetID = nil) 1777: unless defined?(@sheet) 1778: @sheet = make_grouping(self.record('SHEET'), :sheetID) 1779: end 1780: if sheetID then 1781: @sheet.find_all { |f| f.first.sheetID == sheetID } 1782: else 1783: @sheet 1784: end 1785: end
Gets SSBOND records.
# File lib/bio/db/pdb/pdb.rb, line 1788 1788: def ssbond 1789: self.record('SSBOND') 1790: end
Returns a string of Bio::PDB::Models. This propogates down the heirarchy till you get to Bio::PDB::Record::ATOM which are outputed in PDB format
# File lib/bio/db/pdb/pdb.rb, line 1646 1646: def to_s 1647: string = "" 1648: @models.each{ |model| string << model.to_s } 1649: string << "END\n" 1650: return string 1651: end
Gets TURN records. If no arguments are given, it returns all TURN records. (Returns an array of Bio::PDB::Record::TURN instances.) If turnId is given, it only returns a record corresponding to given turnId. (Returns an Bio::PDB::Record::TURN instance.)
# File lib/bio/db/pdb/pdb.rb, line 1763 1763: def turn(turnId = nil) 1764: if turnId then 1765: self.record('TURN').find { |f| f.turnId == turnId } 1766: else 1767: self.record('TURN') 1768: end 1769: end