Quantcast
Channel: Getting residue number and residue name in Biopython PDB module - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Getting residue number and residue name in Biopython PDB module

$
0
0

I'm currently using pymol's iterate to get all the residue numbers, and then I use those to retrieve the residue name. I don't think that's the best way to do it. I tried to look for a way in biopython to no avail. I would appreciate your input and suggestions.

A side question, sometimes even chain[i].resname gives me a KeyError: ('', 'number', '') with a certain residue, which made me use a try and except block. Any alternatives?

from Bio import *from Bio.PDB.PDBParser import PDBParserfrom Bio.PDB.Polypeptide import PPBuilderstructure = PDBParser().get_structure('5bmy', '5bmy.pdb')    model = structure[0]chain = model['A']import __main____main__.pymol_argv = ['pymol','-qc']import pymolfrom pymol import cmd, storedpymol.finish_launching()cmd.load('5bmy.pdb')  # use the name of your pdb filestored.residues = []cmd.iterate('name ca', 'stored.residues.append(resi)')numbers = [ int(x) for x in stored.residues ]for i in numbers:    print (chain[i].resname)

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>