[Biopython-dev] [Bug 3109] Record class in Bio.SCOP.Cla has hierarchy member as list instead of dictionary
bugzilla-daemon at portal.open-bio.org
bugzilla-daemon at portal.open-bio.org
Fri Aug 6 15:51:40 EDT 2010
http://bugzilla.open-bio.org/show_bug.cgi?id=3109
jeffrey.finkelstein at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
URL|http://github.com/jfinkels/b|http://github.com/jfinkels/b
|iopython/commit/6d2257dd0c46|iopython/commit/e52255f06c08
|abdf1ecd14b8bc660e32a205630a|aad1556eb518e2e0da8f030765ff
Version|1.54b |1.54
------- Comment #3 from jeffrey.finkelstein at gmail.com 2010-08-06 15:51 EST -------
(In reply to comment #2)
> Created an attachment (id=1538)
--> (http://bugzilla.open-bio.org/attachment.cgi?id=1538&action=view) [details]
> Fix bug #3109: replace Bio.SCOP.Cla.Record.hierarchy list with dictionary
>
> Updated patch for bug #3109, without removed trailing newlines
>
I have update the patch for this bug so that it no longer removes the trailing
newlines. I will open a new bug for that change.
The fix can be found at my personal github fork of Biopython:
http://github.com/jfinkels/biopython/commit/e52255f06c08aad1556eb518e2e0da8f030765ff
Here is a before/after demonstration of usage of the code which this patch
affects. Currently, to select, for example, all PDB chains in superfamily
50156, one must use something similar to the following code:
<code>
import Bio.SCOP.Cla
SCOP_CLA_FILE = 'dir.cla.scop.txt_1.75'
records = []
with open(SCOP_CLA_FILE, 'r') as f:
for record in Bio.SCOP.Cla.parse(f):
for key, value in record.hierarchy:
if key == 'sf' and value == 50156:
records.append(record)
print [record.residues.pdbid for record in records]
</code>
With this patch, the hierarchy key/value pairs can be accessed like a
dictionary:
<code>
import Bio.SCOP.Cla
SCOP_CLA_FILE = 'dir.cla.scop.txt_1.75'
with open(SCOP_CLA_FILE, 'r') as f:
records = [record for record in Bio.SCOP.Cla.parse(f)
if record.hierarchy['sf'] == 50156]
print [record.residues.pdbid for record in records]
</code>
The benefit is greater with more complex selections of sets of chains (for
example, to select all families within a superfamily).
--
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the Biopython-dev
mailing list