Skip to content

Instantly share code, notes, and snippets.

@tjlane
Created July 9, 2013 03:10
Show Gist options
  • Select an option

  • Save tjlane/5954386 to your computer and use it in GitHub Desktop.

Select an option

Save tjlane/5954386 to your computer and use it in GitHub Desktop.
A dumb script to convert methionines in a PDB file to their tellurium and selenium replacement mutants.
#!/usr/bin/env bash
"""
Generates a selenomethionine (MSE) or telluromethionine (MTE) mutant.
usage: ./heavy_mutant <pdb>
"""
import sys
mutation = raw_input("Mutate all METs to what {'MSE', 'MTE'}? ")
if mutation == 'MSE':
mutation_code = 'MSE'
heavy_atom = 'SE'
elif mutation == 'MTE':
mutation_code = 'MTE'
heavy_atom = 'TE'
else:
raise ValueError('Can only do selenium/tellurium mutations right now!')
input_fn = sys.argv[1]
f = open(input_fn, 'r')
lines = f.readlines()
f.close()
# search lines for MET residues
newlines = []
n_met = 0
for l in lines:
if l[17:20] == 'MET':
l = l.replace('MET', mutation_code)
# re-label
if l[13] == 'S':
n_met += 1
l = l.replace('SD', heavy_atom)
l = l[:76] + heavy_atom + '\n'
newlines.append(l)
output_fn = input_fn[:-4] + '-' + mutation_code + '.pdb'
f = open(output_fn, 'w')
f.writelines(newlines)
f.close()
print "Mutated %d METs" % n_met
print "Wrote: %s" % output_fn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment