[BioPython] Trying to extract a (single) ligand from a PDB file (dimere)
Florian Koelling
florian.koelling at tu-bs.de
Mon Mar 10 17:15:58 UTC 2008
Hi folks!
I'm new to biopython and tried to write a parser to extract a Ligand
from it 's PDB file. It even works - but I've got a dimer with two
ligands and I'd like to have a new PDB file containing only one
ligand.
My trials to acces the residue(the ligand) via the residue id failed...
Hope you can Help me.
My code so far :-((((
#### LIGAND DETECTION
import Bio.PDB
from Bio.PDB import*
import Numeric
parser = PDBParser()
structure = parser.get_structure('s', '2F1G.pdb')
print "\n"
print "structure_object_created"
requirement_id_list = []
requirement_names_list = []
residue = structure.get_residues()
for i in residue:
residue_id = i.get_id()
if residue_id[0]
!='W': #parsing water
if residue_id[0] !='
': #parsing
resname=(residue_id[0]).strip('H_') #remove
het_flag
requirement_names_list.append(resname) #RES
NAME
requirement_id_list.append
(residue_id[1]) #RES ID
###Req_lists: requirements for writing
print '\n'
print requirement_names_list, 'ligands_Names-> Hetatms '
print requirement_id_list, 'ligands_IDs-> Hetatms '
print '\n'
if len(requirement_names_list) == 0:
print 'no_hetatms found!'
assert()
class HetatmSelect(Select):
def accept_residue(self, residue):
if residue.get_resname() in
requirement_names_list[0] : #writing 1st_element
return 1
else:
return 0
io=PDBIO() ###WRITING
io.set_structure(structure)
io.save('ligand_parsed.pdb', HetatmSelect())
print "writing parsed pdb file .... Done"
Thanx alot!
Floran
More information about the Biopython
mailing list