# This file was automatically generated by SWIG (http://www.swig.org). # Version 3.0.6 # # Do not make changes to this file unless you know what you are doing--modify # the SWIG interface file instead. from sys import version_info if version_info >= (2, 6, 0): def swig_import_helper(): from os.path import dirname import imp fp = None try: fp, pathname, description = imp.find_module('_privateer', [dirname(__file__)]) except ImportError: import _privateer return _privateer if fp is not None: try: _mod = imp.load_module('_privateer', fp, pathname, description) finally: fp.close() return _mod _privateer = swig_import_helper() del swig_import_helper else: import _privateer del version_info try: _swig_property = property except NameError: pass # Python < 2.2 doesn't have 'property'. def _swig_setattr_nondynamic(self, class_type, name, value, static=1): if (name == "thisown"): return self.this.own(value) if (name == "this"): if type(value).__name__ == 'SwigPyObject': self.__dict__[name] = value return method = class_type.__swig_setmethods__.get(name, None) if method: return method(self, value) if (not static): if _newclass: object.__setattr__(self, name, value) else: self.__dict__[name] = value else: raise AttributeError("You cannot add attributes to %s" % self) def _swig_setattr(self, class_type, name, value): return _swig_setattr_nondynamic(self, class_type, name, value, 0) def _swig_getattr_nondynamic(self, class_type, name, static=1): if (name == "thisown"): return self.this.own() method = class_type.__swig_getmethods__.get(name, None) if method: return method(self) if (not static): return object.__getattr__(self, name) else: raise AttributeError(name) def _swig_getattr(self, class_type, name): return _swig_getattr_nondynamic(self, class_type, name, 0) def _swig_repr(self): try: strthis = "proxy of " + self.this.__repr__() except: strthis = "" return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) try: _object = object _newclass = 1 except AttributeError: class _object: pass _newclass = 0 class SwigPyIterator(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, SwigPyIterator, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, SwigPyIterator, name) def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract") __repr__ = _swig_repr __swig_destroy__ = _privateer.delete_SwigPyIterator __del__ = lambda self: None def value(self): return _privateer.SwigPyIterator_value(self) def incr(self, n=1): return _privateer.SwigPyIterator_incr(self, n) def decr(self, n=1): return _privateer.SwigPyIterator_decr(self, n) def distance(self, x): return _privateer.SwigPyIterator_distance(self, x) def equal(self, x): return _privateer.SwigPyIterator_equal(self, x) def copy(self): return _privateer.SwigPyIterator_copy(self) def next(self): return _privateer.SwigPyIterator_next(self) def __next__(self): return _privateer.SwigPyIterator___next__(self) def previous(self): return _privateer.SwigPyIterator_previous(self) def advance(self, n): return _privateer.SwigPyIterator_advance(self, n) def __eq__(self, x): return _privateer.SwigPyIterator___eq__(self, x) def __ne__(self, x): return _privateer.SwigPyIterator___ne__(self, x) def __iadd__(self, n): return _privateer.SwigPyIterator___iadd__(self, n) def __isub__(self, n): return _privateer.SwigPyIterator___isub__(self, n) def __add__(self, n): return _privateer.SwigPyIterator___add__(self, n) def __sub__(self, *args): return _privateer.SwigPyIterator___sub__(self, *args) def __iter__(self): return self SwigPyIterator_swigregister = _privateer.SwigPyIterator_swigregister SwigPyIterator_swigregister(SwigPyIterator) def carbname_of(name): return _privateer.carbname_of(name) carbname_of = _privateer.carbname_of def found_in_database(name): return _privateer.found_in_database(name) found_in_database = _privateer.found_in_database def get_annotated_glycans(*args): return _privateer.get_annotated_glycans(*args) get_annotated_glycans = _privateer.get_annotated_glycans def get_annotated_glycans_hierarchical(*args): return _privateer.get_annotated_glycans_hierarchical(*args) get_annotated_glycans_hierarchical = _privateer.get_annotated_glycans_hierarchical def svg_graphics_demo(original_colour_scheme, inverted_background): return _privateer.svg_graphics_demo(original_colour_scheme, inverted_background) svg_graphics_demo = _privateer.svg_graphics_demo def get_colour(colour, original_style): return _privateer.get_colour(colour, original_style) get_colour = _privateer.get_colour _privateer.blue_swigconstant(_privateer) blue = _privateer.blue _privateer.red_swigconstant(_privateer) red = _privateer.red _privateer.yellow_swigconstant(_privateer) yellow = _privateer.yellow _privateer.orange_swigconstant(_privateer) orange = _privateer.orange _privateer.green_swigconstant(_privateer) green = _privateer.green _privateer.purple_swigconstant(_privateer) purple = _privateer.purple _privateer.cyan_swigconstant(_privateer) cyan = _privateer.cyan _privateer.tan_swigconstant(_privateer) tan = _privateer.tan _privateer.black_swigconstant(_privateer) black = _privateer.black _privateer.white_swigconstant(_privateer) white = _privateer.white def minimise_from_smiles ( smiles_string = "", n_conformers=50 ) : from rdkit import Chem from rdkit.Chem import AllChem mol = Chem.MolFromSmiles( smiles_string ) mol_with_h = AllChem.AddHs(mol) conformer_ids = AllChem.EmbedMultipleConfs ( mol_with_h, numConfs=n_conformers ) best_conformer_id = 0 lowest_energy = 5000 for conformer_id in conformer_ids : force_field = AllChem.UFFGetMoleculeForceField ( mol_with_h, confId=conformer_id ) success = force_field.Minimize() if success : if force_field.CalcEnergy() < lowest_energy : best_conformer_id = conformer_id lowest_energy = force_field.CalcEnergy() print "Energy: %f kcal/mol" % lowest_energy from rdkit.Chem import PDBWriter writer = PDBWriter ( "privateer-minimised.pdb" ) writer.write ( mol = mol_with_h, confId = best_conformer_id ) writer.close() with open("privateer-minimised.pdb", 'r+') as f: content = f.read() f.seek(0,0) f.write ( 'REMARK 300 THIS MOLECULE HAS BEEN PRODUCED BY PRIVATEER USING RDKIT\n') f.write ( 'REMARK 300 SMILES STRING: ' + smiles_string + '\n') f.write ( 'REMARK 300 NUMBER OF CONFORMERS EXPLORED: %i\n' % n_conformers ) f.write ( 'REMARK 300 ENERGY AFTER MINIMISATION: %f KCAL/MOL\n' % lowest_energy ) f.write ( content ) print "lowest energy: %f" % lowest_energy # This file is compatible with both classic and new-style classes.