Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
exclude.py
Go to the documentation of this file.
1 # :noTabs=true:
2 
3 # (c) Copyright Rosetta Commons Member Institutions.
4 # (c) This file is part of the Rosetta software suite and is made available under license.
5 # (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
6 # (c) For more information, see http://www.rosettacommons.org. Questions about this can be
7 # (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
8 
9 
10 ## @file exclude.py
11 ## @brief functions to exclude varios elements from Python buidings
12 ## @author Sergey Lyskov and William Sheffler
13 
14 import os, os.path, re, time, commands, sys
15 
16 
17 #if sys.platform != 'win32':
18 # import pyplusplus, pygccxml
19 # from pyplusplus.module_builder import call_policies
20 
21 
22 MAKE_SURE_IS_COPYABLE = [
23  "core::conformation::Residue",
24 ]
25 
26 _SconsFiles = []
27 
28 def isFileInScons(fname):
29  #print 'isFileInScons', fname, ' --> ', fname in _SconsFiles
30  if not _SconsFiles:
31  all_scons_files = [f for f in commands.getoutput('ls *.src.settings').split() if f not in ['apps.src.settings', 'devel.src.settings', 'pilot_apps.src.settings']]
32  for scons_file in all_scons_files:
33  f = file(scons_file).read(); exec(f)
34  for k in sources:
35  for f in sources[k]:
36  #all_sources.append( k + '/' + f + obj_suffix)
37  _SconsFiles.append( (k + '/' + f).replace('//', '/')) # some people don't know the right syntax for scons...
38  #print '_SconsFiles', _SconsFiles
39  return fname in _SconsFiles
40 
41 
42 BannedFiles = [
43  # tmp debug only
44  # 'protocols/features/AtomAtomPairFeatures.hh',
45  # 'protocols/features/AtomInResidueAtomInResiduePairFeatures.hh',
46  # 'protocols/features/HBondFeatures.hh',
47  # 'protocols/features/PairFeatures.hh',
48  # 'protocols/features/ProteinBackboneAtomAtomPairFeatures.hh',
49  # 'protocols/features/ResidueBurialFeatures.hh',
50  # 'protocols/features/ResidueScoresFeatures.hh',
51  # 'protocols/features/RotamerFeaturesCreator.hh',
52  # 'protocols/features/ScoreFunctionFeatures.hh',
53  # 'protocols/features/ScoreTypeFeatures.hh',
54  # 'protocols/features/ScoreTypeFeatures.hh',
55 
56  # 'protocols/features/RotamerFeatures.hh', # array with negative size
57 
58  # Temporary, remove after transition to SP
59  'utility/query', 'core/coarse',
60 
61 
62  'utility/py/PyHelper.hh', 'utility/keys', 'utility/options', 'utility/options/keys',
63  #'utility/pointer', 'utility/pointer/boost', 'utility/pointer/std',
64  #'utility/pointer/std', 'utility/pointer/refcount',
65  'basic/options/keys', 'utility/exit.hh',
66  'numeric/xyzVector.hh',
67 
68  'numeric/PCA.hh', 'numeric/linear_algebra/GeneralizedEigenSolver.hh', 'protocols/forge/remodel/RemodelGlobalFrame.hh', 'protocols/forge/remodel/RemodelLoopMover.hh',
69  'protocols/simple_filters/RepeatParameterFilter.hh',
70  # ^^^ direct Eigen includes
71 
72  #'basic/Tracer.hh',
73  'core/scoring/etable/BaseMembEtableEnergy.hh', # abandoned?
74  'core/scoring/etable/CoarseEtableEnergyCreator.hh', # not in scons (.hh only)
75  'core/scoring/memb_etable/BaseMembEtableEnergy.hh', # abandoned?
76  'core/scoring/rna/RNA_FA_Stack.hh', # not in scons (.hh only)
77  'core/scoring/methods/GaussianOverlapEnergyCreator.hh', # not in scons
78 
79  'core/scoring/fiber_diffraction/FiberDiffractionEnergyGpuCreator.hh',
80  'core/scoring/fiber_diffraction/FiberDiffractionEnergyGpu.hh',
81  'core/scoring/fiber_diffraction/FiberDiffractionKernelGpu.hh',
82 
83  'protocols/forge/remodel/RemodelLoopMoverCreator.hh',
84  #'protocols/toolbox/task_operations/RestrictToMoveMapChiOperationCreator.hh',
85 
86  #'core/pack/dunbrack/DunbrackRotamer.hh', # too many template args (more then 48)
87 
88  'protocols/abinitio/JumpingFoldConstraints.hh', # not in scons (.hh only)
89  'protocols/boinc',
90  'protocols/filters/RGFilterCreator.hh', # not in scons
91  'protocols/flxbb/InterlockAromaCreator.hh', # not in scons
92  'protocols/moves/ChangeFoldTreeMover.hh', # not in scons
93 
94  'protocols/jd2/MultiThreadingJob.hh', # Linker errors, neeed somefunction to be explicitly defined
95 
96  #'protocols/jd2/JD2ResourceManagerInputterCreator.hh', # not in scons
97 
98  'protocols/canonical_sampling/mc_convergence_checks/MPIBPool_ConvergenceCheck.hh', # not in scons, MPI only
99  'protocols/canonical_sampling/mc_convergence_checks/MPIHPool_ConvergenceCheck.hh', # not in scons, MPI only
100  'protocols/canonical_sampling/mc_convergence_checks/MPIPool_ConvergenceCheck.hh', # not in scons, MPI only
101 
102  'protocols/moves/ReportToDB.hh', # need sqlite3, not sure if we need it...
103 
104  # The following removed until JD3 comes online
105  'protocols/jd3',
106  'protocols/jd3/job_distributors',
107  'protocols/jd3/pose_inputters',
108  'protocols/jd3/pose_outputters',
109  'protocols/jd3/MoverAndPoseJob.hh',
110  'protocols/jd3/JobDistributor.fwd.hh',
111  'protocols/jd3/LarvalJob.fwd.hh',
112  'protocols/jd3/pose_outputters/PDBPoseOutputter.hh',
113  'protocols/jd3/pose_outputters/PDBPoseOutputter.fwd.hh',
114  'protocols/jd3/PoseOutputter.fwd.hh',
115  'protocols/jd3/PoseInputter.hh',
116  'protocols/jd3/pose_inputters/PDBPoseInputter.hh',
117  'protocols/jd3/pose_inputters/PDBPoseInputter.fwd.hh',
118  'protocols/jd3/pose_inputters/util.hh',
119  'protocols/jd3/pose_inputters/SilentFilePoseInputter.hh',
120  'protocols/jd3/PoseInputterFactory.hh',
121  'protocols/jd3/StandardJobQueen.fwd.hh',
122  'protocols/jd3/JobResult.hh',
123  'protocols/jd3/MoverAndPoseJob.fwd.hh',
124  'protocols/jd3/SilentFilePoseInputter.hh',
125  'protocols/jd3/JobDistributor.hh',
126  'protocols/jd3/job_distributors/MultiThreadedJobDistributor.hh',
127  'protocols/jd3/job_distributors/MPIWorkPartitionJobDistributor.hh',
128  'protocols/jd3/job_distributors/MPIWorkPoolJobDistributor.hh',
129  'protocols/jd3/JobOutputWritter.hh',
130  'protocols/jd3/PoseInputSource.hh',
131  'protocols/jd3/InnerLarvalJob.fwd.hh',
132  'protocols/jd3/Job.hh',
133  'protocols/jd3/PoseOutputter.hh',
134  'protocols/jd3/PoseInputSource.fwd.hh',
135  'protocols/jd3/Job.fwd.hh',
136  'protocols/jd3/JobDistributorFactory.fwd.hh',
137  'protocols/jd3/PoseInputter.fwd.hh',
138  'protocols/jd3/InnerLarvalJob.hh',
139  'protocols/jd3/JobQueen.hh',
140  'protocols/jd3/JobQueen.fwd.hh',
141  'protocols/jd3/StandardJobQueen.hh',
142  'protocols/jd3/JobResult.fwd.hh',
143  'protocols/jd3/JobDistributorFactory.hh',
144  'protocols/jd3/LarvalJob.hh',
145 
146 
147  'protocols/swa/rna/StepWiseRNA_Classes.hh', # not in scons (.hh only)
148 
149  'protocols/viewer', # OpenGL
150  'protocols/star', # void* StarAbinitio_main(void*); etc
151 
152  #'protocols/wum/WorkUnitManager.hh', # strange linker errors, will deal with it later
153 
154  #'protocols/toolbox/task_operations/RestrictToInterfaceCreator.hh', # not in scons?
155  #we need -DBOOST_NO_INITIALIZER_LISTS or gccxml choke on protocols/genetic_algorithm/GeneticAlgorithm.hh
156 
157  'utility/vectorL.hh', # problem with friend 'swap' functions, definition need to me moved out of class
158  'numeric/kdtree/WrappedType.hh', # Duplicate class name!
159 
160  'protocols/simple_moves/SymmetricFragmentMover.hh', # Somthing with linking/clang (gcc work fine)
161 
162 
163  'utility/io', #/ozstream.hh', # need bindings for std enum: std::_Ios_Openmode
164  'utility/sql_database/DatabaseSessionManager.hh', # SQLite have its own bindigs in Python
165 
166  'protocols/nonlocal/DistributionSampler.hh', # Seems to be abandoned
167 
168  # RELEASE exclude's. Do not remove them until got confirmation from the developers.
169  'protocols/qsar', # requested by Sam DeLuca
170  'protocols/qsar/scoring_grid', # requested by Sam DeLuca
171  'protocols/noesy_assign', # requested by Oliver
172 
173  'protocols/nonlocal/Chunk.hh', # Problem with GCCXML on GCC 4.0
174  'protocols/nonlocal',
175 
176  'protocols/medal/MedalMain.hh', # void* (void*) declaration
177 
178  #'protocols/rpc', # Some problem with parser, but in general: do we need RPC calls in PyRosetta? (it easier to implement it in Python anyway)
179 
180 
181 #'numeric/xyzTransform.hh',
182 
183 # 'protocols/sic_dock/RigidScore.hh',
184 # 'protocols/sic_dock/Rose.hh',
185 # 'protocols/sic_dock/SICFast.hh',
186 # 'protocols/sic_dock/designability_score.hh',
187 # 'protocols/sic_dock/loophash_util.hh',
188 # 'protocols/sic_dock/read_biounit.hh',
189 # 'protocols/sic_dock/types.hh',
190 # 'protocols/sic_dock/util.hh',
191 # 'protocols/sic_dock/xyzStripeHashPose.hh',
192 # 'protocols/sic_dock/xyzStripeHashPoseWithMeta.hh',
193 
194  #'protocols/frag_picker', # whole dir not in scons (ie been moved now), temporary
195 
196 # Lion workarround
197  # problem with gccxml using gcc 4.2.1 ???
198  #'utility/signals',
199  #'numeric/random', # problem with interger been too large (gccxml)
200 '''
201  'numeric/random/DistributionSampler.hh', # problem with interger been too large (gccxml) #include <boost/math/distributions.hpp>
202 
203 
204  'core/io/silent/ProteinSilentStruct.tmpl.hh',
205 
206 'core/io/silent/BinaryProteinSilentStruct.hh',
207 'core/io/silent/BinaryRNASilentStruct.hh',
208 'core/io/silent/ProteinSilentStruct.hh',
209 '''
210 
211 
212 ]
213 
214 def isBanned(fname):
215  ''' Check if given path or file name is banned from PyRosetta
216  '''
217  if fname in BannedFiles: return True
218  elif fname.endswith('.hh') and os.path.isfile(fname[:-3]+'.cc'): # Aha! Cpp file present... let's check if it in scons...
219  return not isFileInScons(fname[:-3])
220  else: return False
221 
222 
223 def namespace(ns):
224  ''' check if namespace 'ns' should be excluded from generating any bindings.
225  This function also exclude all unrelated folders like .svn
226  '''
227  nslist = [
228  'utility/excn',
229  'numeric/deriv',
230  'numeric/geometry',
231  'numeric/internal',
232  'numeric/interpolation',
233  'numeric/interpolation/full',
234  'numeric/interpolation/periodic_range/full',
235  'numeric/interpolation/periodic_range/half',
236  'numeric/interpolation/periodic_range/periodic_value/full',
237  'numeric/interpolation/periodic_range/periodic_value/half',
238  'numeric/SVD',
239  'numeric/model_quality',
240  'numeric/kdtree',
241  'core/conformation/signals',
242  'core/options',
243  'core/options/keys',
244  'core/fragment/io',
245  'core/fragment/picking/concepts',
246  'core/fragment/picking/vall/eval',
247  'core/fragment/picking/vall/scores',
248  #'core/fragment',
249  'core/coarse', #??? new for 1 file scheme
250  'core/scoring/NV',
251 
252  'core/scoring/disulfides',
253  'core/scoring/carbon_hbonds',
254  #'core/scoring/hbonds',
255  'core/scoring/hbonds/hbtrie',
256  'core/scoring/dunbrack',
257  'core/scoring/elec',
258  'core/scoring/etable',
259  'core/scoring/etable/count_pair',
260  'core/scoring/etable/etrie',
261  'core/scoring/geometric_solvation',
262  'core/scoring/packstat',
263  'core/scoring/packing',
264  'core/scoring/symE',
265  #'core/scoring/constraints', # temp
266 
267  'core/io/raw_data',
268  'basic/database',
269  'core/io/sequence_comparation',
270  'core/io/serialization',
271  'core/io/silent',
272  'core/util',
273  'core/pack/interaction_graph',
274  'core/pack/rotamer_set',
275  #'core/pack/annealer',
276  'core/pose/signals',
277  'core/scoring/rna',
278 
279  #'protocols/abinitio',
280  'protocols/boinc',
281  'protocols/branch_angle',
282  'protocols/checkpoint',
283  'protocols/cluster',
284  'protocols/comparative_modeling',
285  'protocols/ddg',
286  'protocols/enzdes',
287  'protocols/evaluation',
288  'protocols/filters',
289  'protocols/flexpack',
290  'protocols/flexpack/rotamer_set',
291  'protocols/frags',
292  'protocols/jd2',
293  'protocols/jd2/archive',
294  'protocols/geometry',
295  'protocols/genetic_algorithm',
296  'protocols/hotspot_hashing',
297  'protocols/jobdist',
298  'protocols/jumping',
299  'protocols/looprelax',
300  #'protocols/loops',
301  'protocols/ligand_docking/ligand_options',
302  'protocols/motifs',
303  'protocols/moves/kinematic_closure',
304  'protocols/multistate_design',
305  'protocols/optimize_weights',
306  'protocols/protein_interface_design',
307  'protocols/rbsegment_Moves',
308  'protocols/rna',
309  'protocols/dna',
310  'protocols/rna_denovo',
311  'protocols/smanager',
312  'protocols/toolbox',
313  'protocols/toolbox/PoseMetricCalculators',
314  'protocols/viewer',
315  'protocols/topology_broker/weights',
316  'protocols/mpi',
317  'protocols/protein_interface_design/movers',
318 
319  'utility/boinc',
320  'utility/io',
321  'utility/query',
322  'utility/factory',
323  'utility/options',
324  'utility/options/keys',
325  'utility/keys',
326  'utility/tools',
327  'utility/signals',
328 
329  ]
330  if ns.find('.svn') >= 0: return True
331  return ns in nslist
332 
333 
334 exclude_header_list = []
335 
336 
337 def mb_exclude(path, mb, hfile):
338  def E(*args):
339  obj = mb
340  fun = True
341  try:
342  for a in args:
343  if fun:
344  obj = obj.__getattribute__(a)
345  fun = False
346  else:
347  obj = obj(a)
348  fun = True
349  if not fun:
350  obj()
351 
352  except pygccxml.declarations.matcher.declaration_not_found_t: pass
353 
354  def E_(v):
355  obj = mb
356  try: eval(v)
357  except pygccxml.declarations.matcher.declaration_not_found_t: pass
358 
359 
360  if path == 'core/pose':
361  try:
362  pass
363  except pygccxml.declarations.matcher.declaration_not_found_t: pass
364 
365  if hfile == 'core/pose/util.hh':
366  mb.free_function("delete_comment").exclude()
367 
368 
369  if path == 'core/pose/metrics':
370  #mb.class_('PoseMetricCalculator').exclude() # Pure virtual class
371  pass
372 
373 
374  if path == 'core/chemical':
375  try: mb.class_("ResidueTypeSet").constructors().exclude() # default arg for ctor causes problems
376  except pygccxml.declarations.matcher.declaration_not_found_t: pass
377 
378 
379  if path == 'core/conformation':
380  #t = mb.classes( lambda decl: decl.name.startswith( 'impl' ) )
381  def fff(name):
382  if name.find( 'std::map<core::id::StubID,core::kinematics::RT') >= 0: return True
383  else: return False
384 
385  try:
386  mb.class_("Conformation").mem_funs('insert_fragment').exclude()
387  #mb.class_("Conformation").mem_funs('res_begin').exclude() -- apl note: removing this member function; so commenting out this line
388  #mb.class_("Conformation").mem_funs('res_end').exclude() -- apl note: removing this member function; so commenting out this line
389  #mb.class_("Conformation").mem_funs('get_stub_transform').exclude()
390 
391  except pygccxml.declarations.matcher.declaration_not_found_t: pass
392 
393  if hfile=='core/conformation/Residue.hh':
394  residue = mb.class_( 'Residue' )
395  residue.add_registration_code( 'def( bp::self_ns::str( bp::self ) )' )
396 
397  if hfile=='core/conformation/Atom.hh':
398  residue = mb.class_( 'Atom' )
399  residue.add_registration_code( 'def( bp::self_ns::str( bp::self ) )' )
400 
401 
402  if path == 'core/fragment':
403  if hfile=='core/fragment/FragID_Iterator.hh':
404  mb.class_("FragID_Iterator").exclude()
405 
406  if hfile=='core/fragment/util.hh':
407  mb.free_function("flatten_list").exclude() # 'undefined symbol' error on python import
408 
409  if hfile=='core/fragment/FragData.hh':
410  def pr(x):
411  print x
412  print " access_type:", x.access_type
413  return True
414  # FragData( Size nr_res ) <-- private
415  #mb.class_("FragData").constructor(arg_types=['platform::Size']).exclude()
416  for c in mb.class_("FragData").constructors(lambda x: pr(x)):
417  if c.access_type == 'protected': c.exclude()
418  #print c
419 
420 
421  #E_(" mb.class_('SecstructSRFD').mem_funs('clone').exclude() ")
422 
423  #E('class_', "BBTorsionSRFD", 'mem_funs', "clone", 'exclude') # mb.class_("BBTorsionSRFD").mem_funs("clone").exclude()
424 
425 
426  if path == 'core/graph':
427  #mb.class_("PointGraphVertexData").var('NUM_EDGES_TO_RESERVE').exclude() # static const
428  E('class_', "PointGraphVertexData", 'var', 'NUM_EDGES_TO_RESERVE', 'exclude' ) # static const
429 
430 
431  if path == 'core/kinematics':
432  #mb.class_("Edge").var('PEPTIDE').exclude()
433  E('class_', "Edge", 'var', 'PEPTIDE', 'exclude')
434  #mb.class_("Edge").var('CHEMICAL').exclude()
435  E('class_', "Edge", 'var', 'CHEMICAL', 'exclude')
436 
437  if hfile == 'core/kinematics/MoveMap.hh':
438  #mb.class_('MoveMap').member_function('find').exclude()
439  mb.class_('MoveMap').mem_funs('find').exclude()
440 
441 
442  if hfile == 'core/kinematics/FoldTree.hh':
443  cl = mb.class_( 'FoldTree' )
444  cl.add_registration_code( 'def( bp::self_ns::str( bp::self ) )' )
445 
446  if hfile == 'core/kinematics/Jump.hh':
447  #E('free_function', "distance", 'exclude')
448  mb.free_functions("distance").exclude()
449  #mb.class_('Jump').mem_funs('distance').exclude()
450 
451 
452  if path == 'core/kinematics/tree':
453  #mb.class_('BondedAtom').member_function('clone').exclude()
454  E('class_', 'BondedAtom', 'member_function', 'clone', 'exclude')
455  #mb.class_('JumpAtom').member_function('clone').exclude()
456  E('class_', 'JumpAtom', 'member_function', 'clone', 'exclude')
457 
458  if hfile == 'core/kinematics/tree/Atom.hh':
459  mb.free_functions("distance").exclude()
460  mb.free_functions("distance_squared").exclude()
461 
462 
463  if path == 'core/pack':
464  if hfile == 'core/pack/pack_rotamers.hh':
465  #E('free_function', "pack_rotamers_run", 'exclude')
466  #fns = mb.free_function("pack_rotamers_run")
467  #for f in fns: f.exclude()
468  #mb.free_function("pack_rotamers_run", return_type="core::Real").exclude()
469  mb.free_functions("pack_rotamers_run").exclude()
470  #print 'QQQ', mb.free_functions("pack_rotamers_run")
471  #print '______________________________'
472 
473  #f = mb.free_function('symmetric_pack_rotamers_run')
474  #print f, dir(f)
475  #print 'Retutn type:', f.return_type
476 
477  E('free_function', 'symmetric_pack_rotamers_run', 'exclude')
478 
479 
480  if path == 'core/pack/task':
481  try:
482  #mb.class_("IGEdgeReweighter").exclude()
483  mb.class_("IGEdgeReweightContainer").mem_funs("reweighters_begin").exclude()
484  mb.class_("IGEdgeReweightContainer").mem_funs("reweighters_end").exclude()
485 
486  except pygccxml.declarations.matcher.declaration_not_found_t: pass
487 
488 
489  if path == 'core/pack/task/operation':
490  try:
491  mb.class_("ResFilterFactory").mem_funs("newResFilter").exclude()
492 
493  except pygccxml.declarations.matcher.declaration_not_found_t: pass
494 
495  E('class_', 'TaskOperationFactory', 'member_function', 'newTaskOperation', 'exclude')
496 
497 
498  if path == 'core/import_pose':
499  if hfile=='core/import_pose/import_pose.hh':
500  #E('free_functions', 'pose_from_pose', 'exclude')
501  pass
502 
503 
504  if path == 'core/pose':
505  pass
506  #if hfile=='core/pose/Pose.hh':
507  # residue = mb.class_( 'Pose' )
508  # residue.add_registration_code( 'def( bp::self_ns::str( bp::self ) )' )
509 
510 
511  if path == 'core/scoring':
512  #mb.class_( "ResidueNeighborIterator" ).exclude() # pure virtual class, can't be created
513  E('class_', "ResidueNeighborIterator", 'exclude')
514  #mb.class_( "ResidueNeighborConstIterator" ).exclude() # pure virtual class, can't be created
515  E('class_', "ResidueNeighborConstIterator", 'exclude') # pure virtual class, can't be created
516 
517  try:
518  mb.class_("ScoreFunction").mem_funs("long_range_energies_begin").exclude()
519  mb.class_("ScoreFunction").mem_funs("long_range_energies_end").exclude()
520  mb.class_("ScoreFunction").mem_funs("cd_2b_intrares_begin").exclude()
521  mb.class_("ScoreFunction").mem_funs("cd_2b_intrares_end").exclude()
522  mb.class_("ScoreFunction").mem_funs("ci_2b_intrares_begin").exclude()
523  mb.class_("ScoreFunction").mem_funs("ci_2b_intrares_end").exclude()
524  mb.class_("ScoreFunction").mem_funs("all_energies_begin").exclude()
525  mb.class_("ScoreFunction").mem_funs("all_energies_end").exclude()
526 
527  mb.class_("ScoreFunction").mem_funs("ci_lr_2b_methods_begin").exclude()
528  mb.class_("ScoreFunction").mem_funs("ci_lr_2b_methods_end").exclude()
529  mb.class_("ScoreFunction").mem_funs("cd_lr_2b_methods_begin").exclude()
530  mb.class_("ScoreFunction").mem_funs("cd_lr_2b_methods_end").exclude()
531 
532  mb.class_("ScoreFunction").mem_funs("ws_methods_begin").exclude()
533  mb.class_("ScoreFunction").mem_funs("ws_methods_end").exclude()
534 
535  except pygccxml.declarations.matcher.declaration_not_found_t: pass
536 
537  try:
538  mb.class_("EMapVector").mem_funs("begin").exclude() # these aren't real iterators... just Real*'s
539  mb.class_("EMapVector").mem_funs("end").exclude()
540  except pygccxml.declarations.matcher.declaration_not_found_t: pass
541 
542  try:
543  mb.class_("TwoBodyEMapVector").mem_funs("begin").exclude() # these aren't real iterators... just Real*'s
544  mb.class_("TwoBodyEMapVector").mem_funs("end").exclude()
545  except pygccxml.declarations.matcher.declaration_not_found_t: pass
546 
547  if hfile=='core/scoring/ScoreFunction.hh':
548  scorefnx = mb.class_( 'ScoreFunction' )
549  scorefnx.add_registration_code( 'def( bp::self_ns::str( bp::self ) )' )
550 
551  if hfile=='core/scoring/Energies.hh':
552  Energies = mb.class_( 'Energies' )
553  Energies.add_registration_code( 'def( bp::self_ns::str( bp::self ) )' )
554 
555  if hfile=='core/scoring/ScoringManager.hh':
556  mb.class_("ScoringManager").mem_fun("get_DDPLookupTable").exclude() # for some reason boost look up this function in core::conformation instead of core::scoring
557 
558 
559  if path == 'core/scoring/constraints':
560  E('class_', 'CircularHarmonicFunc', 'member_function', 'clone', 'exclude') #mb.class_('CircularHarmonicFunc').member_function('clone').exclude()
561  E('class_', 'CircularPowerFunc', 'member_function', 'clone', 'exclude') #mb.class_('CircularPowerFunc').member_function('clone').exclude()
562  E('class_', 'CharmmPeriodicFunc', 'member_function', 'clone', 'exclude') #mb.class_('CharmmPeriodicFunc').member_function('clone').exclude()
563 
564  E('class_', 'GaussianFunc', 'member_function', 'clone', 'exclude') #mb.class_('GaussianFunc').member_function('clone').exclude()
565  try: mb.class_('HarmonicFunc').member_function('clone').exclude()
566  except pygccxml.declarations.matcher.declaration_not_found_t: pass
567  try: mb.class_('MixtureFunc').member_function('clone').exclude()
568  except pygccxml.declarations.matcher.declaration_not_found_t: pass
569  try: mb.class_('ScalarWeightedFunc').member_function('clone').exclude()
570  except pygccxml.declarations.matcher.declaration_not_found_t: pass
571 
572  try: mb.class_('BoundFunc').member_function('clone').exclude()
573  except pygccxml.declarations.matcher.declaration_not_found_t: pass
574  try: mb.class_('ConstantFunc').member_function('clone').exclude()
575  except pygccxml.declarations.matcher.declaration_not_found_t: pass
576  try: mb.class_('EtableFunc').member_function('clone').exclude()
577  except pygccxml.declarations.matcher.declaration_not_found_t: pass
578  try: mb.class_('PeriodicBoundFunc').member_function('clone').exclude()
579  except pygccxml.declarations.matcher.declaration_not_found_t: pass
580  try: mb.class_('PeriodicFunc').member_function('clone').exclude()
581  except pygccxml.declarations.matcher.declaration_not_found_t: pass
582 
583  try: mb.class_('MultiConstraint').exclude()
584  except pygccxml.declarations.matcher.declaration_not_found_t: pass
585  try: mb.class_('Constraint').exclude()
586  except pygccxml.declarations.matcher.declaration_not_found_t: pass
587 
588 
589  if path == 'core/scoring/electron_density':
590  if hfile == 'core/scoring/electron_density/util.hh':
591  #mb.free_function('alignVectorSets').exclude()
592  pass
593 
594  if path == 'core/scoring/hbonds':
595  if hfile == "__core/scoring/hbonds/HBondSet.hh":
596  try:
597  l = mb.decls("get_residue_residue_hbond_energy")
598  for i in l: i.exclude()
599  except pygccxml.declarations.matcher.declaration_not_found_t: pass
600 
601  if hfile == 'core/scoring/hbonds/HBondEnergy.hh':
602  #core::scoring::hbonds::HBondEnergy::evaluate_rotamer_pair_energies
603  E('class_', "HBondEnergy", 'member_function', "evaluate_rotamer_pair_energies", 'exclude')
604 
605  if hfile == 'core/scoring/hbonds/types.hh':
606  mb.free_function('HBEval_lookup_initializer').exclude()
607  mb.var('HBEval_lookup').exclude()
608 
609 
610  if path == 'core/scoring/rna':
611  E('class_', "RNA_TorsionEnergy", 'member_function', "indicate_required_context_graphs", 'exclude') #mb.class_( "RNA_TorsionEnergy" ).member_function( "indicate_required_context_graphs" ).exclude()
612 
613 
614  if path == 'core/scoring/methods':
615  try: mb.class_('ChainbreakEnergy').member_function('clone').exclude()
616  except pygccxml.declarations.matcher.declaration_not_found_t: pass
617 
618  try: mb.class_('DistanceChainbreakEnergy').member_function('clone').exclude()
619  except pygccxml.declarations.matcher.declaration_not_found_t: pass
620 
621  try: mb.class_('LinearChainbreakEnergy').member_function('clone').exclude()
622  except pygccxml.declarations.matcher.declaration_not_found_t: pass
623 
624  try: mb.class_('MMBondAngleEnergy').member_function('indicate_required_context_graphs').exclude()
625  except pygccxml.declarations.matcher.declaration_not_found_t: pass
626  try: mb.class_('MMTorsionEnergy').member_function('indicate_required_context_graphs').exclude()
627  except pygccxml.declarations.matcher.declaration_not_found_t: pass
628  try: mb.class_('OmegaTetherEnergy').member_function('indicate_required_context_graphs').exclude()
629  except pygccxml.declarations.matcher.declaration_not_found_t: pass
630  try: mb.class_('P_AA_pp_Energy').member_function('indicate_required_context_graphs').exclude()
631  except pygccxml.declarations.matcher.declaration_not_found_t: pass
632  try: mb.class_('RMS_Energy').member_function('indicate_required_context_graphs').exclude()
633  except pygccxml.declarations.matcher.declaration_not_found_t: pass
634  try: mb.class_('DunbrackEnergy').member_function('indicate_required_context_graphs').exclude()
635  except pygccxml.declarations.matcher.declaration_not_found_t: pass
636  try: mb.class_('RamachandranEnergy').member_function('indicate_required_context_graphs').exclude()
637  except pygccxml.declarations.matcher.declaration_not_found_t: pass
638  try: mb.class_('ReferenceEnergy').member_function('indicate_required_context_graphs').exclude()
639  except pygccxml.declarations.matcher.declaration_not_found_t: pass
640  try: mb.class_('WaterAdductHBondEnergy').member_function('indicate_required_context_graphs').exclude()
641  except pygccxml.declarations.matcher.declaration_not_found_t: pass
642  try: mb.class_('WaterAdductIntraEnergy').member_function('indicate_required_context_graphs').exclude()
643  except pygccxml.declarations.matcher.declaration_not_found_t: pass
644 
645  #mb.class_('RG_Energy').member_function('clone').exclude() # 'undefinded' error in Python, not in scons
646 
647 
648  if path == 'core/scoring/trie':
649  E('class_', 'TrieCollection', 'member_function', 'clone', 'exclude') #mb.class_('TrieCollection').member_function('clone').exclude()
650 
651 
652  if path == 'core/sequence':
653  try: mb.class_("L1ScoringScheme").mem_funs("clone").exclude()
654  except pygccxml.declarations.matcher.declaration_not_found_t: pass
655  try: mb.class_("L1ScoringScheme").mem_funs("score").exclude()
656  except pygccxml.declarations.matcher.declaration_not_found_t: pass
657  try: mb.class_("MatrixScoringScheme").mem_funs("clone").exclude()
658  except pygccxml.declarations.matcher.declaration_not_found_t: pass
659  try: mb.class_("MatrixScoringScheme").mem_funs("score").exclude()
660  except pygccxml.declarations.matcher.declaration_not_found_t: pass
661 
662  try: mb.class_("ProfSimScoringScheme").mem_funs("clone").exclude()
663  except pygccxml.declarations.matcher.declaration_not_found_t: pass
664  try: mb.class_("ProfSimScoringScheme").mem_funs("score").exclude()
665  except pygccxml.declarations.matcher.declaration_not_found_t: pass
666 
667  try: mb.class_("SequenceProfile").mem_funs("clone").exclude()
668  except pygccxml.declarations.matcher.declaration_not_found_t: pass
669 
670  try: mb.class_("SimpleScoringScheme").mem_funs("clone").exclude()
671  except pygccxml.declarations.matcher.declaration_not_found_t: pass
672  try: mb.class_("SimpleScoringScheme").mem_funs("score").exclude()
673  except pygccxml.declarations.matcher.declaration_not_found_t: pass
674 
675 
676  if path == 'protocols/abinitio':
677  #mb.decl('::std::vector< core::pose::Pose >').exclude()
678  #mb.decl('PoseList').exclude()
679  if hfile == 'protocols/abinitio/ConstraintFragmentMover.hh':
680  mb.class_('ConstraintFragmentMover').mem_funs("choose_fragment").exclude()
681 
682  if hfile == 'protocols/abinitio/KinematicAbinitio.hh':
683  mb.class_('JumpingFoldConstraintsWrapper').mem_funs("register_options").exclude()
684 
685  if hfile == 'protocols/abinitio/KinematicControl.hh':
686  mb.class_('KinematicControl').mem_funs("remove_chainbreak_variants").exclude()
687 
688  #if hfile == 'protocols/abinitio/ConstraintFragmentMover.hh':
689  # removeProtectedConstructos(mb, "ConstraintFragmentMover")
690 
691 
692  if path == 'protocols/branch_angle':
693  mb.free_function("bonded_neighbor_all_res").exclude()
694 
695 
696  if path == 'protocols/docking':
697  if hfile == 'protocols/docking/DockingProtocol.hh':
698  mb.class_('DockingProtocol').mem_funs("show").exclude()
699  #mb.class_('DockingProtocol').mem_funs("DockingProtocol").exclude()
700  mb.class_('DockingProtocol').constructors().exclude()
701 
702  #c = mb.class_('DockingProtocol').constructors()
703  #c[1].exclude()
704  #c[0].exclude()
705  #c[0].exclude()
706 
707  if hfile == 'protocols/docking/DockingLowRes.hh':
708  mb.class_('DockingLowRes').mem_fun("show").exclude()
709 
710 
711  if path == 'protocols/dna':
712  mb.class_('PDBOutput').operator("()").exclude()
713 
714 
715  if path == 'protocols/jobdist':
716  if hfile == 'protocols/jobdist/standard_mains.hh':
717  mb.free_function("main_plain_mover").exclude()
718  mb.free_function("main_atomtree_diff_mover").exclude()
719  mb.free_function("main_plain_pdb_mover").exclude()
720 
721 
722  if path == 'protocols/ligand_docking':
723  pass
724  #mb.free_function("set_sphere").exclude()
725 
726 
727  if path == 'protocols/moves':
728  if hfile == 'protocols/moves/Mover.hh':
729  #mb.class_('Mover').member_function('parse_tag').exclude()
730  mb.class_('Mover').member_function('parse_my_tag').exclude()
731 
732  if hfile == 'protocols/simple_moves/PackRotamersMover.hh':
733  mb.class_('PackRotamersMover').member_function('run').exclude() # Template problem
734 
735  #if hfile == 'protocols/moves/WobbleMover.hh':
736  # mb.class_( "WobbleMover" ).exclude() # Some constructors not defined
737 
738  if hfile == 'protocols/moves/SwitchResidueTypeSetMover.hh':
739  c = mb.class_( 'SwitchResidueTypeSetMover' )
740  c.add_registration_code( 'def( bp::self_ns::str( bp::self ) )' )
741 
742  if hfile == 'protocols/moves/ScoreMover.hh':
743  #print dir(mb.class_("ScoreMover"))
744  mb.class_("ScoreMover").member_function('register_options').exclude() # static function
745 
746 
747  #if path == 'protocols/rna':
748  # mb.class_('RNA_SecStructInfo').member_function('clone').exclude()
749 
750 
751  #if path == 'protocols/loops':
752  # if hfile == 'protocols/loops/LoopClosure.hh':
753  # removeProtectedConstructos(mb, "LoopClosure")
754 
755  #for c in mb.class_("LoopClosure").constructors(lambda x: x.access_type == 'protected'):
756  # c.exclude()
757 
758 
760  # isabs = False
761  # for b in c.bases:
762  # b = b.related_class
763  # if not b.is_abstract and not b.is_wrapper_needed(): continue
764  # print c
765  # print b
766  # assert namespace_of(b) is namespace_of(c)
767  # make_nonvirtual(b)
768  for mf in c.calldefs(allow_empty=True):
769  # if mf.virtuality
770  mf.virtuality = pyplusplus.decl_wrappers.declarations.VIRTUALITY_TYPES.NOT_VIRTUAL
771  c._redefined_funcs = []
772  c.is_abstract = c.__WAS_ABSTRACT
773  c.__NEEDS_NO_INIT = True
774  c.__IS_HACKED_NONVIRTUAL = True
775  if c.is_abstract:
776  c.constructors(allow_empty=True,recursive=False).exclude()
777  if c.is_wrapper_needed():
778  print "NONVIRTUAL'ized still needs wrapper",c
779  print c.is_wrapper_needed()
780  assert False
781 
782 
784  try:
785  for c in mb.classes():
786  for f in c.constructors(lambda x: x.access_type == 'protected', allow_empty=True):
787  f.exclude()
788  except RuntimeError: pass
789 
790  #for f in mb.class_(class_name).constructors(lambda x: x.access_type == 'protected'):
791  #f.exclude()
792 
794  try:
795  for c in ns.classes(allow_empty=True,recursive=False):
796  for f in c.protected_members: f.exclude()
797  for f in c.private_members: f.exclude()
798  except RuntimeError: pass
799 
800 
802  for c in ns.classes(allow_empty=True,recursive=False):
803  for o in ns.operators(allow_empty=True,recursive=False):
804  if o.name == 'operator<<' and len(o.argument_types) == 2 and \
805  str(o.argument_types[0]) == 'std::ostream &' and \
806  '::' + str(o.argument_types[1]) == c.decl_string + ' const &':
807  print 'Adding print operator for:', c.decl_string
808  c.add_registration_code( 'def( bp::self_ns::str( bp::self ) )' )
809 
810  #print 'str(o.argument_types[1])', str(o.argument_types[1])
811 
812  #print o, dir(o)
813  #print 'name:', o.name
814  #print 'argument_types', dir(o.argument_types[0]), ' ~~~ ', o.argument_types[0], str(o.argument_types[0]) == 'std::ostream &'
815  #print 'decl_string', o.argument_types[0].decl_string(), ' partial_decl_string', o.argument_types[0].partial_decl_string()
816  #print 'arguments', type(o.arguments[0]), ' ~~~ ', o.arguments[0]
817 
818 
819 def annotate(mb):
820  try:
821  for c in mb.classes():
822  c.__WAS_ABSTRACT = c.is_abstract
823  except RuntimeError: pass
824 
825 
826 def getNameSpace(path, mb):
827  nspath = path.replace("/","::")
828  nspath = nspath.replace("::::","::")
829  #if nspath in CONFIG.NAMESPACE_EXCLUDE: return
830  print "MAKING PACKAGE:",nspath
831  if nspath: ns = namespace_from_full_path(mb, nspath)
832  else: ns = mb.global_ns
833  assert ns
834 
835  return ns
836 
837 
838 def exclude(path, mb, hfile):
839  print "Manual excluding:", path
840  #mb_exclude(path, mb)
841  #return
842 
843  ns = getNameSpace(path, mb)
844  #ns = '::'.join( path.split('/') ) + ' [namespace]'
845  #print '~~~~~~~ Ns_old=%s Ns=%s Path=%s' % (ns_old, ns, path)
846 
848 
849  mb_exclude(path, mb, hfile)
850  #removeProtectedConstructos(mb)
852  add_print_operators(mb, ns)
853 
854  annotate(mb)
855  for c in ns.classes(allow_empty=True,recursive=False):
856  if c.is_wrapper_needed() or c.is_abstract:
857  make_nonvirtual(c)
858 
859 
860  #namespace_from_full_path(mb,"utility").classes(recursive=0,allow_empty=True),
861  #namespace_from_full_path(mb,"utility").free_funs(recursive=0,allow_empty=True),
862 
863 
864  exclude_impls_(mb,ns)
865  setup_held_type(mb,ns)
867 
868  #make_sure_is_copyable(mb,ns)
869 
870  mb._module_builder_t__registrations_code_tail = []
871  ic = make_implicitly_convertible(mb,ns)
872  if ic:
873  print '\nMaking Implicitly convertible:'
874  for i in ic: print i
875  mb.add_registration_code( "".join(ic) )
876 
877 
878 def exclude_impls_(mb,ns):
879  for c in ns.classes(allow_empty=True,recursive=False):
880  if c.decl_string.endswith("_"):
881  print "EXCLUDE IMPL_:",c.decl_string
882  c.exclude()
883 
884 
885 def setup_held_type(mb,ns):
886  for c in ns.classes(allow_empty=1,recursive=False):
887  if is_refcount(c):
888  if c.decl_string == u'::utility::pointer::ReferenceCount': continue # we cant hold our self...
889  #print "c.decl_string:", c.decl_string
890  # if c.held_type:
891  # if c.held_type.count("utility::pointer::owning_ptr"): continue
892  if c.is_abstract:
893  print 'Abstarct:', c.decl_string
894  if hasattr(c,'__IS_HACKED_NONVIRTUAL'):
895  c.held_type = "utility::pointer::owning_ptr< "+c.decl_string+" >"
896  elif len(c.is_wrapper_needed()) > 0:
897  #print "len(c.is_wrapper_needed()) > 0: c.decl_string:", c.decl_string
898  #pass #
899  #c.held_type = "utility::pointer::owning_ptr< "+c.wrapper_alias+" >"
900  print "~~ SET HELD TYPE OP",c , ' exportable?:', c.exportable
901  c.held_type = "utility::pointer::owning_ptr< "+c.decl_string+" >"
902 
903  else:
904  print "SET HELD TYPE OP",c
905  c.held_type = "utility::pointer::owning_ptr< "+c.decl_string+" >"
906 
907 
909  ic = []
910  for c in ns.classes(allow_empty=True):
911  if not c.held_type: continue
912  if not isinc(c): continue
913  print 'c.decl_string:', c.decl_string
914  if c.held_type.count("utility::pointer::owning_ptr") and c.decl_string != u'::utility::pointer::ReferenceCount':
915  tplt = "bp::implicitly_convertible< utility::pointer::owning_ptr< %s >\n"
916  tplt += " , utility::pointer::owning_ptr< %s > >();\n"
917  ic.append(tplt % ( c.decl_string,c.decl_string+" const") )
918  for b in get_class_bases(c):
919  print 'c, b:', c, b
920  if b is c: continue
921  #if not isinc(b):
922  # print 'isinc...'
923  # continue
924  if b.decl_string == u'::utility::pointer::ReferenceCount': continue
925  ic.append(tplt % ( c.decl_string,b.decl_string) )
926  #ic.append(tplt % ( c.decl_string,b.decl_string+" const") )
927  return ic
928 
930  for c in MAKE_SURE_IS_COPYABLE:
931  c = class_from_full_path(mb,c)
932  if c in ns.classes(allow_empty=True,recursive=True):
933  c.noncopyable = False
934 
935 
937  print 'set_default_call_policies'
938  for f in mb.calldefs().declarations:
939  f.create_with_signature = True
940  # if f.call_policies is None:
941  if not hasattr(f,'return_type') or not f.return_type: continue
942  rt = f.return_type
943  rtdecl = rt
944  if hasattr(rtdecl,'base'):
945  b = rt
946  while hasattr(b,'base'): b = b.base
947  if hasattr(b,'declaration'): rtdecl = b.declaration
948  rtbase = rt.decl_string.strip().rstrip("&").rstrip("*").strip()
949  if rtbase.endswith("const"): rtbase = rtbase[:-5].strip()
950  # if f.name == "default_value":
951  # print "\nDEFAULT_VALUE",rtbase
952  # print rt.decl_string
953  if rt.decl_string.endswith('&') and rtbase.split("::")[-1] in ("Real","int","float","Length","long","unsigned","Size","unsigned int","long unsigned int","size_t","string","Energy","double","char","DistanceSquared","Distance","bool","TorsionType","PackerEnergy"):
954  if rt.decl_string.count("const"):
955  # if f.name == "default_value": print "const"
956  f.call_policies = call_policies.return_value_policy( call_policies.copy_const_reference )
957  else:
958  # if f.name == "default_value": print "non-const"
959  f.call_policies = call_policies.return_value_policy( call_policies.copy_non_const_reference )
960  elif rt.decl_string.strip().endswith("&") or rt.decl_string.strip().endswith("*"):#if f.call_policies is None:
961  if isinstance(rtdecl,pyplusplus.decl_wrappers.enumeration_wrapper.enumeration_t):
962  if rt.decl_string.count('const'):
963  f.call_policies = call_policies.return_value_policy( call_policies.copy_const_reference )
964  else:
965  f.call_policies = call_policies.return_value_policy( call_policies.copy_non_const_reference )
966  else:
967  # if f.name == "default_value": print "ref"
968  f.call_policies = call_policies.return_value_policy( call_policies.reference_existing_object )
969 
970 
972  for c in ns.classes(allow_empty=True,recursive=False):
973  for f in c.protected_members: f.exclude()
974  for f in c.private_members: f.exclude()
975 
977  nowraper = map(lambda x: class_from_full_path(mb,x),CONFIG.DISALLOW_WRAPPERS)
978  for c in ns.classes(allow_empty=True,recursive=False):
979  if not c in nowraper: continue
980  print "\nEXCLUDE ABSTRACT!!!!!",c,'\n'
981  if c.is_abstract: c.exclude()
982  # for mf in c.calldefs(allow_empty=True,recursive=False):
983  # if mf.virtuality == pyplusplus.decl_wrappers.declarations.VIRTUALITY_TYPES.VIRTUAL:
984  # # print "OVERRIDE VIRTUALITY:",mf
985  # mf.virtuality = pyplusplus.decl_wrappers.declarations.VIRTUALITY_TYPES.NOT_VIRTUAL
986  # if c.is_wrapper_needed:
987  # c.is_wrapper_needed = []
988 
989 def make_nonvirtual(c):
990  # isabs = False
991  # for b in c.bases:
992  # b = b.related_class
993  # if not b.is_abstract and not b.is_wrapper_needed(): continue
994  # print c
995  # print b
996  # assert namespace_of(b) is namespace_of(c)
997  # make_nonvirtual(b)
998  for mf in c.calldefs(allow_empty=True):
999  # if mf.virtuality
1000  mf.virtuality = pyplusplus.decl_wrappers.declarations.VIRTUALITY_TYPES.NOT_VIRTUAL
1001  c._redefined_funcs = []
1002  c.is_abstract = c.__WAS_ABSTRACT
1003  c.__NEEDS_NO_INIT = True
1004  c.__IS_HACKED_NONVIRTUAL = True
1005  if c.is_abstract:
1006  c.constructors(allow_empty=True,recursive=False).exclude()
1007  if c.is_wrapper_needed():
1008  print "NONVIRTUAL'ized still needs wrapper",c
1009  print c.is_wrapper_needed()
1010  #assert False
1011  # ^^^ nah, thats ok
1012 
1013 
1014 def parse_full_name(full_name):
1015  pth = []#filter(len,full_class_name.split("::"))
1016  regex = re.compile("^([^<>, :]*)::")
1017  while regex.match(full_name):
1018  ns = regex.search(full_name).group(1) # print ns
1019  if ns:
1020  pth.append( ns )
1021  full_name = regex.sub("",full_name) # print full_name
1022  pth.append(full_name)
1023  pth = [x for x in pth if x]
1024  return pth
1025 
1026 def class_from_full_path(mb,fullname):
1027  path = parse_full_name(fullname)
1028  nspath,cname = path[:-1],path[-1]
1029  ns = mb.global_ns
1030  for nsname in nspath:
1031  for tmp in ns.namespaces(nsname):
1032  if tmp.parent is ns:
1033  ns = tmp
1034  return ns.class_(cname)
1035 
1036 def namespace_from_full_path(mb,fullname):
1037  nspath = parse_full_name(fullname)
1038  ns = mb.global_ns
1039  for nsname in nspath:
1040  #print 'namespace_from_full_path: ', nsname, ns
1041  ns = ns.namespace(nsname,recursive=False)
1042  return ns
1043 
1045  for cd in ns.calldefs(allow_empty=True):
1046  for arg in cd.arguments:
1047  if basetype(arg) == "basic::Tracer":
1048  if arg.default_value:
1049  print "REMOVING TRACER DEFAULT ARG",arg
1050  arg.default_value = None
1051  for fv in ns.vars(recursive=False,allow_empty=True):
1052  if basetype(fv) == "basic::Tracer":
1053  fv.exclude()
1054  print "REMOVING TRACER FREE VAR",fv,`fv`
1055  print " ",fv.ignore
1056 
1057 def basetype(t):
1058  """docstring for basetype"""
1059  # typestr = typestr.split("::")[-1].strip()
1060  # return re.sub("(?:const|[&]|<.*?>)","",typestr).strip()
1061  if hasattr(t,'type'): t = t.type
1062  while hasattr(t,"base"):
1063  t = t.base
1064  return str(t)
1065 
1066 
1067 def getIncludes(files):
1068  ''' return string with includes for finalize2
1069  '''
1070  files = files[:]
1071 
1072  output = ''
1073 
1074  output = set()
1075  for f in files[:]:
1076  cc_file = f.replace('.hh', '.cc')
1077  if os.path.isfile(cc_file):
1078  files.append(cc_file)
1079 
1080  for f in files:
1081  lines = commands.getoutput( "cat %s | grep '^#include <core' | grep '\.hh\|\.hpp'" % f) + '\n' \
1082  + commands.getoutput("cat %s | grep '^#include <numeric' | grep '\.hh\|\.hpp'" % f) + '\n' \
1083  + commands.getoutput("cat %s | grep '^#include <utility' | grep '\.hh\|\.hpp'" % f) + '\n' \
1084  + commands.getoutput("cat %s | grep '^#include <protocols' | grep '\.hh\|\.hpp'" % f) + '\n' \
1085  + commands.getoutput("cat %s | grep '^#include <basic' | grep '\.hh\|\.hpp'" % f) + '\n' \
1086  + commands.getoutput("cat %s | grep '^#include <ObjexxFCL' | grep '\.hh\|\.hpp'" % f) + '\n'
1087  #+ commands.getoutput("cat %s | grep '^#include <boost' | grep '\.hh\|\.hpp'" % f) + '\n'
1088 
1089  for i in lines.split('\n'):
1090  if i:
1091  #print 'i=', i
1092  try:
1093  iname = i[i.index('<')+1 : i.index('>')]
1094  if os.path.isfile( iname.replace('.fwd', '') ): i = i.replace('.fwd', '')
1095  output.add(i)
1096  except ValueError: pass
1097 
1098  output = '\n'.join(output)
1099 
1100 
1101  lines = list( set( output.split('\n') ) ); lines.sort()
1102  output = '\n'.join( lines ) + '\n'
1103  return output
1104 
1105 
1106 def finalize2(fname, dest, path, module_name='_noname', add_by_hand=False, includes=''):
1107 
1108  f = open(fname); s = '#include <boost/python.hpp>\n' + includes + f.read(); f.close()
1109 
1110  namespace = os.path.basename(path)
1111  by_hand = dest + '/../src/' + path + '/_' + namespace + '__by_hand.cc'
1112  #print '!++ ', by_hand, add_by_hand, 'namespace=%s' % namespace, 'path=%s' % path
1113  if os.path.isfile(by_hand) and add_by_hand:
1114  print 'Adding by bindings writen by hand...'
1115  f = open(by_hand);
1116  s = f.read() + '\n\n' + s
1117  f.close()
1118 
1119  #s = re.sub('BOOST_PYTHON_MODULE\(.*\)\{',
1120  # 'BOOST_PYTHON_MODULE(_%(n)s){\n wrap__%(n)s__by_hand();' % dict(n=namespace),
1121  # s)
1122 
1123  if add_by_hand:
1124  s = re.sub('BOOST_PYTHON_MODULE\(.*\)\{',
1125  'BOOST_PYTHON_MODULE(%(module_name)s){\n wrap__%(n)s__by_hand();' % dict(n=namespace, module_name=module_name),
1126  s)
1127  else:
1128  s = re.sub('BOOST_PYTHON_MODULE\(.*\)\{',
1129  'BOOST_PYTHON_MODULE(%(module_name)s){' % dict(n=namespace, module_name=module_name),
1130  s)
1131 
1132 
1133  f = open(fname,'w')
1134  f.write(s)
1135  f.close()
1136 
1137 
1138 def finalize(fname, dest, path, mb, module_name='_noname', add_by_hand=False, files=[], add_includes=True):
1139  files = files[:]
1140  #print 'finalize... add_by_hand=%s' % add_by_hand, files
1141  #if len(files) != 1: # Build mode 'All'
1142  if False:
1143  output = commands.getoutput("cd %s && cat *.cc *.hh | grep '#include <core'" % path)
1144  '''
1145  output += '\n' + commands.getoutput("cd %s && cat *.cc *.hh | grep '#include <protocols'" % path)
1146  output += '\n' + commands.getoutput("cd %s && cat *.cc *.hh | grep '#include <numeric'" % path)
1147  output += '\n' + commands.getoutput("cd %s && cat *.cc *.hh | grep '#include <utility'" % path)
1148  '''
1149  output += '\n' + commands.getoutput("cd %s && cat *.cc *.hh | grep '#include <protocols\|#include <numeric\|#include <utility' | grep '\.hh'" % path)
1150 
1151  # Some exceptional situation where we want to add additional includes
1152  if fname.find('AmbiguousMultiConstraint.cc') > 0: output += '\n#include <core/conformation/Conformation.hh>\n'
1153  if fname.find('RotamerTrieBase.cc') > 0:
1154  output += '\n#include <core/scoring/etable/EtableEnergy.hh>\n'
1155  output += '\n#include <core/scoring/etable/CoarseEtableEnergy.hh>\n'
1156  output += '\n#include <core/scoring/hbonds/HBondEnergy.hh>\n'
1157  if fname.find('TrieCountPairBase.cc') > 0:
1158  output += '\n#include <core/scoring/etable/EtableEnergy.hh>\n'
1159  output += '\n#include <core/scoring/etable/CoarseEtableEnergy.hh>\n'
1160  output += '\n#include <core/scoring/hbonds/HBondEnergy.hh>\n'
1161  if fname.find('EnergyMethod.cc') > 0:
1162  output += '\n#include <core/optimization/MinimizerMap.hh>\n'
1163  output += '\n#include <core/pack/task/PackerTask.hh>\n'
1164  if fname.find('RotamerTrieBase.cc') > 0:
1165  output += '\n#include <core/scoring/elec/FA_ElecEnergy.hh>\n'
1166  if fname.find('ScoreFunction.cc') > 0:
1167  output += '\n#include <core/optimization/MinimizerMap.hh>\n'
1168  #if fname.find('DNA_BaseEnergy.cc') > 0:
1169  # output += '\n#include <core/pack/task/PackerTask.hh>\n'
1170  #if fname.find('GenBornEnergy.cc') > 0:
1171  # output += '\n#include <core/pack/task/PackerTask.hh>\n'
1172  if fname.find('core/scoring/methods') > 0:
1173  output += '\n#include <core/pack/task/PackerTask.hh>\n'
1174  output += '\n#include <core/optimization/MinimizerMap.hh>\n'
1175 
1176  if fname.find('core/scoring/hbonds') > 0:
1177  output += '\n#include <core/pack/task/PackerTask.hh>\n'
1178 
1179  if fname.find('TrieCountPairBase.cc') > 0:
1180  output += '\n#include <core/scoring/elec/FA_ElecEnergy.hh>\n'
1181 
1182  if fname.find('FlexbbIGFactory.cc') > 0:
1183  output += '\n#include <core/pack/task/PackerTask.hh>\n'
1184 
1185 
1186  #if fname.find('AbrelaxApplication.hh') > 0:
1187  # output += '\n#include <core/kinematics/MoveMap.hh>\n'
1188 
1189  output = ''
1190  if add_includes:
1191 
1192  if True:
1193  output = set()
1194  for f in files[:]:
1195  cc_file = f.replace('.hh', '.cc')
1196  if os.path.isfile(cc_file):
1197  files.append(cc_file)
1198 
1199  for f in files:
1200  #print f
1201  lines = commands.getoutput( "cat %s | grep '^#include <core' | grep '\.hh\|\.hpp'" % f) + '\n' \
1202  + commands.getoutput("cat %s | grep '^#include <numeric' | grep '\.hh\|\.hpp'" % f) + '\n' \
1203  + commands.getoutput("cat %s | grep '^#include <utility' | grep '\.hh\|\.hpp'" % f) + '\n' \
1204  + commands.getoutput("cat %s | grep '^#include <protocols' | grep '\.hh\|\.hpp'" % f) + '\n' \
1205  + commands.getoutput("cat %s | grep '^#include <basic' | grep '\.hh\|\.hpp'" % f) + '\n' \
1206  + commands.getoutput("cat %s | grep '^#include <ObjexxFCL' | grep '\.hh\|\.hpp'" % f) + '\n'
1207  #+ commands.getoutput("cat %s | grep '^#include <boost' | grep '\.hh\|\.hpp'" % f) + '\n'
1208 
1209  #print f, lines
1210 
1211  for i in lines.split('\n'):
1212  if i:
1213  #print 'i=', i
1214  iname = i[i.index('<')+1 : i.index('>')]
1215  if os.path.isfile( iname.replace('.fwd', '') ): i = i.replace('.fwd', '')
1216  output.add(i)
1217 
1218  output = '\n'.join(output)
1219  #print output
1220  #sys.exit(1)
1221 
1222 
1223  #if fname.find('ShortLoopClosure.cc') > 0:
1224  # output += '\n#include <protocols/abinitio/FragmentMover.hh>\n'
1225 
1226  if fname.find('IterativeFullatom.cc') > 0:
1227  output += '\n#include <protocols/abinitio/PairingStatistics.hh>\n'
1228 
1229  if fname.find('FASelectSlidingWindowLoopClosure.cc') > 0:
1230  output += '\n#include <protocols/evaluation/ConstraintEvaluator.hh>\n'
1231 
1232 
1233  else: # Build mode 'one file'
1234  print "finalize... Build mode 'one file'..."
1235  f = files[0].replace('.hh', '.cc')
1236  if os.path.isfile(f):
1237  output = commands.getoutput("cat %s | grep '#include <core'" % f)
1238  output += '\n' + commands.getoutput("cat %s | grep '#include <protocols'" % f)
1239  output += '\n' + commands.getoutput("cat %s | grep '#include <numeric'" % f)
1240  else: output = ''
1241 
1242  lines = list( set( output.split('\n') ) ); lines.sort()
1243  output = '\n'.join( lines ) + '\n'
1244 
1245  #output = re.sub('\.fwd\.', '.', output)
1246 
1247  # removing non existen header files
1248  #lines = output.split('\n')
1249  #while
1250 
1251  f = open(fname); s = '#include <boost/python.hpp>\n' + output + f.read(); f.close()
1252 
1253  namespace = os.path.basename(path)
1254  by_hand = dest + '/../src/' + path + '/_' + namespace + '__by_hand.cc'
1255  #print '!++ ', by_hand, add_by_hand, 'namespace=%s' % namespace, 'path=%s' % path
1256  if os.path.isfile(by_hand) and add_by_hand:
1257  print 'Adding by bindings writen by hand...'
1258  f = open(by_hand);
1259  s = f.read() + '\n\n' + s
1260  f.close()
1261 
1262  #s = re.sub('BOOST_PYTHON_MODULE\(.*\)\{',
1263  # 'BOOST_PYTHON_MODULE(_%(n)s){\n wrap__%(n)s__by_hand();' % dict(n=namespace),
1264  # s)
1265 
1266  if add_by_hand:
1267  s = re.sub('BOOST_PYTHON_MODULE\(.*\)\{',
1268  'BOOST_PYTHON_MODULE(%(module_name)s){\n wrap__%(n)s__by_hand();' % dict(n=namespace, module_name=module_name),
1269  s)
1270  else:
1271  s = re.sub('BOOST_PYTHON_MODULE\(.*\)\{',
1272  'BOOST_PYTHON_MODULE(%(module_name)s){' % dict(n=namespace, module_name=module_name),
1273  s)
1274 
1275 
1276  f = open(fname,'w')
1277  f.write(s)
1278  f.close()
1279 
1280  #print 'Creating __init__.py file...'
1281  #f = file( dest + '/' + path + '/__init__.py', 'a');
1282  #f.write('from %s import *\n' % os.path.basename(fname)[:-3]);
1283  #f.close()
1284 
1285 
1286 def finalize_old(fname, path, mb):
1287  ns = getNameSpace(path, mb)
1288 
1289  print "FINALIZE"
1290  f = open(fname)
1291  s = f.read()
1292  f.close()
1293  f = open(fname,'w')
1294  s = re.sub("BOOST_PYTHON_MODULE\(.*\)","void wrap"+ns.decl_string.replace(":","_")+"()",s)
1295  # vec_unsigned = "::utility::vector1<unsigned, std::allocator<unsigned> >"
1296  # vecvec_unsigned = "::utility::vector1<utility::vector1<unsigned, std::allocator<unsigned> >, std::allocator<utility::vector1<unsigned, std::allocator<unsigned> > > >"
1297  # vec_size = "::utility::vector1<Size>"
1298  # vecvec_size = "::utility::vector1<utility::vector1<Size> >"
1299  # if s.count(vec_unsigned) or s.count(vecvec_unsigned):
1300  # print "REPLACING VEC<UNSIGNED> w/ VEC<SIZE_T>!!!!!!!!!!"
1301  # s = s.replace(vec_unsigned,vec_size)
1302  # s = s.replace(vecvec_unsigned,vecvec_size)
1303  # # n = fname.split("/")[-1][1:].replace(".cc","")
1304  # # s = s.replace('#include "all_headers.hh"','#include "include/all_forwards.hh"\n#include "include/%s.hh"'%n)
1305  incname = ns.decl_string.strip(":").replace("::","__")+".hh"
1306  # s = s.replace( '#include "include/%s/groups/all.hh"'%CONFIG.SVN_REV
1307  # , '#include "include/%s/groups/'%CONFIG.SVN_REV+incname+'"')
1308  s = s.replace("protocols::moves::Real","core::Real")
1309  #
1310  pat1 = r"\(\(const std::allocator<([^<>]+)>\&\)\(\(const std::allocator<\1>\*\)\(\& std::allocator<\1>\(\)\)\)\)"
1311  pat2 = r" /* REMOVED ((const std::allocator<\1>&)((const std::allocator<\1>*)(& std::allocator<\1>())))*/ "
1312  s = re.sub(pat1,pat2,s)
1313  #
1314  f.write(s)
1315  f.close()
1316  #os.system('find %s -name \*~ | xargs rm'%ROOT_DIR)
1317  #os.system("find %s -name named_tuple.py | xargs rm"%ROOT_DIR)
1318 
1319 
1320 def filter_code_creators(mb, path, wrappers):
1321  ns = getNameSpace(path, mb)
1322 
1323  print 'getting all creators...'
1324  creators = pyplusplus.code_creators.make_flatten(mb.code_creator.creators)
1325  print(len(creators))
1326  creators = filter( lambda x: hasattr(x,'declaration'), creators )
1327  print(len(creators))
1328  for cc in creators:
1329  nstmp = namespace_of(cc)
1330  if nstmp is not ns:
1331  print 'removing CC for',cc.declaration
1332  cc.parent.creators.remove(cc)
1333  if not wrappers:
1334  if str(type(cc)).count("_wrapper"):
1335  print cc
1336  print cc.declaration
1337  assert False
1338 
1339 
1340 def isinc(x):
1341  return not x._ignore
1342 
1344  return "utility::pointer::ReferenceCount [class]" in [str(b) for b in get_class_bases(c)]
1345 
1346 def postproc(code):
1347  code = re.sub(r'<unsigned([,>])',r'<std::size_t\1',code)
1348  return code
1349 
1350 def ischildof(a,b):
1351  while a and a is not b: a = a.parent
1352  return a is b
1353 
1354 
1356  # t = time.time()
1357  if isinstance(x,pyplusplus.code_creators.code_creator_t): x = x.declaration
1358  # print "FIND NS:",time.time() - t
1359  while x:
1360  # t = time.time()
1361  if isinstance(x,pyplusplus.decl_wrappers.namespace_t): break
1362  # print 'isinstance',time.time()-t
1363  t = time.time()
1364  x = x.parent
1365  # print 'parent',time.time()-t
1366  # print " ",x
1367  return x
1368 
1369 def class_of(x):
1370  # t = time.time()
1371  if isinstance(x,pyplusplus.code_creators.code_creator_t): x = x.declaration
1372  # print "FIND NS:",time.time() - t
1373  while x:
1374  # t = time.time()
1375  if isinstance(x,pyplusplus.decl_wrappers.class_t): break
1376  # print 'isinstance',time.time()-t
1377  t = time.time()
1378  x = x.parent
1379  # print 'parent',time.time()-t
1380  # print " ",x
1381  return x
1382 
1383 
1384 def get_class_bases(argcls,baseslist=None):
1385  baseslist = []
1386  if hasattr(argcls,'bases'):
1387  for bi in argcls.bases:
1388  assert hasattr(bi,"related_class")
1389  baseslist.extend( get_class_bases(bi.related_class,baseslist) )
1390  if baseslist is None:
1391  baseslist = []
1392  baseslist.append(argcls)
1393  return baseslist
def filter_code_creators
Definition: exclude.py:1320
def is_refcount
Definition: exclude.py:1343
def mb_exclude
Definition: exclude.py:337
def setup_held_type
Definition: exclude.py:885
def finalize2
Definition: exclude.py:1106
def make_sure_is_copyable
Definition: exclude.py:929
std::istream & read(std::istream &stream, Fstring &s)
Read from Stream.
Definition: Fstring.cc:1622
def exclude_private_and_protected_members
Definition: exclude.py:793
def annotate
Definition: exclude.py:819
def exclude_disallowed_virtuals
Definition: exclude.py:976
def exclude
Definition: exclude.py:838
def ischildof
Definition: exclude.py:1350
bool endswith(std::string const &haystack, std::string const &needle)
True iff haystack ends with needle.
Definition: string_util.cc:280
def make_implicitly_convertible
Definition: exclude.py:908
std::string E(int const w, int const d, float const &t)
Exponential Format: float.
Definition: format.cc:312
Fstring::size_type len(Fstring const &s)
Length.
Definition: Fstring.hh:2207
utility::vector1< std::string > split(const std::string &s)
split given std::string using ' ' symbol.
Definition: string_util.cc:59
def make_nonvirtual
Definition: exclude.py:759
def getNameSpace
Definition: exclude.py:826
def namespace
Definition: exclude.py:223
def remove_tracer_default_args_and_vars
Definition: exclude.py:1044
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
std::string & strip(std::string &s, std::string const &chars)
Strip Specified Characters from a string's Tails.
def parse_full_name
Definition: exclude.py:1014
def set_default_call_policies
Definition: exclude.py:936
def class_of
Definition: exclude.py:1369
def class_from_full_path
Definition: exclude.py:1026
def namespace_of
Definition: exclude.py:1355
def isinc
Definition: exclude.py:1340
def isFileInScons
Definition: exclude.py:28
def getIncludes
Definition: exclude.py:1067
def get_class_bases
Definition: exclude.py:1384
def finalize
Definition: exclude.py:1138
def exclude_impls_
Definition: exclude.py:878
def add_print_operators
Definition: exclude.py:801
std::string & rstrip(std::string &s, std::string const &chars)
Strip Specified Characters from a string's Right Tail.
def basetype
Definition: exclude.py:1057
def postproc
Definition: exclude.py:1346
def removeProtectedConstructos
Definition: exclude.py:783
def namespace_from_full_path
Definition: exclude.py:1036
def finalize_old
Definition: exclude.py:1286
def isBanned
Definition: exclude.py:214