Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
generate_resfile.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # :noTabs=true:
3 
4 
5 # (c) Copyright Rosetta Commons Member Institutions.
6 # (c) This file is part of the Rosetta software suite and is made available under license.
7 # (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
8 # (c) For more information, see http://www.rosettacommons.org. Questions about this can be
9 # (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
10 
11 ## @file generate_resfile.py
12 ## @brief
13 ## @author Evan H. Baugh, Johns Hopkins University
14 
15 # adapted from original code by Sid Chaudhury
16 
17 from rosetta import Pose
18 from rosetta import pose_from_pdb
19 
20 # writes a specified resfile for the user, defaults to packing w/ input SC
21 def generate_resfile_from_pose( pose , resfilename ,
22  pack = True , design = False , input_sc = True ,
23  freeze = [] , specific = {} ):
24  """
25  Writes a resfile for <pose> named <resfilename>
26  <pack> = True allows packing by default
27  <design> = True allows design using all amino acids by default
28  <input_sc> = True allows usage of the original side chain conformation
29  <freeze> is an optional list of (pose) residue numbers to exclude
30  (preserve the side chain conformations of these residues)
31  <specific> is an optional dictionary with (pose) residue numbers as keys
32  and resfile keywords as corresponding values
33  (for setting individual residue options, it may be easier to add
34  these numbers to freeze and edit the resfile manually)
35 
36  example:
37  generate_resfile_from_pose(pose,'1YY8.resfile')
38  See also:
39  Pose
40  PackRotamersMover
41  TaskFactory
42  """
43  # determine the header, default settings
44  header = ''
45  if pack:
46  if not design:
47  header += 'NATAA\n'
48  else:
49  header += 'ALLAA\n# ALLAA will NOT work on bridged Cysteines\n'
50  else:
51  header += 'NATRO\n'
52  if input_sc:
53  header += 'USE_INPUT_SC\n'
54  to_write = header + 'start\n'
55  # add <freeze> list to <specific> dict
56  for i in freeze:
57  specific[i] = 'NATRO'
58  # <specific> is a dictionary with keys() as pose resi numbers
59  # and values as resfile keywords (PIKAA
60  # use PDBInfo object to write the resfile
61  info = pose.pdb_info()
62  # pose_from_sequence returns empty PDBInfo, Pose() makes NULL
63  if info and info.nres():
64  for i in specific.keys():
65  num = pose.pdb_info().number(i)
66  chain = pose.pdb_info().chain(i)
67  to_write += str(num).rjust(4) + str(chain).rjust(3) + ' ' + specific[i] + ' \n'
68  else:
69  for i in specific.keys():
70  num = i
71  chain = ' '
72  to_write += str(num).rjust(4) + str(chain).rjust(3) + ' ' + specific[i] + ' \n'
73  f = open(resfilename,'w')
74  f.write(to_write)
75  f.close()
76 
77 # this is silly, as with cleanCRYS, later implement a Biopy PDBParser method
78 def generate_resfile_from_pdb( pdbfilename , resfilename ,
79  pack = True , design = False , input_sc = True ,
80  freeze = [] , specific = {} ):
81  """
82  Writes a resfile for the PDB file <pdbfilename> named <resfilename>
83  <pack> = True allows packing by default
84  <design> = True allows design using all amino acids by default
85  <input_sc> = True allows usage of the original side chain conformation
86  <freeze> is an optional list of (pose) residue numbers to exclude
87  (preserve the side chain conformations of these residues)
88  <specific> is an optional dictionary with (pose) residue numbers as keys
89  and resfile keywords as corresponding values
90  (for setting individual residue options, it may be easier to add
91  these numbers to freeze and edit the resfile manually)
92 
93  example:
94  generate_resfile_from_pdb('1YY8.pdb','1YY8.resfile')
95  See also:
96  generate_resfile_from_pose
97  Pose
98  PackRotamersMover
99  TaskFactory
100  """
101  p = pose_from_pdb(pdbfilename)
102  generate_resfile_from_pose(p,resfilename,pack,design,input_sc,freeze,specific)
103 
104 # this class currently supports NOTHING more than the options above...but that will change! soon?
106  def __init__( self , pose , resfilename , pack = True , design = False , input_sc = True , freeze = [] , specific = {} ):
107  self.pose = pose
108  self.resfilename = resfilename
109  self.pack = pack
110  self.design = design
111  self.input_sc = input_sc
112  self.freeze = freeze
113  self.specific = specific
114 
115  def write_resfile( self , resfilename = '' ):
116  if not resfilename:
117  resfilename = self.resfilename
118  generate_resfile_from_pose( self.pose , resfilename , self.pack , self.design , self.input_sc , self.freeze , self.specific )
119 
120 # make it actually perform from PDB, use Bio.PDBParser
121 
122 
bool open(utility::io::izstream &db_stream, std::string const &db_file, bool warn)
Open a database file on a provided stream.
Definition: open.cc:55
Fstring rjust(Fstring const &s)
Right-Justified Copy.
Definition: Fstring.hh:2413