[BioRuby] Preparing for 1.1 release
Naohisa GOTO
ngoto at gen-info.osaka-u.ac.jp
Tue Jul 10 10:40:10 UTC 2007
Hi,
On Mon, 09 Jul 2007 16:00:47 -0400
Mikael Borg <mikael.borg at utoronto.ca> wrote:
> There are still a few bugs in the pdb parser. I have tried to correct
> the ones I've found (see below), but as I find the original code
> difficult to understand, I might have introduced new bugs. Maybe you can
> have a look and either use my suggested changes, or come up with other
> solutions?
>
> Cheers,
>
> Mikael
>
> 1. empty records causes parser to crash through
> Bio::PDB::Record.Pdb_LString(nil).
> Solution: if empty record, make empty string String.new('').
Thank you for bug report.
I changed "str" to "str.to_s" to fix the bug.
> 2. if calling method sheet (Bio::PDB) for a Bio::PDB structure that
> doesn't contain any sheets, the parser crashes.
> Solution: return nil if there are no sheets in structure
The same or similar error could also be occurred for REMARK (remark),
JRNL (jrnl), HELIX (helix), TURN (turn), SHEET (sheet),
SSBOND (ssbond), SEQRES (seqres), DBREF (dbref), KEYWDS (keywords),
AUTHOR (authors), HEADER (entry_id, accession, classification),
TITLE (definition), and REVDAT (version) records (methods).
This is mostly caused by the Bio::PDB#record method which
returned nil when the specified record did not exist.
I changed it to return an empty array for nonexistent records.
All of the above bugs are now fixed and committed into CVS.
For your convenience, patch is attached below.
Thanks,
Naohisa Goto
ngoto at gen-info.osaka-u.ac.jp / ngoto at bioruby.org
-------------------------------------------------------------------
--- lib/bio/db/pdb/pdb.rb 19 Apr 2007 13:59:29 -0000 1.22
+++ lib/bio/db/pdb/pdb.rb 10 Jul 2007 10:17:38 -0000
@@ -119,7 +119,7 @@
m
end
def self.new(str)
- String.new(str)
+ String.new(str.to_s)
end
end
@@ -1674,7 +1674,7 @@
# p pdb.record['HETATM']
#
def record(name = nil)
- name ? @hash[name] : @hash
+ name ? (@hash[name] || []) : @hash
end
#--
@@ -1837,12 +1837,13 @@
# Classification in "HEADER".
def classification
- self.record('HEADER').first.classification
+ f = self.record('HEADER').first
+ f ? f.classification : nil
end
# Get authors in "AUTHOR".
def authors
- self.record('AUTHOR').first.authorList
+ self.record('AUTHOR').collect { |f| f.authorList }.flatten
end
#--
@@ -1851,7 +1852,10 @@
# PDB identifier written in "HEADER". (e.g. 1A00)
def entry_id
- @id = self.record('HEADER').first.idCode unless @id
+ unless @id
+ f = self.record('HEADER').first
+ @id = f ? f.idCode : nil
+ end
@id
end
@@ -1862,12 +1866,14 @@
# Title of this entry in "TITLE".
def definition
- self.record('TITLE').first.title
+ f = self.record('TITLE').first
+ f ? f.title : nil
end
# Current modification number in "REVDAT".
def version
- self.record('REVDAT').first.modNum
+ f = self.record('REVDAT').first
+ f ? f.modNum : nil
end
end #class PDB
-------------------------------------------------------------------
More information about the BioRuby
mailing list