├── .gitignore ├── AutoDockTools ├── AutoDockBondClassifier.py ├── AutoLigand.py ├── AutoLigandCommand.py ├── CADD │ ├── VisionNetworks │ │ ├── VS_net.py │ │ └── __init__.py │ ├── __init__.py │ └── cadd.py ├── ConfPlayer.py ├── Conformation.py ├── DlgFilters.py ├── DlgParser.py ├── Docking.py ├── DockingFilters.py ├── DockingParameters.py ├── EntropiaParser.py ├── EpdbParser.py ├── GridParameters.py ├── InteractionDetector.py ├── LigandMixin.py ├── MoleculePreparation.py ├── Objects │ └── __init__.py ├── ResultParser.py ├── TrajParser.py ├── Utilities24 │ ├── __init__.py │ ├── calc_energy_breakdown_from_results.py │ ├── compute_AD42ScoreC.py │ ├── compute_AutoDock41_score.py │ ├── compute_consensus_maps_from_dlgs.py │ ├── compute_interatomic_distance_per_pose.py │ ├── compute_interatomic_distance_per_vina_pose.py │ ├── compute_rms_between_conformations.py │ ├── compute_rms_between_methods.py │ ├── compute_water_map.py │ ├── dpf3_to_dpf4.py │ ├── energy_average_maps.py │ ├── get_trilinterp_values.py │ ├── gpf3_to_gpf4.py │ ├── gpf4_to_gpf3.py │ ├── pdbq_to_pdbqt.py │ ├── pdbqs_to_pdbqt.py │ ├── pdbqt_to_pdb.py │ ├── pdbqt_to_pdbq.py │ ├── pdbqt_to_pdbqs.py │ ├── prepare_configFile.py │ ├── prepare_covalent_flexres.py │ ├── prepare_dpf.py │ ├── prepare_dpf4.py │ ├── prepare_dpf41.py │ ├── prepare_dpf42.py │ ├── prepare_dpf_vif.py │ ├── prepare_flexreceptor4.py │ ├── prepare_gpf.py │ ├── prepare_gpf4.py │ ├── prepare_ligand.py │ ├── prepare_ligand4.py │ ├── prepare_ligand_dict.py │ ├── prepare_ligand_vif.py │ ├── prepare_pdb_split_alt_confs.py │ ├── prepare_receptor.py │ ├── prepare_receptor4.py │ ├── process_VSResults.py │ ├── process_VSResultsFox.py │ ├── process_VinaResult.py │ ├── repair_ligand4.py │ ├── rotate_molecule.py │ ├── score_atoms_by_component.py │ ├── summarize_docking.py │ ├── summarize_docking_directory.py │ ├── summarize_epdb_results4.py │ ├── summarize_results.py │ ├── summarize_results4.py │ ├── summarize_results41.py │ ├── summarize_results_vif.py │ ├── summarize_time.py │ ├── summarize_wcg_docking.py │ ├── superimpose_based_on_subset.py │ ├── superpose_molecules.py │ ├── write_all_complexes.py │ ├── write_clustering_histogram_postscript.py │ ├── write_component_energies.py │ ├── write_conformations_from_dlg.py │ ├── write_each_cluster_LE_conf.py │ ├── write_largest_cluster_ligand.py │ ├── write_lowest_energy_ligand.py │ ├── write_models_from_states.py │ ├── write_random_state_ligand.py │ ├── write_rigid_ligand.py │ └── write_vs_hits.py ├── VSResultFilters.py ├── VisionInterface │ ├── AD3Dpf.py │ ├── AD3Gpf.py │ ├── Adt │ │ ├── Filter │ │ │ ├── __init__.py │ │ │ └── filterLigands.py │ │ ├── Input │ │ │ ├── AutogridResDirectoryBrowser.py │ │ │ ├── AutogridResURL.py │ │ │ ├── DPFTemplateBrowser.py │ │ │ ├── GPFTemplateBrowser.py │ │ │ ├── GetStructuresFromDir.py │ │ │ ├── LocalLigandDirectory.py │ │ │ ├── MakeDPFCopies.py │ │ │ ├── MakeGPFCopies.py │ │ │ ├── MakeGpfDpfCopies.py │ │ │ ├── PreparedStructureBrowser.py │ │ │ ├── PublicServerLigandDB.py │ │ │ ├── StructureBrowser.py │ │ │ ├── UrlLigandDB.py │ │ │ └── __init__.py │ │ ├── LigandDB.py │ │ ├── Macro │ │ │ ├── AutodockVS.py │ │ │ ├── AutodockVsCSF.py │ │ │ ├── ComputeGrids.py │ │ │ ├── GromosCluster.py │ │ │ ├── PrepareReceptor.py │ │ │ ├── PrepareSingleLigand.py │ │ │ ├── TrajQR.py │ │ │ ├── Vina.py │ │ │ ├── VirtualScreening.py │ │ │ ├── VirtualScreeningCSF.py │ │ │ └── __init__.py │ │ ├── Mapper │ │ │ ├── ADTFileNames.py │ │ │ ├── InputValidation.py │ │ │ └── __init__.py │ │ ├── Other │ │ │ └── __init__.py │ │ ├── Output │ │ │ └── __init__.py │ │ ├── __init__.py │ │ ├── autogrid_results.py │ │ ├── dpf_template.py │ │ ├── gpf_template.py │ │ ├── libTypes.py │ │ ├── receptor.py │ │ └── receptor_prepared.py │ ├── AdtNodes.py │ ├── Docking.py │ ├── PrepareAD3Ligand.py │ ├── PrepareAD3Receptor.py │ ├── PrepareAD4Ligand.py │ ├── __init__.py │ └── recluster.py ├── WebServices.py ├── XMLParser.py ├── __init__.py ├── adthosts.py ├── atomTypeTools.py ├── autoanalyze3Commands.py ├── autoanalyze41Commands.py ├── autoanalyze4Commands.py ├── autoanalyzeCommands.py ├── autodockHosts.py ├── autodpf3Commands.py ├── autodpf41Commands.py ├── autodpf4Commands.py ├── autodpfCommands.py ├── autoflex41Commands.py ├── autoflex4Commands.py ├── autoflexCommands.py ├── autogpf3Commands.py ├── autogpf41Commands.py ├── autogpf4Commands.py ├── autogpfCommands.py ├── autopilotCommands.py ├── autostart3Commands.py ├── autostart41Commands.py ├── autostart4Commands.py ├── autostartCommands.py ├── autotors3Commands.py ├── autotors41Commands.py ├── autotors4Commands.py ├── autotorsCommands.py ├── bin │ └── runAdt.py ├── cluster.py ├── cluster_ad.py ├── cmdlib.py ├── energyCalculator.py ├── energyConstants.py ├── filterLigands.py ├── histogram.py ├── interactiveHistogramGraph.py ├── lib_parameter_file_writer.py ├── modlib.py ├── pixelMap2D.py ├── pyAutoDockCommands.py ├── sol_par.py └── waterMapBuilder.py ├── LICENSE.txt ├── MolKit ├── APBSParameters.py ├── GapFinder.py ├── MolecularDescriptor.py ├── PDBdict.py ├── PDBresidueNames.py ├── PROSS.py ├── VisionInterface │ ├── MolKitNodes.py │ ├── MolKitTypes.py │ └── __init__.py ├── WaterBuilder.py ├── __init__.py ├── amberPrmTop.py ├── bondClassifier.py ├── bondSelector.py ├── chargeCalculator.py ├── chargeMass.py ├── data │ ├── __init__.py │ ├── all_amino94_dat.py │ ├── all_aminoct94_dat.py │ ├── all_aminont94_dat.py │ ├── all_dat.py │ ├── all_nuc94_dat.py │ ├── allct_dat.py │ ├── allnt_dat.py │ ├── build_all_in.py │ ├── nh2e_dat.py │ ├── opls_nacl_dat.py │ ├── opls_uni_dat.py │ ├── opls_unict_dat.py │ ├── opls_unint_dat.py │ ├── qkollua.py │ ├── uni_dat.py │ ├── unict_dat.py │ └── unint_dat.py ├── distanceSelector.py ├── genPdbParser.py ├── getsecondarystructure.py ├── groParser.py ├── hydrogenBondBuilder.py ├── hydrogenBuilder.py ├── interactionDescriptor.py ├── introduction.py ├── listSet.py ├── mmcifParser.py ├── mmcifWriter.py ├── mol2Parser.py ├── molecule.py ├── moleculeParser.py ├── moleculeWriter.py ├── oxtBuilder.py ├── parm94_dat.py ├── pdb2pqr │ ├── __init__.py │ ├── definitions.py │ ├── extensions │ │ ├── __init__.py │ │ ├── chi.py │ │ ├── hbond.py │ │ ├── phi.py │ │ ├── psi.py │ │ └── rama.py │ ├── forcefield.py │ ├── hydrogens.py │ ├── pdb.py │ ├── pdb2pka │ │ ├── NEWligand_topology.py │ │ ├── __init__.py │ │ ├── apbs.py │ │ ├── example.py │ │ ├── inputgen_pKa.py │ │ ├── ligand_topology.py │ │ ├── ligandclean │ │ │ ├── __init__.py │ │ │ ├── ligff.py │ │ │ ├── lookuptable.py │ │ │ ├── peoe_PDB2PQR.py │ │ │ ├── templates.py │ │ │ └── trial_templates.py │ │ ├── pKa_base.py │ │ ├── pMC_mult.py │ │ ├── pka.py │ │ └── substruct │ │ │ └── __init__.py │ ├── pdb2pqr.py │ ├── propka │ │ ├── __init__.py │ │ └── propkalib.py │ ├── protein.py │ ├── quatfit.py │ ├── routines.py │ ├── src │ │ ├── __init__.py │ │ ├── aa.py │ │ ├── definitions.py │ │ ├── forcefield.py │ │ ├── hydrogens.py │ │ ├── inputgen.py │ │ ├── na.py │ │ ├── pdb.py │ │ ├── protein.py │ │ ├── psize.py │ │ ├── quatfit.py │ │ ├── routines.py │ │ ├── server.py │ │ ├── structures.py │ │ └── utilities.py │ ├── structures.py │ └── utilities.py ├── pdbParser.py ├── pdbWriter.py ├── pqrWriter.py ├── protein.py ├── radii_patterns.py ├── rotamerLib.py ├── sdfParser.py ├── sequence.py ├── sets.py ├── stringSelector.py ├── torTree.py ├── trajParser.py ├── tree.py └── waterBuilder.py ├── PyBabel ├── __init__.py ├── addh.py ├── aromatic.py ├── atomTypes.py ├── babelAtomTypes.py ├── babelElements.py ├── bo.py ├── cycle.py ├── gasteiger.py ├── tools.py └── util.py ├── README.md ├── Support ├── __init__.py ├── mktestsummary.py ├── path.py ├── sitecustomize.py ├── unzip.py ├── update.py └── version.py ├── _py2k_string └── __init__.py ├── bhtree ├── __init__.py └── bhtreelib.py ├── cMolKit ├── __init__.py └── xtcparser.py ├── conda-recipe ├── build.sh └── meta.yaml ├── mglutil ├── TestUtil │ ├── BugReport.py │ ├── Dependencytester.py │ ├── MultipartPostHandler.py │ ├── __init__.py │ ├── bin │ │ └── getlatest.py │ └── tester.py ├── __init__.py ├── bhtfunctions.py ├── errors.py ├── events.py ├── gui │ ├── BasicWidgets │ │ ├── Tk │ │ │ ├── Dial.py │ │ │ ├── KeyboardEntry.py │ │ │ ├── RelabelingCascadeMenu.py │ │ │ ├── TreeWidget │ │ │ │ ├── TV_sample.py │ │ │ │ ├── __init__.py │ │ │ │ ├── icons │ │ │ │ │ └── __init__.py │ │ │ │ ├── objectBrowser.py │ │ │ │ └── tree.py │ │ │ ├── __init__.py │ │ │ ├── canvasWidgets.py │ │ │ ├── colorWidgets.py │ │ │ ├── customizedWidgets.py │ │ │ ├── defaultColors.py │ │ │ ├── dirDialog.py │ │ │ ├── eventHandler.py │ │ │ ├── fileBrowsers.py │ │ │ ├── graphtool.py │ │ │ ├── multiButton.py │ │ │ ├── multiListbox.py │ │ │ ├── optionsPanel.py │ │ │ ├── player.py │ │ │ ├── progressBar.py │ │ │ ├── seqViewer.py │ │ │ ├── tablemaker.py │ │ │ ├── thumbwheel.py │ │ │ ├── toolbarbutton.py │ │ │ ├── trees │ │ │ │ ├── TreeWithButtons.py │ │ │ │ ├── __init__.py │ │ │ │ └── tree.py │ │ │ ├── vector3DGUI.py │ │ │ └── xyzGUI.py │ │ └── __init__.py │ ├── InputForm │ │ ├── Tk │ │ │ ├── VFPmw.py │ │ │ ├── __init__.py │ │ │ ├── gui.py │ │ │ └── moveTk.py │ │ ├── __init__.py │ │ └── inputFormEditor.py │ ├── Misc │ │ ├── Tk │ │ │ ├── KeybdModMonitor.py │ │ │ └── __init__.py │ │ └── __init__.py │ ├── Spline │ │ ├── __init__.py │ │ ├── animatorSpline.py │ │ ├── spline.py │ │ └── splineGUI.py │ └── __init__.py ├── math │ ├── TensorModule.py │ ├── VectorModule.py │ ├── __init__.py │ ├── crystal.py │ ├── gridDescriptor.py │ ├── kinematics.py │ ├── kinematicstest.py │ ├── kmeansClustering.py │ ├── munkres.py │ ├── ncoords.py │ ├── ncoordstest.py │ ├── rigidFit.py │ ├── rmsd.py │ ├── rmsdtest.py │ ├── rotax.py │ ├── statetocoords.py │ ├── statetocoordstest.py │ ├── stats.py │ ├── torsion.py │ ├── transformation.py │ ├── transformationtest.py │ └── usr.py ├── popen2Threads.py ├── preferences.py ├── process.py ├── regression │ ├── __init__.py │ ├── testplus.py │ └── testplus_before_2_1.py ├── splashregister │ ├── __init__.py │ ├── about.py │ ├── license.py │ ├── register.py │ └── splashscreen.py ├── util │ ├── __init__.py │ ├── callback.py │ ├── colorUtil.py │ ├── defaultPalettes.py │ ├── idleUtil.py │ ├── misc.py │ ├── packageFilePath.py │ ├── parser.py │ ├── qhullUtils.py │ ├── recentFiles.py │ ├── relpath.py │ ├── repeatPrinter.py │ ├── tree.py │ └── uniq.py └── web │ ├── HTMLParser.py │ ├── __init__.py │ ├── regression │ ├── __init__.py │ ├── testAll.py │ └── test_htmlparser.py │ └── services │ ├── AppService_client.py │ ├── AppService_server.py │ ├── AppService_services.py │ ├── AppService_services_types.py │ ├── AppService_types.py │ ├── SecuritymyproxyloginImplService_services.py │ ├── SecurityuserimportImplService_services.py │ └── __init__.py └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | 53 | # Translations 54 | *.mo 55 | *.pot 56 | 57 | # Django stuff: 58 | *.log 59 | local_settings.py 60 | db.sqlite3 61 | db.sqlite3-journal 62 | 63 | # Flask stuff: 64 | instance/ 65 | .webassets-cache 66 | 67 | # Scrapy stuff: 68 | .scrapy 69 | 70 | # Sphinx documentation 71 | docs/_build/ 72 | 73 | # PyBuilder 74 | target/ 75 | 76 | # Jupyter Notebook 77 | .ipynb_checkpoints 78 | 79 | # IPython 80 | profile_default/ 81 | ipython_config.py 82 | 83 | # pyenv 84 | .python-version 85 | 86 | # pipenv 87 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 88 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 89 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 90 | # install all needed dependencies. 91 | #Pipfile.lock 92 | 93 | # celery beat schedule file 94 | celerybeat-schedule 95 | 96 | # SageMath parsed files 97 | *.sage.py 98 | 99 | # Environments 100 | .env 101 | .venv 102 | env/ 103 | venv/ 104 | ENV/ 105 | env.bak/ 106 | venv.bak/ 107 | 108 | # Spyder project settings 109 | .spyderproject 110 | .spyproject 111 | 112 | # Rope project settings 113 | .ropeproject 114 | 115 | # mkdocs documentation 116 | /site 117 | 118 | # mypy 119 | .mypy_cache/ 120 | .dmypy.json 121 | dmypy.json 122 | 123 | # Pyre type checker 124 | .pyre/ -------------------------------------------------------------------------------- /AutoDockTools/CADD/VisionNetworks/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/AutoDockTools/CADD/VisionNetworks/__init__.py -------------------------------------------------------------------------------- /AutoDockTools/CADD/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/AutoDockTools/CADD/__init__.py -------------------------------------------------------------------------------- /AutoDockTools/Objects/__init__.py: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # 3 | # Author: Ruth HUEY, Michel F. SANNER 4 | # 5 | # Copyright: M. Sanner TSRI 2000 6 | # 7 | ############################################################################# 8 | # 9 | # $Header: /opt/cvs/python/packages/share1.5/AutoDockTools/Objects/__init__.py,v 1.2 2009/06/17 00:03:24 vareille Exp $ 10 | # 11 | # $Id: __init__.py,v 1.2 2009/06/17 00:03:24 vareille Exp $ 12 | 13 | # create hostDict with hostMacros accessible by anyone 14 | from AutoDockTools.adthosts import hostMacros 15 | from AutoDockTools.autodockHosts import AutoDockHosts 16 | 17 | hostDict = AutoDockHosts(hostMacros) 18 | 19 | import socket 20 | h= socket.gethostname() 21 | hostDict[h]=hostDict['localhost'] 22 | hostDict[h]['host']=h 23 | del hostDict['localhost'] 24 | 25 | # try to extend that dictionary with user specific hostMacros 26 | 27 | # first try to find a adthost file in current directory 28 | import os,sys 29 | if os.path.isfile('./adthosts.py'): 30 | exec(compile(open('./adthosts.py', "rb").read(), './adthosts.py', 'exec')) 31 | if 'hostMacros' in globals(): 32 | hostDict.update(hostMacros) 33 | elif os.name != 'nt':#sys.platform!='win32': 34 | # try to find the user's home directory 35 | import posix 36 | if 'HOME' in list(posix.environ.keys()): 37 | try: 38 | exec(compile(open(os.path.join(posix.environ['HOME'],'adthosts.py'), "rb").read(), os.path.join(posix.environ['HOME'],'adthosts.py'), 'exec')) 39 | if 'hostMacros' in globals(): 40 | hostDict.update(hostMacros) 41 | except: 42 | pass 43 | 44 | 45 | -------------------------------------------------------------------------------- /AutoDockTools/ResultParser.py: -------------------------------------------------------------------------------- 1 | # 2 | # Last modified on Mon Mar 4 14:35:36 PST 2002 by lindy 3 | # 4 | # $Header: /opt/cvs/python/packages/share1.5/AutoDockTools/ResultParser.py,v 1.3 2009/01/09 19:53:49 rhuey Exp $ 5 | # 6 | 7 | 8 | 9 | 10 | class ResultParser: 11 | """Base class of result parsers. Supply your own parseline 12 | function which appends a conformation dictionary to self.clist 13 | """ 14 | def __init__(self): 15 | self.clist = [] 16 | 17 | # add more keywords in subclass if you like 18 | keywords = [ 19 | 'cluster', # number of cluster 20 | 'cluster_rank', # rank within cluster 21 | 'rmsd_ref', # distance to reference structure 22 | 'rmsd_seed', # distance to lowest energy conf. in cluster 23 | 'binding_energy', # estimated free energy of binding 24 | 'docking_energy', # final docked energy 25 | 'internal_energy', 26 | 'trn_x', # translation x, y, z 27 | 'trn_y', 28 | 'trn_z', 29 | 'qtn_nx', # quaternion unit vector x, y, z 30 | 'qtn_ny', 31 | 'qtn_nz', 32 | 'qtn_ang_deg', # quaternion rotation angle 33 | 'num_torsions', 34 | 'torsion_values', 35 | 'rseed1', # the random number seeds for this conformation 36 | 'rseed2', 37 | ] 38 | 39 | def parse(self, filename): 40 | """ 41 | """ 42 | file_ptr = open(filename) 43 | 44 | self.clist = [] 45 | for line in file_ptr.readlines(): 46 | self.parseline(line) 47 | file_ptr.close() 48 | 49 | self.filename = filename 50 | 51 | return self.clist 52 | 53 | 54 | def parseline(self, line): 55 | """over ride me""" 56 | pass 57 | 58 | -------------------------------------------------------------------------------- /AutoDockTools/TrajParser.py: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # 3 | # Author: Ruth HUEY, Michel F. SANNER 4 | # 5 | # Copyright: M. Sanner TSRI 2002 6 | # 7 | ############################################################################# 8 | 9 | 10 | # $Header: /opt/cvs/python/packages/share1.5/AutoDockTools/TrajParser.py,v 1.2 2003/08/29 17:55:18 sophiec Exp $ 11 | # 12 | # $Id: TrajParser.py,v 1.2 2003/08/29 17:55:18 sophiec Exp $ 13 | # 14 | # 15 | # 16 | # 17 | # 18 | # 19 | # 20 | 21 | """ 22 | This Object parses the result of a trajectory AutoDock run and returns a dictionary. 23 | 24 | """ 25 | import os 26 | from string import find, join, replace, split, rfind 27 | import re 28 | from MolKit.pdbParser import PdbqParser 29 | 30 | from AutoDockTools.ResultParser import ResultParser 31 | 32 | 33 | class TrajParser(ResultParser): 34 | """ reads log from a AutoDock traj docking and return structured data""" 35 | 36 | keywords = ResultParser.keywords + [ 37 | 'run', 38 | 'cycle', 39 | 'temp', 40 | 'acc_rej_code', 41 | #'intermol_energy', #(1) 42 | #'internal_energy', #(2) NB: 1+2->final docked energy 43 | #'e_total', #1+2 THIS IS THE SAME AS docking_energy???? 44 | 45 | ] 46 | 47 | 48 | def __init__(self, dlgFile=None): 49 | """selected dlgFile,ok sets which docked conformations to show""" 50 | ResultParser.__init__(self) 51 | self.filename = dlgFile 52 | #set up dict here 53 | if dlgFile: 54 | self.filename = os.path.basename(dlgFile) 55 | self.parse(dlgFile) 56 | 57 | 58 | def parse(self, filename): 59 | """ 60 | to parse uses keys: 61 | 'ntorsions', 62 | 'run', 63 | 'cycle', 64 | 'temp', 65 | 'state' 66 | after parsing: 67 | self.clist is list of dictionaries for states, 68 | """ 69 | self.filename = filename 70 | #reset 71 | self.clist = [] 72 | dlgptr = open(filename, 'r') 73 | allLines = dlgptr.readlines() 74 | #first 4 lines are ntorsions, run, cycle and temp 75 | for i in range(len(allLines)): 76 | l = allLines[i] 77 | ll = split(l) 78 | if 'ntorsions'==ll[0]: 79 | self.num_torsions = int(ll[1]) 80 | elif 'run' == ll[0]: 81 | self.run = int(ll[1]) 82 | elif 'cycle' == ll[0]: 83 | self.cycle = int(ll[1]) 84 | elif 'temp' == ll[0]: 85 | self.temp = float(ll[1]) 86 | elif 'state' == ll[0]: 87 | self.getTrajState(allLines[i:]) 88 | 89 | 90 | def getTrajState(self, lines): 91 | # BUILD A DICTIONARY and put it in clist 92 | d = {} 93 | d['num_torsions'] = self.num_torsions 94 | #lines[i] has format: 95 | #state 1 A e_total x y z qx qy qz qw 96 | #torsion 1 97 | # etc 98 | #WHEREAS in 'test-1.dlg' State= + 17 items: 3 trans, 4quat + ndihe(10) torsions 99 | xx = split(lines[0]) 100 | 101 | # remove possible punctuation 102 | for ind in range(len(xx)): 103 | if xx[ind][-1]==',': xx[ind] = xx[ind][:-1] 104 | if xx[ind][-1]=='.': xx[ind] = xx[ind][:-1] 105 | 106 | d['cycle'] = int(xx[1]) 107 | d['acc_rej_code'] = xx[2] 108 | d['docking_energy'] = float(xx[3]) 109 | d['trn_x'] = float(xx[-7]) 110 | d['trn_y'] = float(xx[-6]) 111 | d['trn_z'] = float(xx[-5]) 112 | d['qtn_nx'] = float(xx[-4]) 113 | d['qtn_ny'] = float(xx[-3]) 114 | d['qtn_nz'] = float(xx[-2]) 115 | d['qtn_ang_deg'] = float(xx[-1]) 116 | 117 | angList = [] 118 | #NB: here torsions are NOT in the same line 119 | for i in range(1, self.num_torsions+1): 120 | angList.append(float(split(lines[i])[0])) 121 | d['torsion_values'] = angList 122 | self.clist.append(d) 123 | return 124 | 125 | -------------------------------------------------------------------------------- /AutoDockTools/Utilities24/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/AutoDockTools/Utilities24/__init__.py -------------------------------------------------------------------------------- /AutoDockTools/Utilities24/gpf4_to_gpf3.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | from string import find, strip 5 | 6 | from MolKit import Read 7 | from MolKit.pdbWriter import PdbqtWriter 8 | from AutoDockTools.atomTypeTools import AutoDock4_AtomTyper 9 | from AutoDockTools.GridParameters import GridParameters, grid_parameter_list 10 | 11 | 12 | 13 | 14 | if __name__ == '__main__': 15 | import sys 16 | import getopt 17 | 18 | 19 | def usage(): 20 | "Print helpful, accurate usage statement to stdout." 21 | print("Usage: gpf4_to_gpf3.py -s gpf4_stem -r receptor_filename -l ligand_filename") 22 | print() 23 | print(" Description of command...") 24 | print(" [-s] gpf4_stem") 25 | print(" [-r] receptor_filename") 26 | print(" [-l] ligand_filename") 27 | print(" Optional parameters:") 28 | print(" [-o] outputfilename") 29 | print(" [-v] verbose output") 30 | 31 | 32 | # process command arguments 33 | try: 34 | #opt_list, args = getopt.getopt(sys.argv[1:], 'r:o:bs:ampvHG') 35 | opt_list, args = getopt.getopt(sys.argv[1:], 's:r:l:o:v') 36 | 37 | except getopt.GetoptError as msg: 38 | print('gpf4_to_gpf3.py: %s' %msg) 39 | usage() 40 | sys.exit(2) 41 | 42 | # initialize required parameters 43 | #-s: pdbq_stem 44 | gpf4_filename = None 45 | 46 | #-r: receptor_filename 47 | receptor_filename = None 48 | 49 | #-l: ligand_filename 50 | ligand_filename = None 51 | 52 | # optional parameters 53 | # optional parameters 54 | verbose = None 55 | outputfilename = None 56 | 57 | #'s:r:l:v' 58 | for o, a in opt_list: 59 | if o in ('-s', '--s'): 60 | gpf4_stem = a 61 | gpf4_filename = a + '.gpf' 62 | if verbose: print('set gpf4_filename to ', gpf4_filename) 63 | if o in ('-r', '--r'): 64 | receptor_filename = a 65 | if verbose: print('set receptor_filename to ', receptor_filename) 66 | if o in ('-l', '--l'): 67 | ligand_filename = a 68 | if verbose: print('set ligand_filename to ', ligand_filename) 69 | if o in ('-o', '--o'): 70 | outputfilename = a 71 | if verbose: print('set outputfilename to ', outputfilename) 72 | if o in ('-v', '--v'): 73 | verbose = True 74 | if verbose: print('set verbose to ', True) 75 | if o in ('-h', '--'): 76 | usage() 77 | sys.exit() 78 | 79 | 80 | if not ligand_filename: 81 | print('gpf4_to_gpf3: ligand_filename must be specified.') 82 | usage() 83 | sys.exit() 84 | if not receptor_filename: 85 | receptor_filename = gpf4_stem + '.pdbqs' 86 | print("gpf4_to_gpf3: using default receptor_filename:", receptor_filename) 87 | if not gpf4_filename: 88 | print('gpf4_to_gpf3: no gpf4_filename specified using GridParameter defaults') 89 | 90 | #what about nucleic acids??? 91 | GPO3 = GridParameters() 92 | GPO3.read4(gpf4_filename) 93 | GPO3.read(gpf4_filename) 94 | if verbose: print('read ', gpf4_filename) 95 | #have to set the ligand_types 96 | GPO3.set_ligand(ligand_filename) 97 | #build an autogrid3 'types' string from autogrid4 ligand_types 98 | GPO3.set_ligand_types3(GPO3['ligand_types']['value']) 99 | if verbose: print('set ligand to ', ligand_filename) 100 | GPO3.set_receptor(receptor_filename) 101 | if verbose: print('set receptor to ', receptor_filename) 102 | if outputfilename is None: 103 | outputfilename = gpf4_stem + '_3.gpf' 104 | GPO3.write(outputfilename, grid_parameter_list) 105 | if verbose: 106 | print("wrote ", outputfilename, ' using:') 107 | for p in grid_parameter_list: 108 | print(p) 109 | 110 | 111 | # To execute this command type: 112 | # gpf4_to_gpf3.py -s gpf4_stem -v 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /AutoDockTools/Utilities24/pdbqt_to_pdb.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | from string import find 5 | 6 | from MolKit import Read 7 | from MolKit.pdbWriter import PdbWriter 8 | 9 | 10 | 11 | 12 | if __name__ == '__main__': 13 | import sys 14 | import getopt 15 | 16 | 17 | def usage(): 18 | "Print helpful, accurate usage statement to stdout." 19 | print("Usage: pdbqt_to_pdb.py -s filename") 20 | print() 21 | print(" Description of command...") 22 | print(" [-f] pdbqt_filename") 23 | print(" Optional parameters:") 24 | print(" [-o] alternative pdb_filename") 25 | print(" [-v] verbose output") 26 | 27 | 28 | # process command arguments 29 | try: 30 | opt_list, args = getopt.getopt(sys.argv[1:], 'f:o:v') 31 | 32 | except getopt.GetoptError as msg: 33 | print('pdbqt_to_pdb.py: %s' %msg) 34 | usage() 35 | sys.exit(2) 36 | 37 | # initialize required parameters 38 | #-s: pdbqt_filename_stem 39 | pdbqt_filename = None 40 | 41 | # optional parameters 42 | verbose = None 43 | pdb_filename = None 44 | 45 | #'f:o:v' 46 | for o, a in opt_list: 47 | if o in ('-f', '--f'): 48 | pdbqt_filename = a 49 | stem = pdbqt_filename.split('.')[0] 50 | pdb_filename = stem + ".pdb" 51 | if verbose: print('set pdbqt_filename to ', pdbqt_filename) 52 | if o in ('-o', '--o'): 53 | pdb_filename = a 54 | if verbose: 55 | print('set output pdb_filename to ', a) 56 | if o in ('-v', '--v'): 57 | verbose = True 58 | if verbose: print('set verbose to ', True) 59 | if o in ('-h', '--'): 60 | usage() 61 | sys.exit() 62 | 63 | 64 | if not pdbqt_filename: 65 | print('pdbqt_to_pdb: pdbqt_filename must be specified.') 66 | usage() 67 | sys.exit() 68 | 69 | mols = Read(pdbqt_filename) 70 | if verbose: print('read ', pdbqt_filename) 71 | mol = mols[0] 72 | mol.buildBondsByDistance() 73 | #fix number for problem files with alternative positions 74 | mol.allAtoms.number = list(range(1, len(mol.allAtoms)+1)) 75 | 76 | #pdb_filename = mol.name + '.pdb' 77 | writer = PdbWriter() 78 | writer.write(pdb_filename, mol.allAtoms, records=['ATOM', 'HETATM']) 79 | 80 | if verbose: 81 | print("wrote ", ctr, " atoms to", pdb_filename) 82 | 83 | 84 | # To execute this command type: 85 | # pdbqt_to_pdb.py -f pdbqt_filename_stem [-o outputfilename] -v 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /AutoDockTools/Utilities24/pdbqt_to_pdbq.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | from string import find 5 | 6 | from MolKit import Read 7 | from MolKit.pdbWriter import PdbqWriter 8 | 9 | 10 | 11 | 12 | if __name__ == '__main__': 13 | import sys 14 | import getopt 15 | 16 | 17 | def usage(): 18 | "Print helpful, accurate usage statement to stdout." 19 | print("Usage: pdbqt_to_pdbq.py -s filename") 20 | print() 21 | print(" Description of command...") 22 | print(" [-f] pdbqt_filename") 23 | print(" Optional parameters:") 24 | print(" [-o] alternative pdbq_filename") 25 | print(" [-v] verbose output") 26 | 27 | 28 | # process command arguments 29 | try: 30 | opt_list, args = getopt.getopt(sys.argv[1:], 'f:o:v') 31 | 32 | except getopt.GetoptError as msg: 33 | print('pdbqt_to_pdbq.py: %s' %msg) 34 | usage() 35 | sys.exit(2) 36 | 37 | # initialize required parameters 38 | #-s: pdbqt_filename_stem 39 | pdbqt_filename = None 40 | 41 | # optional parameters 42 | verbose = None 43 | pdbq_filename = None 44 | 45 | #'f:o:v' 46 | for o, a in opt_list: 47 | if o in ('-f', '--f'): 48 | pdbqt_filename = a 49 | stem = pdbqt_filename.split('.')[0] 50 | pdbq_filename = stem + ".pdbq" 51 | if verbose: print('set pdbqt_filename to ', pdbqt_filename) 52 | if o in ('-o', '--o'): 53 | pdbq_filename = a 54 | if verbose: 55 | print('set output pdbq_filename to ', a) 56 | if o in ('-v', '--v'): 57 | verbose = True 58 | if verbose: print('set verbose to ', True) 59 | if o in ('-h', '--'): 60 | usage() 61 | sys.exit() 62 | 63 | 64 | if not pdbqt_filename: 65 | print('pdbqt_to_pdbq: pdbqt_filename must be specified.') 66 | usage() 67 | sys.exit() 68 | 69 | mols = Read(pdbqt_filename) 70 | if verbose: print('read ', pdbqt_filename) 71 | mol = mols[0] 72 | mol.buildBondsByDistance() 73 | #fix number for problem files with alternative positions 74 | mol.allAtoms.number = list(range(1, len(mol.allAtoms)+1)) 75 | 76 | #pdb_filename = mol.name + '.pdb' 77 | writer = PdbqWriter() 78 | #writer.write(pdbq_filename, mol.allAtoms, records=['ATOM', 'HETATM']) 79 | fptr = open(pdbq_filename, 'w') 80 | ctr = 0 81 | for l in mol.parser.allLines: 82 | if l.find('ATOM')==0 or l.find('HETATM')==0: 83 | at = mol.allAtoms[ctr] 84 | if at.autodock_element=='A': 85 | if len(at.name)==1: 86 | at.name='A' 87 | else: 88 | at.name = 'A' + at.name[1:] 89 | writer.write_atom(fptr, mol.allAtoms[ctr]) 90 | ctr = ctr + 1 91 | else: 92 | fptr.write(l) 93 | if verbose: 94 | print("wrote ", ctr, " atoms to", pdbq_filename) 95 | 96 | 97 | # To execute this command type: 98 | # pdbqt_to_pdb.py -f pdbqt_filename_stem [-o outputfilename] -v 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /AutoDockTools/Utilities24/pdbqt_to_pdbqs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | from string import find 5 | 6 | from MolKit import Read 7 | from MolKit.pdbWriter import PdbqsWriter 8 | from AutoDockTools.atomTypeTools import SolvationParameterizer 9 | 10 | 11 | 12 | 13 | if __name__ == '__main__': 14 | import sys 15 | import getopt 16 | 17 | 18 | def usage(): 19 | "Print helpful, accurate usage statement to stdout." 20 | print("Usage: pdbqt_to_pdbqs.py -s filename") 21 | print() 22 | print(" Description of command...") 23 | print(" [-s] receptor_filename_stem") 24 | print(" Optional parameters:") 25 | print(" [-o] alternative pdbqs_filename") 26 | print(" [-v] verbose output") 27 | 28 | 29 | # process command arguments 30 | try: 31 | opt_list, args = getopt.getopt(sys.argv[1:], 's:o:v') 32 | 33 | except getopt.GetoptError as msg: 34 | print('pdbqt_to_pdbqs.py: %s' %msg) 35 | usage() 36 | sys.exit(2) 37 | 38 | # initialize required parameters 39 | #-s: pdbqt_filename_stem 40 | pdbqt_filename = None 41 | 42 | # optional parameters 43 | verbose = None 44 | pdbqs_filename = None 45 | 46 | #'s:o:v' 47 | for o, a in opt_list: 48 | if o in ('-s', '--s'): 49 | pdbqt_filename = a + ".pdbqt" 50 | pdbqs_filename = a + ".pdbqs" 51 | if verbose: print('set AD4 receptor_filename to ', pdbqt_filename) 52 | if o in ('-o', '--o'): 53 | pdbqs_filename = a 54 | if verbose: 55 | print('set AD3 pdbqs_filename to ', a) 56 | if o in ('-v', '--v'): 57 | verbose = True 58 | if verbose: print('set verbose to ', True) 59 | if o in ('-h', '--'): 60 | usage() 61 | sys.exit() 62 | 63 | 64 | if not pdbqt_filename: 65 | print('pdbqt_to_pdbqs: pdbqt_filename_stem must be specified.') 66 | usage() 67 | sys.exit() 68 | 69 | #what about nucleic acids??? 70 | 71 | mols = Read(pdbqt_filename) 72 | if verbose: print('read ', pdbqt_filename) 73 | mol = mols[0] 74 | #fix number for problem files with alternative positions 75 | mol.allAtoms.number = list(range(1, len(mol.allAtoms)+1)) 76 | 77 | #possible clean-up??? 78 | #need to type atoms + assign babel_types 79 | solparer = SolvationParameterizer() 80 | solparer.addParameters(mol.allAtoms) 81 | if verbose: 82 | print("set autodock3 solvation parameters for ", mol.name) 83 | 84 | #pdbqs_filename = mol.name + '.pdbqs' 85 | writer = PdbqsWriter() 86 | fptr = open(pdbqs_filename, 'w') 87 | ctr = 0 88 | for line in mol.parser.allLines: 89 | if find(line, 'ATOM')<0 and find(line, "HETA")<0: 90 | fptr.write(line) 91 | else: 92 | this_atom = mol.allAtoms[ctr] 93 | writer.write_atom(fptr, this_atom) 94 | ctr = ctr + 1 95 | fptr.close() 96 | if verbose: 97 | print("wrote ", ctr, " atoms to", pdbqs_filename) 98 | 99 | 100 | # To execute this command type: 101 | # pdbqt_to_pdbqs.py -s pdbqt_filename_stem -v 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /AutoDockTools/Utilities24/prepare_gpf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # 4 | # 5 | # $Header: /opt/cvs/python/packages/share1.5/AutoDockTools/Utilities24/prepare_gpf.py,v 1.6 2007/10/09 17:30:07 annao Exp $ 6 | # 7 | 8 | import _py2k_string as string 9 | import os.path 10 | from math import ceil 11 | from MolKit import Read 12 | from AutoDockTools.GridParameters import GridParameters, grid_parameter_list 13 | from AutoDockTools.GridParameters import GridParameterFileMaker 14 | 15 | 16 | def usage(): 17 | print("Usage: prepare_gpf.py -l pdbq_file -r pdbqs_file ") 18 | print(" -l ligand_filename") 19 | print(" -r receptor_filename") 20 | print() 21 | print("Optional parameters:") 22 | print(" [-i reference_gpf_filename]") 23 | print(" [-o output_gpf_filename]") 24 | print(" [-p parameter=newvalue]") 25 | print(" [-v]") 26 | print() 27 | print("Prepare a grid parameter file (GPF) for AutoDock.") 28 | print() 29 | print(" The GPF will by default be .gpf. This") 30 | print("may be overridden using the -o flag.") 31 | 32 | 33 | if __name__ == '__main__': 34 | import getopt 35 | import sys 36 | 37 | try: 38 | opt_list, args = getopt.getopt(sys.argv[1:], 'vl:r:i:o:p:') 39 | except getopt.GetoptError as msg: 40 | print('prepare_gpf.py: %s' % msg) 41 | usage() 42 | sys.exit(2) 43 | 44 | receptor_filename = ligand_filename = None 45 | list_filename = gpf_filename = gpf_filename = None 46 | output_gpf_filename = None 47 | parameters = [] 48 | verbose = None 49 | for o, a in opt_list: 50 | if o in ('-v', '--v'): 51 | verbose = 1 52 | if o in ('-l', '--l'): 53 | ligand_filename = a 54 | if verbose: print('ligand_filename=', ligand_filename) 55 | if o in ('-r', '--r'): 56 | receptor_filename = a 57 | if verbose: print('receptor_filename=', receptor_filename) 58 | if o in ('-i', '--i'): 59 | gpf_filename = a 60 | if verbose: print('reference_gpf_filename=', gpf_filename) 61 | if o in ('-o', '--o'): 62 | output_gpf_filename = a 63 | if verbose: print('output_gpf_filename=', output_gpf_filename) 64 | if o in ('-p', '--p'): 65 | parameters.append(a) 66 | if verbose: print('parameters=', parameters) 67 | if o in ('-h', '--'): 68 | usage() 69 | sys.exit() 70 | 71 | 72 | if (not receptor_filename) or (not ligand_filename): 73 | print("prepare_gpf.py: ligand and receptor filenames") 74 | print(" must be specified.") 75 | usage() 76 | sys.exit() 77 | 78 | gpfm = GridParameterFileMaker(verbose=verbose) 79 | gpfm.set_ligand(ligand_filename) 80 | gpfm.set_receptor(receptor_filename) 81 | if gpf_filename is not None: 82 | gpfm.read_reference(gpf_filename) 83 | for p in parameters: 84 | key,newvalue = string.split(p, '=') 85 | kw = {key:newvalue} 86 | gpfm.set_grid_parameters(*(), **kw) 87 | #gpfm.set_grid_parameters(spacing=1.0) 88 | gpfm.write_gpf(output_gpf_filename) 89 | 90 | 91 | #prepare_gpf.py -l indinavir.pdbq -r 1hsg.pdbqs -p spacing=0.4 -p npts=[60,60,60] -i ref.gpf -o testing.dpf 92 | 93 | -------------------------------------------------------------------------------- /AutoDockTools/Utilities24/process_VSResultsFox.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # 4 | ############################################################################## 5 | # 6 | # Authors: Stefano FORLI , Ruth HUEY 7 | # 8 | # Copyright: A. Olson TSRI 2011 9 | # 10 | ############################################################################# 11 | 12 | # $Header: /opt/cvs/python/packages/share1.5/AutoDockTools/Utilities24/process_VSResultsFox.py,v 1.1 2011/05/05 18:26:21 rhuey Exp $ 13 | # 14 | # $Id: process_VSResultsFox.py,v 1.1 2011/05/05 18:26:21 rhuey Exp $ 15 | # 16 | 17 | """ 18 | This script creates a pdbqt+ file containing docked coordinates, docked 19 | energy as well as other important summary information about the docking. 20 | Input for the script is a 'directory' containing 1 or more docking log files 21 | (*.dlg) from AutoDock calculations and the 'receptor filename'. The script 22 | reclusters the results and includes a summary of the clustering in the pdbqt+. 23 | """ 24 | import os, glob, time 25 | from AutoDockTools.Docking import FoxResultProcessor 26 | 27 | 28 | if __name__ == '__main__': 29 | import sys 30 | import getopt 31 | 32 | #'d:t:f:r:BLx:Dnc vh' 33 | 34 | def usage(): 35 | "Print helpful, accurate usage statement to stdout." 36 | print("Usage: process_VSResultsFox.py -d directory") 37 | print() 38 | print(" Description of command...") 39 | print(" -r receptor filename ") 40 | print(" -d directory") 41 | print(" Optional parameters:") 42 | print(" [-t] rmsd tolerance (default is 2.0)") 43 | print(" [-v] verbose output") 44 | 45 | 46 | # process command arguments 47 | try: 48 | opt_list, args = getopt.getopt(sys.argv[1:], 'r:d:t:vh') 49 | except getopt.GetoptError as msg: 50 | print('process_VSResultsFox.py: %s' %msg) 51 | usage() 52 | sys.exit(2) 53 | 54 | # initialize required parameters 55 | #-d: directory 56 | directory = None 57 | #-r receptor_filename 58 | receptor_filename = None 59 | 60 | # optional parameters 61 | #-t: rms_tolerance 62 | rms_tolerance = 2.0 63 | 64 | # -v verbose output 65 | verbose = None 66 | 67 | # r:d:t:vh 68 | for o, a in opt_list: 69 | if o in ('-r', '--r'): 70 | receptor_filename = a 71 | if verbose: print('set receptor_filename to ', receptor_filename) 72 | if o in ('-d', '--d'): 73 | directory = a 74 | if verbose: print('set directory to ', a) 75 | if o in ('-t', '--t'): 76 | rms_tolerance = float(a) 77 | if verbose: print('set rms_tolerance to ', rms_tolerance) 78 | if o in ('-v', '--v'): 79 | verbose = True 80 | if verbose: print('set verbose to ', True) 81 | if o in ('-h', '--'): 82 | usage() 83 | sys.exit() 84 | 85 | if not directory: 86 | print('process_VSResultsFox: directory must be specified.') 87 | usage() 88 | sys.exit() 89 | 90 | if receptor_filename is None: 91 | print('process_VSResultsFox: receptor_filename must be specified.') 92 | usage() 93 | sys.exit() 94 | 95 | frp = FoxResultProcessor(receptor_filename) 96 | frp.process(directory=directory, rms_tolerance=rms_tolerance) 97 | 98 | -------------------------------------------------------------------------------- /AutoDockTools/Utilities24/repair_ligand4.py: -------------------------------------------------------------------------------- 1 | 2 | #!/usr/bin/env python 3 | 4 | import os 5 | from string import find 6 | 7 | from MolKit import Read 8 | from MolKit.pdbWriter import PdbqWriter 9 | from MolKit.molecule import AtomSet 10 | 11 | from AutoDockTools.MoleculePreparation import AD4LigandPreparation 12 | 13 | 14 | if __name__ == '__main__': 15 | import sys 16 | import getopt 17 | 18 | 19 | def usage(): 20 | "Print helpful, accurate usage statement to stdout." 21 | print("Usage: repair_ligand4.py -s filename") 22 | print() 23 | print(" Description of command...") 24 | print(" [-f] pdbqt_filename") 25 | print(" Optional parameters:") 26 | print(" [-o] alternative pdbqt_filename") 27 | print(" (default is 'repaired_' +pdbqt_filename)") 28 | print(" [-v] verbose output") 29 | 30 | 31 | # process command arguments 32 | try: 33 | opt_list, args = getopt.getopt(sys.argv[1:], 'f:o:v') 34 | 35 | except getopt.GetoptError as msg: 36 | print('repair_ligand4.py: %s' %msg) 37 | usage() 38 | sys.exit(2) 39 | 40 | # initialize required parameters 41 | #-f: pdbqt_filename_stem 42 | pdbqt_filename = None 43 | 44 | # optional parameters 45 | verbose = None 46 | outputfilename = None 47 | 48 | #'f:o:v' 49 | for o, a in opt_list: 50 | if o in ('-f', '--f'): 51 | pdbqt_filename = a 52 | if verbose: print('set pdbqt_filename to ', pdbqt_filename) 53 | outputfilename = 'repaired_' + pdbqt_filename 54 | if o in ('-o', '--o'): 55 | outputfilename = a 56 | if verbose: 57 | print('set output outputfilename to ', a) 58 | if o in ('-v', '--v'): 59 | verbose = True 60 | if verbose: print('set verbose to ', True) 61 | if o in ('-h', '--'): 62 | usage() 63 | sys.exit() 64 | 65 | 66 | if not pdbqt_filename: 67 | print('repair_ligand4: pdbqt_filename must be specified.') 68 | usage() 69 | sys.exit() 70 | 71 | mol = Read(pdbqt_filename)[0] 72 | if verbose: print('read ', pdbqt_filename) 73 | mol.buildBondsByDistance() 74 | mol.LPO = AD4LigandPreparation(mol, mode='interactive', repairs='', charges_to_add=None, 75 | root=0, outputfilename=outputfilename, cleanup='') 76 | #rebuild torTree 77 | allAts = mol.allAtoms 78 | for b in allAts.bonds[0]: 79 | if b.activeTors: b.activeTors = 0 80 | torscount = 0 81 | tM = mol.torTree.torsionMap 82 | for i in range(len(tM)): 83 | bnum0, bnum1 = tM[i].bond 84 | a0 = allAts.get(lambda x: x.number==bnum0 + 1)[0] 85 | a0.tt_ind = bnum0 86 | a1 = allAts.get(lambda x: x.number==bnum1 + 1)[0] 87 | a1.tt_ind = bnum1 88 | b = AtomSet([a0,a1]).bonds[0] 89 | if hasattr(b, 'possibleTors'): 90 | assert b.possibleTors 91 | else: 92 | b.possibleTors = 1 93 | b.activeTors = 1 94 | torscount = torscount + 1 95 | mol.torscount = torscount 96 | mol.ROOT = mol.allAtoms[0] 97 | mol.ROOT.rnum0 = 0 98 | mol.LPO.write(outputfilename) 99 | 100 | 101 | # To execute this command type: 102 | # repair_ligand4.py -f pdbqt_filename [-o outputfilename] -v 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /AutoDockTools/Utilities24/summarize_epdb_results4.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # 4 | # 5 | # $Header: /opt/cvs/python/packages/share1.5/AutoDockTools/Utilities24/summarize_epdb_results4.py,v 1.2.6.2 2016/03/11 00:52:51 annao Exp $ 6 | # 7 | # $Id: summarize_epdb_results4.py,v 1.2.6.2 2016/03/11 00:52:51 annao Exp $ 8 | # 9 | import os, glob 10 | import numpy 11 | from AutoDockTools.EpdbParser import EpdbParser 12 | 13 | 14 | 15 | if __name__ == '__main__': 16 | import sys 17 | import getopt 18 | 19 | 20 | def usage(): 21 | "Print helpful, accurate usage statement to stdout." 22 | print("Usage: summarize_epdb_results4.py -f epdb_dlgfilename") 23 | print() 24 | print(" Description of command...") 25 | print(" -f epdb_dlgfilename") 26 | print(" Optional parameters:") 27 | print(" [-o] output filename") 28 | print(" (default is 'summary_of_epdb_results')") 29 | print(" [-a] append to output filename") 30 | print(" (default is to open output filename 'w')") 31 | print(" [-v] verbose output") 32 | 33 | 34 | # process command arguments 35 | try: 36 | opt_list, args = getopt.getopt(sys.argv[1:], 'f:o:avh') 37 | except getopt.GetoptError as msg: 38 | print('summarize_epdb_results4.py: %s' %msg) 39 | usage() 40 | sys.exit(2) 41 | 42 | # initialize required parameters 43 | #-f: epdb_dlgfilename 44 | epdb_dlgfilename = None 45 | # optional parameters 46 | #-o outputfilename 47 | outputfilename = "summary_of_epdb_results" 48 | #-a append to outputfile 49 | append_to_outputfile = False 50 | #-v verbose 51 | verbose = False 52 | 53 | #'f:o:avh' 54 | for o, a in opt_list: 55 | #print "o=", o, " a=", a 56 | if o in ('-f', '--f'): 57 | epdb_dlgfilename = a 58 | if verbose: print('set epdb_dlgfilename to ', a) 59 | if o in ('-o', '--o'): 60 | outputfilename = a 61 | if verbose: print('set outputfilename to ', a) 62 | if o in ('-a', '--a'): 63 | append_to_outputfile = True 64 | if verbose: print('set append_to_outputfile to ', True) 65 | if o in ('-v', '--v'): 66 | verbose = True 67 | if verbose: print('set verbose to ', True) 68 | if o in ('-h', '--'): 69 | usage() 70 | sys.exit() 71 | 72 | if not epdb_dlgfilename: 73 | print('summarize_epdb_results4: epdb_dlgfilename must be specified.') 74 | usage() 75 | sys.exit() 76 | 77 | ep = EpdbParser(epdb_dlgfilename) 78 | mode = 'w' 79 | first = True 80 | if append_to_outputfile: 81 | mode = 'a' 82 | first = not os.path.exists(outputfilename) 83 | fptr = open(outputfilename, mode) 84 | 85 | if verbose: print("first is ", first) 86 | if first: 87 | tstr = " dlgfn estFE IntermolE InternalE torsFE sumTotal sumEstat sumVDW #at #tors\n " 88 | fptr.write(tstr) 89 | ostr = "%10s,%10.2f,%10.2f,%11.2f,%10.2f,%10.2f,%10.2f,%10.2f,%4d,%5d\n"%(os.path.basename(epdb_dlgfilename), \ 90 | ep.estFreeEnergy, ep.finalIntermolEnergy, \ 91 | ep.finalTotalInternalEnergy, ep.torsionalFreeEnergy, \ 92 | numpy.add.reduce(ep.total_energies), \ 93 | numpy.add.reduce(ep.estat_energies), \ 94 | numpy.add.reduce(ep.vdw_energies), ep.atmCtr, ep.ntors) 95 | fptr.write(ostr) 96 | fptr.close() 97 | 98 | 99 | 100 | # To execute this command type: 101 | # summarize_epdb_results4.py -d directory -t rmsd tolerance 102 | # -f epdb_dlgfilename 103 | # -o outputfilename 104 | # -a append to outputfilename 105 | # -v verbose output 106 | -------------------------------------------------------------------------------- /AutoDockTools/Utilities24/summarize_time.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # 4 | # 5 | # $Header: /opt/cvs/python/packages/share1.5/AutoDockTools/Utilities24/summarize_time.py,v 1.4.2.1 2016/02/11 09:24:08 annao Exp $ 6 | # 7 | import os, glob 8 | from AutoDockTools.DlgParser import DlgParser 9 | 10 | 11 | if __name__ == '__main__': 12 | import sys 13 | import getopt 14 | 15 | 16 | def usage(): 17 | "Print helpful, accurate usage statement to stdout." 18 | print("Usage: summarize_time.py -d directory") 19 | print() 20 | print(" Description of command...") 21 | print(" -d directory") 22 | print(" Optional parameters:") 23 | print(" [-o] output filename") 24 | print(" (default is 'summary_of_time')") 25 | print(" [-v] verbose output") 26 | 27 | 28 | # process command arguments 29 | try: 30 | opt_list, args = getopt.getopt(sys.argv[1:], 'd:o:vh') 31 | except getopt.GetoptError as msg: 32 | print('summarize_time.py: %s' %msg) 33 | usage() 34 | sys.exit(2) 35 | 36 | # initialize required parameters 37 | #-d: directory 38 | directory = None 39 | 40 | # optional parameters 41 | #-o outputfilename 42 | outputfilename = "summary_of_time.txt" 43 | #-v: verbose 44 | verbose = None 45 | #-h: help 46 | help = None 47 | 48 | 49 | #'d:o:vh' 50 | for o, a in opt_list: 51 | #print "o=", o, " a=", a 52 | if o in ('-d', '--d'): 53 | directory = a 54 | if verbose: print('set directory to ', a) 55 | if o in ('-o', '--o'): 56 | outputfilename = a 57 | if verbose: print('set outputfilename to ', a) 58 | if o in ('-v', '--v'): 59 | verbose = True 60 | if verbose: print('set verbose to ', True) 61 | if o in ('-h', '--'): 62 | usage() 63 | sys.exit() 64 | 65 | if not directory: 66 | print('summarize_time: directory must be specified.') 67 | usage() 68 | sys.exit() 69 | 70 | p = DlgParser() 71 | dlg_list = glob.glob(directory + '/*.dlg') 72 | total_time = 0 73 | for dlg in dlg_list: 74 | p.parse(dlg) 75 | total_time = total_time + p.total_time 76 | if verbose: print("dlg time=", total_time) 77 | stem = dlg_list[0].split('.')[0] 78 | mins = total_time/60. 79 | if verbose: print("total time in minutes =", mins) 80 | ostr = '%s: % 12.4f m \n' %(directory, mins) 81 | fptr = open(outputfilename, 'a') 82 | fptr.write(ostr) 83 | fptr.close() 84 | 85 | # To execute this command type: 86 | # summarize_time.py -d directory -o outputfilename -v 87 | 88 | -------------------------------------------------------------------------------- /AutoDockTools/Utilities24/write_conformations_from_dlg.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # 4 | # 5 | # $Header: /opt/cvs/python/packages/share1.5/AutoDockTools/Utilities24/write_conformations_from_dlg.py,v 1.4.8.1 2015/08/26 22:45:31 sanner Exp $ 6 | # 7 | # $Id: write_conformations_from_dlg.py,v 1.4.8.1 2015/08/26 22:45:31 sanner Exp $ 8 | # 9 | import os 10 | 11 | from AutoDockTools.Docking import Docking 12 | 13 | 14 | if __name__ == '__main__': 15 | import sys 16 | import getopt 17 | 18 | 19 | def usage(): 20 | "Print helpful, accurate usage statement to stdout." 21 | print("Usage: write_conformations_from_dlg.py -d directory") 22 | print() 23 | print(" Description of command...") 24 | print(" -d docking filename") 25 | print(" Optional parameters:") 26 | print(" [-o] output file stem") 27 | print(" (default is ligandname. Outputfiles are named 'stem' plus '_num.pdbq[t]')") 28 | print(" [-v] verbose output") 29 | 30 | 31 | # process command arguments 32 | try: 33 | opt_list, args = getopt.getopt(sys.argv[1:], 'd:o:vh') 34 | except getopt.GetoptError as msg: 35 | print('write_conformations_from_dlg.py: %s' %msg) 36 | usage() 37 | sys.exit(2) 38 | 39 | # initialize required parameters 40 | #-d: docking log filename 41 | docking_filename = None 42 | 43 | # initialize optional parameter 44 | #-o output_stem 45 | output_stem = None 46 | #-v verbose best only 47 | verbose = False 48 | 49 | #'d:bvh' 50 | for o, a in opt_list: 51 | #print "o=", o, " a=", a 52 | if o in ('-d', '--d'): 53 | docking_filename = a 54 | if verbose: print('set docking_filename to ', a) 55 | if o in ('-o', '--o'): 56 | output_stem = a 57 | if verbose: print('set output_stem to ', a) 58 | if o in ('-v', '--v'): 59 | verbose = True 60 | if verbose: print('set verbose to ', True) 61 | if o in ('-h', '--'): 62 | usage() 63 | sys.exit() 64 | 65 | if not docking_filename: 66 | print('write_conformations_from_dlg: docking_filename must be specified.') 67 | usage() 68 | sys.exit() 69 | 70 | 71 | d = Docking() 72 | d.readDlg(docking_filename) 73 | lines = d.ligMol.parser.allLines 74 | for i in range(len(lines)): 75 | line = lines[i] 76 | if line.find("\n")==-1: 77 | d.ligMol.parser.allLines[i] = line + "\n" 78 | ext = '.pdbq' 79 | if d.version>=4.0: 80 | ext = '.pdbqt' 81 | 82 | if output_stem is None: 83 | output_stem = d.ligMol.name 84 | 85 | for ix, conf in enumerate(d.ch.conformations): 86 | outfile= output_stem + '_' + str(ix+1) + ext 87 | conf = d.ch.conformations[ix] 88 | d.ligMol.parser.write_with_new_coords(conf.getCoords(),outfile) 89 | if verbose: print("wrote ", outfile) 90 | 91 | 92 | # To execute this command type: 93 | # write_conformations_from_dlg.py -d docking_filename 94 | # optional arguments 95 | # -o outputfile_stem (default is ligandname) 96 | -------------------------------------------------------------------------------- /AutoDockTools/Utilities24/write_each_cluster_LE_conf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # 4 | # 5 | # $Header: /opt/cvs/python/packages/share1.5/AutoDockTools/Utilities24/write_each_cluster_LE_conf.py,v 1.3 2011/12/27 22:41:53 rhuey Exp $ 6 | # 7 | import os, glob 8 | 9 | from MolKit import Read 10 | from AutoDockTools.Docking import Docking 11 | from mglutil.math.rmsd import RMSDCalculator 12 | from string import strip 13 | 14 | 15 | 16 | 17 | if __name__ == '__main__': 18 | import sys 19 | import getopt 20 | 21 | 22 | def usage(): 23 | print("Usage: write_largest_cluster_ligand.py ") 24 | print(" This script does the following: ") 25 | print(" (1) read all the files with extension '.dlg' into one Docking") 26 | print(" (2) compute a clustering at the specified rms tolerance ") 27 | print(" (3) write the ligand with the coordinates of the ") 28 | print(" lowest-energy conformation in each cluster to a separate file") 29 | print(" ") 30 | print(" Optional parameters:") 31 | print(" [-t] rms_tolerance (default 2.0)") 32 | print(" [-o pdbqt_filename] (default ligandstem_clust#.pdbqt)") 33 | print(" [-v] verbose output") 34 | 35 | # process command arguments 36 | try: 37 | opt_list, args = getopt.getopt(sys.argv[1:], 't:o:vh') 38 | except getopt.GetoptError as msg: 39 | print('write_each_cluster_LE_conf.py: %s' %msg) 40 | usage() 41 | sys.exit(2) 42 | 43 | # initialize required parameters 44 | # optional parameters 45 | verbose = None 46 | #-o outputfilestem 47 | outputfilestem = None 48 | #-t rms_tolerance 49 | rms_tolerance = 2.0 50 | 51 | #'t:o:vh' 52 | for o, a in opt_list: 53 | #print "o=", o, " a=", a 54 | if o in ('-o', '--o'): 55 | outputfilestem = a 56 | if verbose: print('set stem for outputfile to ', a) 57 | if o in ('-t', '--t'): 58 | rms_tolerance = float(a) 59 | if verbose: print('set rms_tolerance to ', a) 60 | if o in ('-v', '--v'): 61 | verbose = True 62 | if verbose: print('set verbose to ', True) 63 | if o in ('-h', '--'): 64 | usage() 65 | sys.exit() 66 | 67 | dlg_list = glob.glob('*.dlg') 68 | d = Docking() 69 | for dlg in dlg_list: 70 | d.readDlg(dlg) 71 | d.clusterer.rmsTool = RMSDCalculator(d.ligMol.allAtoms.coords[:]) 72 | d.clusterer.make_clustering(rms_tolerance) 73 | clustering = d.clusterer.clustering_dict[rms_tolerance] 74 | for clust in clustering: 75 | clustStr = str(clustering.index(clust)) 76 | if verbose: print("processing clust number ", clustStr) 77 | #update the coordinates to those of conf with lowest energy in current cluster 78 | d.ch.set_conformation(clust[0]) 79 | parser = d.ligMol.parser 80 | lines = [] 81 | #have to add newline character to lines read from dlg 82 | for l in parser.allLines: 83 | l = strip(l) 84 | l+= '\n' 85 | lines.append(l) 86 | parser.allLines = lines 87 | coords = d.ligMol.allAtoms.coords 88 | if outputfilestem is None: 89 | parser.write_with_new_coords(coords, d.ligMol.name + "_LE_clust"+clustStr +'.pdbqt') 90 | else: 91 | parser.write_with_new_coords(coords, outputfilestem + clustStr +'.pdbqt') 92 | if verbose: print('wrote %s' %outputfilestem) 93 | 94 | 95 | # To execute this command type: 96 | # write_each_cluster_LE_conf.py [-t rms_tolerance, -o outputfilestem] -v 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /AutoDockTools/Utilities24/write_largest_cluster_ligand.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # 4 | # 5 | # $Header: /opt/cvs/python/packages/share1.5/AutoDockTools/Utilities24/write_largest_cluster_ligand.py,v 1.3 2008/05/28 15:40:15 rhuey Exp $ 6 | # 7 | import os, glob 8 | 9 | from MolKit import Read 10 | from AutoDockTools.Docking import Docking 11 | from mglutil.math.rmsd import RMSDCalculator 12 | 13 | 14 | 15 | 16 | if __name__ == '__main__': 17 | import sys 18 | import getopt 19 | 20 | 21 | def usage(): 22 | print("Usage: write_largest_cluster_ligand.py ") 23 | print(" This script does the following: ") 24 | print(" (1) read all the files with extension '.dlg' into one Docking") 25 | print(" (2) compute a clustering at the specified rms tolerance ") 26 | print(" (3) write the ligand with the coordinates of the ") 27 | print(" lowest-energy conformation in the largest cluster to a file") 28 | print(" ") 29 | print(" Optional parameters:") 30 | print(" [-t] rms_tolerance (default 1.5)") 31 | print(" [-o pdbqt_filename] (default ligandstem_BC.pdbqt)") 32 | print(" [-v] verbose output") 33 | 34 | # process command arguments 35 | try: 36 | opt_list, args = getopt.getopt(sys.argv[1:], 't:o:vh') 37 | except getopt.GetoptError as msg: 38 | print('write_largest_cluster_ligand.py: %s' %msg) 39 | usage() 40 | sys.exit(2) 41 | 42 | # initialize required parameters 43 | # optional parameters 44 | verbose = None 45 | #-o outputfilename 46 | outputfilename = None 47 | #-t rms_tolerance 48 | rms_tolerance = 1.5 49 | 50 | #'t:o:vh' 51 | for o, a in opt_list: 52 | #print "o=", o, " a=", a 53 | if o in ('-o', '--o'): 54 | outputfilename = a 55 | if verbose: print('set outputfilename to ', a) 56 | if o in ('-t', '--t'): 57 | rms_tolerance = float(a) 58 | if verbose: print('set rms_tolerance to ', a) 59 | if o in ('-v', '--v'): 60 | verbose = True 61 | if verbose: print('set verbose to ', True) 62 | if o in ('-h', '--'): 63 | usage() 64 | sys.exit() 65 | 66 | dlg_list = glob.glob('*.dlg') 67 | d = Docking() 68 | for dlg in dlg_list: 69 | d.readDlg(dlg) 70 | d.clusterer.rmsTool = RMSDCalculator(d.ligMol.allAtoms.coords[:]) 71 | d.clusterer.make_clustering(rms_tolerance) 72 | clustering = d.clusterer.clustering_dict[rms_tolerance] 73 | largest = clustering[0] 74 | for clust in clustering: 75 | if len(clust)>len(largest): 76 | largest = clust 77 | #update the coordinates with those of conf with lowest energy in this largest cluster 78 | d.ch.set_conformation(largest[0]) 79 | parser = d.ligMol.parser 80 | lines = [] 81 | #have to add newline character to lines read from dlg 82 | for l in parser.allLines: 83 | l+= '\n' 84 | lines.append(l) 85 | parser.allLines = lines 86 | coords = d.ligMol.allAtoms.coords 87 | if outputfilename is None: 88 | outputfilename = d.ligMol.name + '_BC.pdbqt' 89 | parser.write_with_new_coords(coords, outputfilename) 90 | if verbose: 91 | print('wrote %s' %outputfilename) 92 | 93 | 94 | # To execute this command type: 95 | # write_largest_cluster_ligand.py [-t rms_tolerance, -o outputfilename] -v 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /AutoDockTools/Utilities24/write_rigid_ligand.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # 4 | # 5 | # $Header: /opt/cvs/python/packages/share1.5/AutoDockTools/Utilities24/write_rigid_ligand.py,v 1.1 2008/05/28 16:48:41 rhuey Exp $ 6 | # 7 | import os, _py2k_string as string 8 | from MolKit import Read 9 | 10 | 11 | 12 | 13 | if __name__ == '__main__': 14 | import sys 15 | import getopt 16 | 17 | 18 | def usage(): 19 | print("Usage: write_rigid_ligand.py ") 20 | print(" This writes a rigid ligandfile with no rotatable bonds") 21 | print(" -l ligand_filename") 22 | print(" Optional parameters:") 23 | print(" [-o pdbqt_filename] (default ligandstem_rigid.pdbqt)") 24 | print(" [-v] verbose output") 25 | 26 | # process command arguments 27 | try: 28 | opt_list, args = getopt.getopt(sys.argv[1:], 'l:o:vh') 29 | except getopt.GetoptError as msg: 30 | print('write_rigid_ligand.py: %s' %msg) 31 | usage() 32 | sys.exit(2) 33 | 34 | # initialize required parameters 35 | # optional parameters 36 | verbose = None 37 | #-l ligandfilename 38 | ligandfilename = None 39 | #-o outputfilename 40 | outputfilename = None 41 | 42 | #'l:o:vh' 43 | for o, a in opt_list: 44 | if o in ('-l', '--l'): 45 | ligandfilename = a 46 | if verbose: print('set ligandfilename to ', a) 47 | if o in ('-o', '--o'): 48 | outputfilename = a 49 | if verbose: print('set outputfilename to ', a) 50 | if o in ('-v', '--v'): 51 | verbose = True 52 | if verbose: print('set verbose to ', True) 53 | if o in ('-h', '--'): 54 | usage() 55 | sys.exit() 56 | if not ligandfilename: 57 | print("write_rigid_ligand.py: ligandfilename must be specified.") 58 | usage() 59 | sys.exit() 60 | 61 | lig = Read(ligandfilename)[0] 62 | ext = os.path.splitext(ligandfilename)[1] 63 | if outputfilename is None: 64 | outputfilename = lig.name + "_rigid" + ext 65 | if verbose: print('set outputfilename to ', outputfilename) 66 | parser = lig.parser 67 | optr = open(outputfilename, 'w') 68 | #have to add newline character to lines read from dlg 69 | for l in parser.allLines: 70 | if l.find("active torsions:")>-1: 71 | nl = "REMARK 0 active torsions:\n" 72 | optr.write(nl) 73 | elif l.find("A between atoms:")>-1: 74 | ll = l.split() 75 | #REMARK,1,A,between,atoms:,N1_1517,and,C31_1555" 76 | nl = ll[0] + " I " + string.join(ll[3:]) + "\n" 77 | optr.write(nl) 78 | elif l.find("TORSDOF")==0: 79 | nl = "ENDROOT\n" 80 | optr.write(nl) 81 | optr.write(l) 82 | elif l.find("BRANCH")==-1 and l.find("ENDBRANCH")==-1 and l.find("ENDROOT")==-1: 83 | optr.write(l) 84 | if verbose: 85 | print('wrote %s' %outputfilename) 86 | 87 | 88 | # To execute this command type: 89 | # write_rigid_ligand.py -l ligandfilename [-o outputfilename] -v 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Filter/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/AutoDockTools/VisionInterface/Adt/Filter/__init__.py -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Input/AutogridResDirectoryBrowser.py: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # 3 | # Date: Nov 2001 Authors: Michel Sanner 4 | # 5 | # sanner@scripps.edu 6 | # 7 | # The Scripps Research Institute (TSRI) 8 | # Molecular Graphics Lab 9 | # La Jolla, CA 92037, USA 10 | # 11 | # Copyright: Michel Sanner and TSRI 12 | # 13 | ######################################################################### 14 | 15 | from NetworkEditor.items import NetworkNode 16 | 17 | from AutoDockTools.VisionInterface.Adt.autogrid_results import autogrid_results 18 | 19 | import os 20 | 21 | class AutogridResDirectoryBrowser(NetworkNode): 22 | """ 23 | Browse local directory that contains Autogrid results. 24 | The directory will be compressed into a zip file. 25 | 26 | Input: Directory that contains autogrid results 27 | 28 | Output: 29 | port 1: autogrid_result object that contains info about the autogrid result directory 30 | port 2: path to compressed autogrid directory. 31 | """ 32 | 33 | def __init__(self, name='AutogridResDirectoryBrowser', **kw): 34 | kw['name'] = name 35 | NetworkNode.__init__(*(self,), **kw) 36 | 37 | 38 | kw['name'] = name 39 | NetworkNode.__init__(*(self,), **kw) 40 | ip = self.inputPortsDescr 41 | ip.append(datatype='string', name='directory') 42 | 43 | self.widgetDescr['directory'] = { 44 | 'class':'NEEntryWithDirectoryBrowser', 'master':'node', 'width':16, 45 | 'initialValue':'', 'labelCfg':{'text':'Autogrid result directory: '} 46 | } 47 | 48 | op = self.outputPortsDescr 49 | op.append(datatype='autogrid_results', name='autogrid_result') 50 | op = self.outputPortsDescr 51 | op.append(datatype='string', name='zip_file_path') 52 | 53 | code = """def doit(self, directory): 54 | autogrid_result = autogrid_results(directory, "local") 55 | 56 | self.outputData(autogrid_result=autogrid_result, zip_file_path=autogrid_result.path) 57 | """ 58 | self.setFunction(code) 59 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Input/AutogridResURL.py: -------------------------------------------------------------------------------- 1 | from NetworkEditor.items import NetworkNode 2 | 3 | from AutoDockTools.VisionInterface.Adt.autogrid_results import autogrid_results 4 | 5 | class AutogridResURL(NetworkNode): 6 | """ 7 | Creates an autogrid_results object form a URL to the autogrid results 8 | 9 | Input: URL to autogrid results 10 | Output: autogrid_results object that contains info about the URL to autogrid results 11 | """ 12 | 13 | def __init__(self, name='AutogridResURL', **kw): 14 | kw['name'] = name 15 | NetworkNode.__init__(*(self,), **kw) 16 | 17 | 18 | kw['name'] = name 19 | NetworkNode.__init__(*(self,), **kw) 20 | ip = self.inputPortsDescr 21 | ip.append(datatype='string', name='url') 22 | 23 | self.widgetDescr['url'] = { 24 | 'class':'NEEntry', 'master':'node', 'width':40, 25 | 'labelCfg':{'text':'URL to Autogrid Results: '} 26 | } 27 | 28 | op = self.outputPortsDescr 29 | op.append(datatype='autogrid_results', name='autogrid_res_obj') 30 | 31 | code = """def doit(self, url): 32 | autogrid_res_obj=autogrid_results(url, "url") 33 | 34 | self.outputData(autogrid_res_obj=autogrid_res_obj) 35 | """ 36 | self.setFunction(code) 37 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Input/DPFTemplateBrowser.py: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # 3 | # Date: Nov 2001 Authors: Michel Sanner 4 | # 5 | # sanner@scripps.edu 6 | # 7 | # The Scripps Research Institute (TSRI) 8 | # Molecular Graphics Lab 9 | # La Jolla, CA 92037, USA 10 | # 11 | # Copyright: Michel Sanner and TSRI 12 | # 13 | ######################################################################### 14 | 15 | from NetworkEditor.items import NetworkNode 16 | from AutoDockTools.VisionInterface.Adt.dpf_template import dpf_template 17 | 18 | class DPFTemplateBrowser(NetworkNode): 19 | """ 20 | A node that allows the user to browse for a DPF template with the extension .dpf 21 | 22 | Input: DPF template file with the extension .dpf 23 | Output: dpf_template object that contains info about the DPF template file 24 | """ 25 | 26 | def __init__(self, name='DPFTemplateBrowser', **kw): 27 | kw['name'] = name 28 | NetworkNode.__init__(*(self,), **kw) 29 | 30 | kw['name'] = name 31 | NetworkNode.__init__(*(self,), **kw) 32 | ip = self.inputPortsDescr 33 | ip.append(datatype='string', name='dpf_template_file') 34 | 35 | filetypes = [('All supported files', '*.dpf')] 36 | 37 | self.widgetDescr['dpf_template_file'] = { 38 | 'class':'NEEntryWithFileBrowser', 'master':'node', 'width':20, 39 | 'filetypes':filetypes, 40 | 'initialValue':'', 'labelCfg':{'text':'DPF template file: '} 41 | } 42 | 43 | op = self.outputPortsDescr 44 | op.append(datatype='dpf_template', name='dpf_template') 45 | 46 | code = """def doit(self, dpf_template_file): 47 | import os 48 | from AutoDockTools.VisionInterface.Adt.dpf_template import dpf_template 49 | 50 | dpf_template_file = os.path.abspath(dpf_template_file) 51 | 52 | if not(os.path.exists(dpf_template_file)): 53 | print "ERROR: DPF template file " + dpf_template_file + " does not exist!" 54 | return 'stop' 55 | 56 | dpf_template = dpf_template(dpf_template_file) 57 | 58 | self.outputData(dpf_template=dpf_template) 59 | """ 60 | self.setFunction(code) 61 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Input/GPFTemplateBrowser.py: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # 3 | # Date: Nov 2001 Authors: Michel Sanner 4 | # 5 | # sanner@scripps.edu 6 | # 7 | # The Scripps Research Institute (TSRI) 8 | # Molecular Graphics Lab 9 | # La Jolla, CA 92037, USA 10 | # 11 | # Copyright: Michel Sanner and TSRI 12 | # 13 | ######################################################################### 14 | 15 | from NetworkEditor.items import NetworkNode 16 | from AutoDockTools.VisionInterface.Adt.gpf_template import gpf_template 17 | 18 | class GPFTemplateBrowser(NetworkNode): 19 | """ 20 | A node that allows the user to browse for a GPF template with the extension .gpf 21 | 22 | Input: GPF template file with the extension .gpf 23 | Output: gpf_template object that contains info about the GPF template file 24 | """ 25 | 26 | def __init__(self, name='GPFTemplateBrowser', **kw): 27 | kw['name'] = name 28 | NetworkNode.__init__(*(self,), **kw) 29 | 30 | kw['name'] = name 31 | NetworkNode.__init__(*(self,), **kw) 32 | ip = self.inputPortsDescr 33 | ip.append(datatype='string', name='gpf_template_file') 34 | 35 | filetypes = [('All supported files', '*.gpf')] 36 | 37 | self.widgetDescr['gpf_template_file'] = { 38 | 'class':'NEEntryWithFileBrowser', 'master':'node', 'width':20, 39 | 'filetypes':filetypes, 40 | 'initialValue':'', 'labelCfg':{'text':'GPF template file: '} 41 | } 42 | 43 | op = self.outputPortsDescr 44 | op.append(datatype='gpf_template', name='gpf_template') 45 | 46 | code = """def doit(self, gpf_template_file): 47 | import os 48 | from AutoDockTools.VisionInterface.Adt.gpf_template import gpf_template 49 | 50 | gpf_template_file = os.path.abspath(gpf_template_file) 51 | 52 | if not(os.path.exists(gpf_template_file)): 53 | print "ERROR: GPF template file " + gpf_template_file + " does not exist!" 54 | return 'stop' 55 | 56 | gpf_template = gpf_template(gpf_template_file) 57 | 58 | self.outputData(gpf_template=gpf_template) 59 | """ 60 | self.setFunction(code) 61 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Input/GetStructuresFromDir.py: -------------------------------------------------------------------------------- 1 | from NetworkEditor.items import NetworkNode 2 | class GetStructuresFromDir(NetworkNode): 3 | """ 4 | Get list of structure file names from directory and create 5 | objects based on these files 6 | """ 7 | mRequiredTypes = {} 8 | mRequiredSynonyms = [ 9 | ] 10 | 11 | def __init__(self, constrkw = {}, name='GetStructuresFromDir', **kw): 12 | kw['constrkw'] = constrkw 13 | kw['name'] = name 14 | NetworkNode.__init__(*(self,), **kw) 15 | 16 | ip = self.inputPortsDescr 17 | ip.append({'name': 'directory', 'datatype': 'string'}) 18 | 19 | self.widgetDescr['directory'] = { 20 | 'class':'NEEntryWithDirectoryBrowser', 'master':'node', 'width':20, 21 | 'initialValue':'', 'labelCfg':{'text':'Structure Directory: '} 22 | } 23 | 24 | op = self.outputPortsDescr 25 | op.append({'name': 'structure_list_obj', 'datatype': 'list'}) 26 | 27 | # op = self.outputPortsDescr 28 | # op.append({'name': 'structure_list', 'datatype': 'list'}) 29 | 30 | 31 | code = """def doit(self, directory): 32 | import glob, os 33 | from AutoDockTools.VisionInterface.Adt.receptor import receptor 34 | 35 | directory = os.path.abspath(directory) 36 | 37 | if directory == None: 38 | return 'stop' 39 | 40 | if directory is not None: 41 | cwd = os.getcwd() 42 | os.chdir(directory) 43 | try: 44 | filenames_pdbqt = glob.glob('*.pdbqt') 45 | filenames_pqr = glob.glob('*.pqr') 46 | filenames_pdb = glob.glob('*.pdb') 47 | 48 | structure_list = filenames_pdbqt 49 | 50 | for f in filenames_pqr: 51 | sid = f.rstrip('.pqr') 52 | s = sid + '.pdbqt' 53 | found = False 54 | 55 | for i in structure_list: 56 | if i == s: 57 | found = True 58 | break 59 | 60 | if found == False: 61 | structure_list.append(f) 62 | 63 | for f in filenames_pdb: 64 | sid = f.rstrip('.pdb') 65 | found = False 66 | 67 | for i in structure_list: 68 | if i == sid + '.pdb' or i == sid + '.pdbqt': 69 | found = True 70 | break 71 | 72 | if found == False: 73 | structure_list.append(f) 74 | 75 | structure_list = [os.path.join(directory, x) for x in filenames_pdbqt] 76 | structure_list_obj = [receptor(x) for x in structure_list] 77 | finally: 78 | if directory is not None: 79 | os.chdir(cwd) 80 | 81 | print "--------------------------------------------------------------" 82 | print "The following structures are found in the structure directory:" 83 | 84 | count = 0 85 | 86 | for i in structure_list: 87 | count = count + 1 88 | print str(count) + '. ' + i 89 | 90 | print "--------------------------------------------------------------" 91 | 92 | pass 93 | # self.outputData(structure_list_obj=structure_list_obj, structure_list=structure_list) 94 | self.outputData(structure_list_obj=structure_list_obj) 95 | """ 96 | self.configure(function=code) 97 | 98 | 99 | def beforeAddingToNetwork(self, net): 100 | try: 101 | ed = net.getEditor() 102 | except: 103 | import traceback; traceback.print_exc() 104 | print('Warning! Could not import widgets') 105 | 106 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Input/MakeDPFCopies.py: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # 3 | # Date: Nov 2001 Authors: Michel Sanner 4 | # 5 | # sanner@scripps.edu 6 | # 7 | # The Scripps Research Institute (TSRI) 8 | # Molecular Graphics Lab 9 | # La Jolla, CA 92037, USA 10 | # 11 | # Copyright: Michel Sanner and TSRI 12 | # 13 | ######################################################################### 14 | 15 | from NetworkEditor.items import NetworkNode 16 | from AutoDockTools.VisionInterface.Adt.dpf_template import dpf_template 17 | 18 | class MakeDPFCopies(NetworkNode): 19 | """ 20 | A node that takes a DPF and a directory of pdb/pqr/pdbqt files and 21 | makes copies of the DPF. The DPF copies will have the basenames of the 22 | pdb/pqr/pdbqt files. 23 | 24 | Input 1: DPF template file with the extension .dpf 25 | Input 2: A directory path to the PDB/PQR/PDBQT files 26 | Output: List of all DPFs in the directory 27 | """ 28 | 29 | def __init__(self, name='MakeDPFCopies', **kw): 30 | kw['name'] = name 31 | NetworkNode.__init__(*(self,), **kw) 32 | 33 | kw['name'] = name 34 | NetworkNode.__init__(*(self,), **kw) 35 | ip = self.inputPortsDescr 36 | ip.append(datatype='dpf_template', name='dpf_file') 37 | ip.append(datatype='string', name='struct_dir') 38 | 39 | op = self.outputPortsDescr 40 | op.append(datatype='list', name='dpf_list') 41 | 42 | code = """def doit(self, dpf_file, struct_dir): 43 | import os 44 | import shutil 45 | from AutoDockTools.VisionInterface.Adt.dpf_template import dpf_template 46 | 47 | file_path = dpf_file.fullpath 48 | 49 | if not(os.path.exists(file_path)): 50 | print "ERROR: DPF template file " + file_path + " does not exist!" 51 | return 'stop' 52 | 53 | name_list = set() 54 | dpf_list = [] 55 | 56 | d = os.path.abspath(struct_dir) 57 | 58 | for i in os.listdir(struct_dir): 59 | if i.endswith(".pdbqt") or i.endswith(".pdb") or i.endswith(".pqr"): 60 | name_list.add(i.split('.')[0]) 61 | 62 | for i in name_list: 63 | dst = os.path.join(d, i + '.dpf') 64 | dpf_list.append(dst) 65 | 66 | if not(os.path.exists(dst)): 67 | shutil.copyfile(file_path, dst) 68 | 69 | 70 | self.outputData(dpf_list=dpf_list) 71 | """ 72 | self.setFunction(code) 73 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Input/MakeGPFCopies.py: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # 3 | # Date: Nov 2001 Authors: Michel Sanner 4 | # 5 | # sanner@scripps.edu 6 | # 7 | # The Scripps Research Institute (TSRI) 8 | # Molecular Graphics Lab 9 | # La Jolla, CA 92037, USA 10 | # 11 | # Copyright: Michel Sanner and TSRI 12 | # 13 | ######################################################################### 14 | 15 | from NetworkEditor.items import NetworkNode 16 | from AutoDockTools.VisionInterface.Adt.gpf_template import gpf_template 17 | 18 | class MakeGPFCopies(NetworkNode): 19 | """ 20 | A node that takes a GPF and a directory of pdb/pqr/pdbqt files and 21 | makes copies of the GPF. The GPF copies will have the basenames of the 22 | pdb/pqr/pdbqt files. 23 | 24 | Input 1: GPF template file with the extension .gpf 25 | Input 2: A directory path to the PDB/PQR/PDBQT files 26 | Output: List of all GPFs in the directory 27 | """ 28 | 29 | def __init__(self, name='MakeGPFCopies', **kw): 30 | kw['name'] = name 31 | NetworkNode.__init__(*(self,), **kw) 32 | 33 | kw['name'] = name 34 | NetworkNode.__init__(*(self,), **kw) 35 | ip = self.inputPortsDescr 36 | ip.append(datatype='gpf_template', name='gpf_file') 37 | ip.append(datatype='string', name='struct_dir') 38 | 39 | op = self.outputPortsDescr 40 | op.append(datatype='list', name='gpf_list') 41 | 42 | code = """def doit(self, gpf_file, struct_dir): 43 | import os 44 | import shutil 45 | from AutoDockTools.VisionInterface.Adt.gpf_template import gpf_template 46 | 47 | file_path = gpf_file.fullpath 48 | 49 | if not(os.path.exists(file_path)): 50 | print "ERROR: GPF template file " + file_path + " does not exist!" 51 | return 'stop' 52 | 53 | name_list = set() 54 | gpf_list = [] 55 | 56 | d = os.path.abspath(struct_dir) 57 | 58 | for i in os.listdir(struct_dir): 59 | if i.endswith(".pdbqt") or i.endswith(".pdb") or i.endswith(".pqr"): 60 | name_list.add(i.split('.')[0]) 61 | 62 | for i in name_list: 63 | dst = os.path.join(d, i + '.gpf') 64 | gpf_list.append(dst) 65 | 66 | if not(os.path.exists(dst)): 67 | shutil.copyfile(file_path, dst) 68 | 69 | 70 | self.outputData(gpf_list=gpf_list) 71 | """ 72 | self.setFunction(code) 73 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Input/MakeGpfDpfCopies.py: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # 3 | # Date: Nov 2001 Authors: Michel Sanner 4 | # 5 | # sanner@scripps.edu 6 | # 7 | # The Scripps Research Institute (TSRI) 8 | # Molecular Graphics Lab 9 | # La Jolla, CA 92037, USA 10 | # 11 | # Copyright: Michel Sanner and TSRI 12 | # 13 | ######################################################################### 14 | 15 | from NetworkEditor.items import NetworkNode 16 | from AutoDockTools.VisionInterface.Adt.dpf_template import dpf_template 17 | from AutoDockTools.VisionInterface.Adt.gpf_template import gpf_template 18 | 19 | class MakeGpfDpfCopies(NetworkNode): 20 | """ 21 | A node that takes a DPF, a GPF and a directory of pdb/pqr/pdbqt files and 22 | makes copies of the DPF/GPF. The DPF/GPF copies will have the basenames of the 23 | pdb/pqr/pdbqt files. 24 | 25 | Input 1: GPF template file with the extension .gpf 26 | Input 2: DPF template file with the extension .dpf 27 | Input 3: A directory path to the PDB/PQR/PDBQT files 28 | Output 1: List of all GPFs in the directory 29 | Output 2: List of all DPFs in the directory 30 | Output 3: Same as input 3 31 | """ 32 | 33 | def __init__(self, name='MakeDPFCopies', **kw): 34 | kw['name'] = name 35 | NetworkNode.__init__(*(self,), **kw) 36 | 37 | kw['name'] = name 38 | NetworkNode.__init__(*(self,), **kw) 39 | ip = self.inputPortsDescr 40 | ip.append(datatype='gpf_template', name='gpf_file', required=False) 41 | ip.append(datatype='dpf_template', name='dpf_file', required=False) 42 | ip.append(datatype='string', name='struct_dir', required=True) 43 | 44 | op = self.outputPortsDescr 45 | op.append(datatype='list', name='gpf_list') 46 | op.append(datatype='list', name='dpf_list') 47 | op.append(datatype='string', name='struct_dir') 48 | 49 | code = """def doit(self, gpf_file, dpf_file, struct_dir): 50 | import os 51 | import shutil 52 | from AutoDockTools.VisionInterface.Adt.dpf_template import dpf_template 53 | from AutoDockTools.VisionInterface.Adt.gpf_template import gpf_template 54 | 55 | if dpf_file == None and gpf_file == None: 56 | print "ERROR: DPF and GPF input missing" 57 | return 'stop' 58 | 59 | 60 | if dpf_file != None: 61 | dpf_file_path = dpf_file.fullpath 62 | 63 | if not(os.path.exists(dpf_file_path)): 64 | print "ERROR: DPF template file " + dpf_file_path + " does not exist!" 65 | return 'stop' 66 | 67 | if gpf_file != None: 68 | gpf_file_path = gpf_file.fullpath 69 | 70 | if not(os.path.exists(gpf_file_path)): 71 | print "ERROR: GPF template file " + gpf_file_path + " does not exist!" 72 | return 'stop' 73 | 74 | name_list = set() 75 | d = os.path.abspath(struct_dir) 76 | 77 | for i in os.listdir(struct_dir): 78 | if i.endswith(".pdbqt") or i.endswith(".pdb") or i.endswith(".pqr"): 79 | name_list.add(i.split('.')[0]) 80 | 81 | dpf_list = [] 82 | gpf_list = [] 83 | 84 | if dpf_file != None: 85 | for i in name_list: 86 | d_dst = os.path.join(d, i + '.dpf') 87 | dpf_list.append(d_dst) 88 | 89 | if not(os.path.exists(d_dst)): 90 | shutil.copyfile(dpf_file_path, d_dst) 91 | 92 | if gpf_file != None: 93 | for i in name_list: 94 | g_dst = os.path.join(d, i + '.gpf') 95 | gpf_list.append(g_dst) 96 | 97 | if not(os.path.exists(g_dst)): 98 | shutil.copyfile(gpf_file_path, g_dst) 99 | 100 | 101 | self.outputData(dpf_list=dpf_list, gpf_list=gpf_list, struct_dir=struct_dir) 102 | """ 103 | self.setFunction(code) 104 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Input/PreparedStructureBrowser.py: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # 3 | # Date: Nov 2001 Authors: Michel Sanner 4 | # 5 | # sanner@scripps.edu 6 | # 7 | # The Scripps Research Institute (TSRI) 8 | # Molecular Graphics Lab 9 | # La Jolla, CA 92037, USA 10 | # 11 | # Copyright: Michel Sanner and TSRI 12 | # 13 | ######################################################################### 14 | 15 | from NetworkEditor.items import NetworkNode 16 | 17 | from AutoDockTools.VisionInterface.Adt.receptor import receptor 18 | 19 | import os 20 | 21 | class PreparedStructureBrowser(NetworkNode): 22 | """ 23 | Allows the user to browse a structure prepared pdbqt structure. 24 | """ 25 | 26 | def __init__(self, name='StructureBrowser', **kw): 27 | kw['name'] = name 28 | NetworkNode.__init__(*(self,), **kw) 29 | 30 | kw['name'] = name 31 | NetworkNode.__init__(*(self,), **kw) 32 | ip = self.inputPortsDescr 33 | ip.append(datatype='string', name='prepared_structure_file') 34 | 35 | filetypes = [('All supported files', '*.pdbqt')] 36 | 37 | self.widgetDescr['prepared_structure_file'] = { 38 | 'class':'NEEntryWithFileBrowser', 'master':'node', 'width':20, 39 | 'filetypes':filetypes, 40 | 'initialValue':'', 'labelCfg':{'text':'Prepared Structure file: '} 41 | } 42 | 43 | op = self.outputPortsDescr 44 | op.append(datatype='receptor_prepared', name='receptor_obj') 45 | 46 | code = """def doit(self, prepared_structure_file): 47 | import os 48 | 49 | receptor_file = os.path.abspath(prepared_structure_file) 50 | 51 | if not(os.path.exists(prepared_structure_file)): 52 | print "ERROR: prepared structure file " + prepared_structure_file + " does not exist!" 53 | return 'stop' 54 | 55 | receptor_obj = receptor(prepared_structure_file) 56 | 57 | self.outputData(receptor_obj=receptor_obj) 58 | """ 59 | self.setFunction(code) 60 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Input/PublicServerLigandDB.py: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # 3 | # Date: Nov 2001 Authors: Michel Sanner 4 | # 5 | # sanner@scripps.edu 6 | # 7 | # The Scripps Research Institute (TSRI) 8 | # Molecular Graphics Lab 9 | # La Jolla, CA 92037, USA 10 | # 11 | # Copyright: Michel Sanner and TSRI 12 | # 13 | ######################################################################### 14 | 15 | from NetworkEditor.items import NetworkNode 16 | 17 | from AutoDockTools.VisionInterface.Adt.LigandDB import LigandDB 18 | from mglutil.util.packageFilePath import getResourceFolderWithVersion 19 | 20 | import os 21 | import time 22 | import urllib.request, urllib.error, urllib.parse 23 | 24 | class PublicServerLigandDB(NetworkNode): 25 | """ 26 | List of available public libraries on the virtual screening server. 27 | A description of the ligand libraries can be found on 28 | http://nbcr.sdsc.edu/pub/wiki/index.php?title=Virtual_Screening_Libraries 29 | 30 | Input: a public ligand library name 31 | Output: LigandDB object containing info about the info 32 | """ 33 | 34 | def __init__(self, name='PublicServerLigandDB', **kw): 35 | import urllib.request, urllib.parse, urllib.error 36 | 37 | kw['name'] = name 38 | NetworkNode.__init__(*(self,), **kw) 39 | 40 | kw['name'] = name 41 | NetworkNode.__init__(*(self,), **kw) 42 | ip = self.inputPortsDescr 43 | ip.append(datatype='string', name='server_lib', required=True, ) 44 | 45 | fqdn = "kryptonite.nbcr.net" 46 | url = "http://" + fqdn + "/pub_ligand_libs.txt" 47 | 48 | publibdir = os.path.join(getResourceFolderWithVersion(), 'ws') 49 | 50 | if not (os.path.exists(publibdir)): 51 | os.mkdir(publibdir) 52 | 53 | publiblocal = os.path.join(publibdir, 'publibs.txt') 54 | 55 | lock = publiblocal + '.lock' 56 | 57 | if os.path.exists(lock) and time.time() - os.path.getmtime(lock) > 15: 58 | os.remove(lock) 59 | 60 | try: 61 | if not(os.path.exists(lock)): 62 | open(lock, 'w').close() 63 | publibweb = urllib.request.urlopen(url) 64 | outfile = open(publiblocal, 'w') 65 | outfile.write(publibweb.read()) 66 | outfile.close() 67 | os.remove(lock) 68 | except: 69 | print("[INFO]: Getting list of public server libs from cache") 70 | pass 71 | 72 | 73 | try: 74 | f = open(publiblocal, 'r') 75 | self.choices = f.read().split() 76 | f.close() 77 | except: 78 | self.choices = [] 79 | print("[ERROR]: Unable to public server libs from the web and from cache") 80 | 81 | self.widgetDescr['server_lib'] = { 82 | 'class':'NEComboBox', 'master':'node', 83 | 'choices':self.choices, 84 | 'fixedChoices':True, 85 | 'entryfield_entry_width':18, 86 | 'labelGridCfg':{'sticky':'w'}, 87 | 'widgetGridCfg':{'sticky':'w'}, 88 | 'labelCfg':{'text':'Server Libraries:'}} 89 | 90 | op = self.outputPortsDescr 91 | op.append(datatype='LigandDB', name='ligDB') 92 | 93 | code = """def doit(self, server_lib): 94 | ligDB = LigandDB(server_lib=server_lib) 95 | 96 | self.outputData(ligDB=ligDB) 97 | """ 98 | self.setFunction(code) 99 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Input/StructureBrowser.py: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # 3 | # Date: Nov 2001 Authors: Michel Sanner 4 | # 5 | # sanner@scripps.edu 6 | # 7 | # The Scripps Research Institute (TSRI) 8 | # Molecular Graphics Lab 9 | # La Jolla, CA 92037, USA 10 | # 11 | # Copyright: Michel Sanner and TSRI 12 | # 13 | ######################################################################### 14 | 15 | from NetworkEditor.items import NetworkNode 16 | 17 | from AutoDockTools.VisionInterface.Adt.receptor import receptor 18 | 19 | import os 20 | 21 | class StructureBrowser(NetworkNode): 22 | """ 23 | Allows the user to browser a structure file in pdb, pqr, or pdbqt format 24 | and returns a receptor object. 25 | """ 26 | 27 | def __init__(self, name='StructureBrowser', **kw): 28 | kw['name'] = name 29 | NetworkNode.__init__(*(self,), **kw) 30 | 31 | kw['name'] = name 32 | NetworkNode.__init__(*(self,), **kw) 33 | ip = self.inputPortsDescr 34 | ip.append(datatype='string', name='receptor_file') 35 | 36 | filetypes = [('All supported files', '*.pdb *.pqr *.pdbqt')] 37 | 38 | self.widgetDescr['receptor_file'] = { 39 | 'class':'NEEntryWithFileBrowser', 'master':'node', 'width':20, 40 | 'filetypes':filetypes, 41 | 'initialValue':'', 'labelCfg':{'text':'Structure file: '} 42 | } 43 | 44 | op = self.outputPortsDescr 45 | op.append(datatype='receptor', name='receptor_obj') 46 | 47 | code = """def doit(self, receptor_file): 48 | import os 49 | 50 | receptor_file = os.path.abspath(receptor_file) 51 | 52 | if not(os.path.exists(receptor_file)): 53 | print "ERROR: structure file " + receptor_file + " does not exist!" 54 | return 'stop' 55 | 56 | receptor_obj = receptor(receptor_file) 57 | 58 | self.outputData(receptor_obj=receptor_obj) 59 | """ 60 | self.setFunction(code) 61 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Input/UrlLigandDB.py: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # 3 | # Date: Nov 2001 Authors: Michel Sanner 4 | # 5 | # sanner@scripps.edu 6 | # 7 | # The Scripps Research Institute (TSRI) 8 | # Molecular Graphics Lab 9 | # La Jolla, CA 92037, USA 10 | # 11 | # Copyright: Michel Sanner and TSRI 12 | # 13 | ######################################################################### 14 | 15 | from NetworkEditor.items import NetworkNode 16 | 17 | from AutoDockTools.VisionInterface.Adt.LigandDB import LigandDB 18 | 19 | import sys 20 | import os 21 | 22 | class UrlLigandDB(NetworkNode): 23 | """ 24 | Input: URL to a ligand DB on the virtual screening server. 25 | Output: LigandDB object containing info about the input 26 | """ 27 | 28 | def __init__(self, name='UrlLigandDB', **kw): 29 | kw['name'] = name 30 | NetworkNode.__init__(*(self,), **kw) 31 | 32 | 33 | kw['name'] = name 34 | NetworkNode.__init__(*(self,), **kw) 35 | ip = self.inputPortsDescr 36 | ip.append(datatype='string', name='url') 37 | # ip.append(datatype='string', name='local_dir') 38 | 39 | self.widgetDescr['url'] = { 40 | 'class':'NEEntry', 'master':'node', 'width':40, 41 | 'labelCfg':{'text':'URL to ligands: '} 42 | } 43 | # self.widgetDescr['local_dir'] = { 44 | # 'class':'NEEntryWithDirectoryBrowser', 'master':'node', 'width':30, 45 | # 'labelCfg':{'text':'Local directory to save ligands: '} 46 | # } 47 | 48 | op = self.outputPortsDescr 49 | op.append(datatype='LigandDB', name='ligDB') 50 | 51 | # code = """def doit(self, url, local_dir): 52 | code = """def doit(self, url): 53 | # ligDB = LigandDB(url_compressed_file=url) 54 | ligDB = LigandDB(url_lib=url) 55 | 56 | bname = os.path.basename(url) 57 | 58 | # if bname.endwith('.tar.gz'): 59 | # print "TEST tar.gz" 60 | # elif bname.endswith('.zip'): 61 | # print "TEST ZIP" 62 | 63 | if not(url.startswith('http://kryptonite.nbcr.net/app')): 64 | print "ERROR: the URL must be a directory on kryptonite.nbcr.net" 65 | sys.exit() 66 | 67 | 68 | 69 | self.outputData(ligDB=ligDB) 70 | """ 71 | self.setFunction(code) 72 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Input/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/AutoDockTools/VisionInterface/Adt/Input/__init__.py -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/LigandDB.py: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # 3 | # Author: J. Ren 4 | # 5 | ############################################################################# 6 | 7 | """ 8 | Ligand Library Object 9 | """ 10 | 11 | import os 12 | import tempfile 13 | import zipfile 14 | import _py2k_string as string 15 | import types, re 16 | from AutoDockTools.filterLigands import CalculateProperties, PropertyTable, LigandList, FilterLigands 17 | 18 | class LigandDB: 19 | """Ligand Library Object 20 | """ 21 | 22 | # def __init__(self, server_lib=None, url_lib=None, filter_file=None, accepted=None): 23 | def __init__(self, server_lib=None, url_lib=None): 24 | 25 | self.server_lib = server_lib 26 | self.url_lib = url_lib 27 | # self.accepted = accepted 28 | self.accepted = None 29 | self.property_file = None 30 | self.propertyTable = None 31 | 32 | # if filter_file == None: 33 | # self.filter_file = os.path.abspath('filtered_ligands.txt') 34 | # else: 35 | # self.filter_file = os.path.abspath(filter_file) 36 | self.filter_file = None 37 | 38 | if self.server_lib != None: 39 | import urllib.request, urllib.parse, urllib.error 40 | slu = "http://kryptonite.nbcr.net/ligand_props/" + server_lib + ".prop" 41 | pt = PropertyTable(url=slu) 42 | self.propertyTable = pt 43 | self.loc = self.server_lib 44 | self.loc_type = "server_lib" 45 | elif self.url_lib != None: 46 | import urllib.request, urllib.parse, urllib.error 47 | slu = url_lib + "/lib.prop" 48 | #print slu 49 | pt = PropertyTable(url=slu) 50 | self.propertyTable = pt 51 | self.loc = self.url_lib 52 | self.loc_type = "url_lib" 53 | 54 | # if accepted == None: 55 | # lfilter = FilterLigands() 56 | # accepted, rejected = lfilter.filterTable(self.propertyTable) 57 | # self.SetAcceptedLigands(accepted.filenames) 58 | # else: 59 | # f = open(self.filter_file, 'w') 60 | # for i in self.accepted: 61 | # f.write(i + ''' 62 | #''') 63 | # f.close() 64 | 65 | def SetAcceptedLigands(self, accept_list, filter_file=None): 66 | if filter_file == None: 67 | workingDir = tempfile.mkdtemp() 68 | filter_file = workingDir + os.sep + 'filtered_ligands.txt' 69 | 70 | self.accepted = accept_list 71 | self.filter_file = filter_file 72 | 73 | f = open(self.filter_file, 'w') 74 | for i in self.accepted: 75 | f.write(i + ''' 76 | ''') 77 | f.close() 78 | 79 | def GetPropertyFile(self): 80 | return self.property_file 81 | 82 | 83 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Macro/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/AutoDockTools/VisionInterface/Adt/Macro/__init__.py -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Mapper/ADTFileNames.py: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # 3 | # Vision Node - Python source code - file generated by vision 4 | # Monday 22 June 2009 13:08:37 5 | # 6 | # The Scripps Research Institute (TSRI) 7 | # Molecular Graphics Lab 8 | # La Jolla, CA 92037, USA 9 | # 10 | # Copyright: Daniel Stoffler, Michel Sanner and TSRI 11 | # 12 | # revision: Guillaume Vareille 13 | # 14 | ######################################################################### 15 | # 16 | # $Header: /opt/cvs/python/packages/share1.5/AutoDockTools/VisionInterface/Adt/Mapper/ADTFileNames.py,v 1.3 2010/07/15 23:45:39 jren Exp $ 17 | # 18 | # $Id: ADTFileNames.py,v 1.3 2010/07/15 23:45:39 jren Exp $ 19 | # 20 | 21 | # import node's base class node 22 | from NetworkEditor.items import NetworkNode 23 | class ADTFileNames(NetworkNode): 24 | """ 25 | Node to make inputs for virtual screening. 26 | """ 27 | mRequiredTypes = {} 28 | mRequiredSynonyms = [ 29 | ] 30 | 31 | def __init__(self, constrkw = {}, name='ADTFileNames', **kw): 32 | kw['constrkw'] = constrkw 33 | kw['name'] = name 34 | NetworkNode.__init__(*(self,), **kw) 35 | 36 | ip = self.inputPortsDescr 37 | ip.append({'name': 'recpetor_obj', 'datatype': 'receptor'}) 38 | 39 | op = self.outputPortsDescr 40 | op.append({'name': 'GPF_template', 'datatype': 'gpf_template'}) 41 | op.append({'name': 'DPF_template', 'datatype': 'dpf_template'}) 42 | op.append({'name': 'result_dir', 'datatype': 'string'}) 43 | 44 | 45 | code = """def doit(self, receptor_obj): 46 | import os 47 | from AutoDockTools.VisionInterface.Adt.receptor import receptor 48 | from AutoDockTools.VisionInterface.Adt.dpf_template import dpf_template 49 | from AutoDockTools.VisionInterface.Adt.gpf_template import gpf_template 50 | 51 | receptor_id = receptor_obj.get_id() 52 | receptor_dir = receptor_obj.get_workdir() 53 | 54 | GPF_template = gpf_template(receptor_dir + os.sep + receptor_id + '.gpf') 55 | DPF_template = dpf_template(receptor_dir + os.sep + receptor_id + '.dpf') 56 | result_dir = os.path.abspath(receptor_dir + os.sep + '..' + os.sep + receptor_id) 57 | 58 | print "-------------------------------------------------------" 59 | print " INPUTS THAT WILL BE USED FOR VIRTUAL SCREENING " 60 | print "GPF Template: " + GPF_template.fullpath 61 | print "DPF Template: " + DPF_template.fullpath 62 | print "Results will be downloaded to: " + result_dir 63 | print "-------------------------------------------------------" 64 | 65 | pass 66 | self.outputData(GPF_template=GPF_template, DPF_template=DPF_template, result_dir=result_dir) 67 | """ 68 | self.configure(function=code) 69 | 70 | 71 | def beforeAddingToNetwork(self, net): 72 | try: 73 | ed = net.getEditor() 74 | except: 75 | import traceback; traceback.print_exc() 76 | print('Warning! Could not import widgets') 77 | 78 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Mapper/InputValidation.py: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # 3 | # Vision Node - Python source code - file generated by vision 4 | # Monday 22 June 2009 13:08:37 5 | # 6 | # The Scripps Research Institute (TSRI) 7 | # Molecular Graphics Lab 8 | # La Jolla, CA 92037, USA 9 | # 10 | # Copyright: Daniel Stoffler, Michel Sanner and TSRI 11 | # 12 | # revision: Guillaume Vareille 13 | # 14 | ######################################################################### 15 | # 16 | # $Header: /opt/cvs/python/packages/share1.5/AutoDockTools/VisionInterface/Adt/Mapper/InputValidation.py,v 1.1 2010/07/26 23:00:19 jren Exp $ 17 | # 18 | # $Id: InputValidation.py,v 1.1 2010/07/26 23:00:19 jren Exp $ 19 | # 20 | 21 | # import node's base class node 22 | from NetworkEditor.items import NetworkNode 23 | class InputValidation(NetworkNode): 24 | """ 25 | Get inputs for virtual screening, and check for validity of inputs. 26 | """ 27 | mRequiredTypes = {} 28 | mRequiredSynonyms = [ 29 | ] 30 | 31 | def __init__(self, constrkw = {}, name='ADTFileNames', **kw): 32 | kw['constrkw'] = constrkw 33 | kw['name'] = name 34 | NetworkNode.__init__(*(self,), **kw) 35 | 36 | ip = self.inputPortsDescr 37 | ip.append({'name': 'recpetor_obj', 'datatype': 'receptor'}) 38 | 39 | op = self.outputPortsDescr 40 | op.append({'name': 'GPF_template', 'datatype': 'gpf_template'}) 41 | op.append({'name': 'DPF_template', 'datatype': 'dpf_template'}) 42 | op.append({'name': 'result_dir', 'datatype': 'string'}) 43 | 44 | 45 | code = """def doit(self, receptor_obj): 46 | import os 47 | from AutoDockTools.VisionInterface.Adt.receptor import receptor 48 | from AutoDockTools.VisionInterface.Adt.dpf_template import dpf_template 49 | from AutoDockTools.VisionInterface.Adt.gpf_template import gpf_template 50 | 51 | receptor_id = receptor_obj.get_id() 52 | receptor_dir = receptor_obj.get_workdir() 53 | 54 | gpf_file = receptor_dir + os.sep + receptor_id + '.gpf' 55 | dpf_file = receptor_dir + os.sep + receptor_id + '.dpf' 56 | GPF_template = gpf_template(gpf_file) 57 | DPF_template = dpf_template(dpf_file) 58 | result_dir = os.path.abspath(receptor_dir + os.sep + '..' + os.sep + receptor_id) 59 | 60 | if not(os.path.exists(gpf_file)): 61 | print "ERROR: GPF template " + gpf_file + " does not exist!" 62 | return 'stop' 63 | elif not(os.path.exists(dpf_file)): 64 | print "ERROR: DPF template " + dpf_file + " does not exist!" 65 | return 'stop' 66 | 67 | pdbqt_loc = receptor_obj.get_ext_loc('pdbqt') 68 | pqr_loc = receptor_obj.get_ext_loc('pqr') 69 | pdb_loc = receptor_obj.get_ext_loc('pdb') 70 | 71 | if pdbqt_loc == None and pqr_loc == None and pdb_loc == None: 72 | print "ERROR: No valid structure file found, none of the following exist" 73 | print " " + pdbqt_loc + ", " + pqr_loc + ", " + pdb_loc 74 | return 'stop' 75 | 76 | print "-------------------------------------------------------" 77 | print " INPUTS THAT WILL BE USED FOR VIRTUAL SCREENING " 78 | print "GPF Template: " + GPF_template.fullpath 79 | print "DPF Template: " + DPF_template.fullpath 80 | print "Results will be downloaded to: " + result_dir 81 | print "-------------------------------------------------------" 82 | 83 | pass 84 | self.outputData(GPF_template=GPF_template, DPF_template=DPF_template, result_dir=result_dir) 85 | """ 86 | self.configure(function=code) 87 | 88 | 89 | def beforeAddingToNetwork(self, net): 90 | try: 91 | ed = net.getEditor() 92 | except: 93 | import traceback; traceback.print_exc() 94 | print('Warning! Could not import widgets') 95 | 96 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Mapper/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/AutoDockTools/VisionInterface/Adt/Mapper/__init__.py -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Other/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/AutoDockTools/VisionInterface/Adt/Other/__init__.py -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/Output/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/AutoDockTools/VisionInterface/Adt/Output/__init__.py -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/__init__.py: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # 3 | # Date: Jan 2006 Authors: Guillaume Vareille, Michel Sanner 4 | # 5 | # vareille@scripps.edu 6 | # sanner@scripps.edu 7 | # 8 | # The Scripps Research Institute (TSRI) 9 | # Molecular Graphics Lab 10 | # La Jolla, CA 92037, USA 11 | # 12 | # Copyright: Guillaume Vareille, Michel Sanner and TSRI 13 | # 14 | # Vision Library Loader 15 | # 16 | ######################################################################### 17 | # 18 | # /home/vareille/.mgltools/1.6.0/Vision/UserLibs/MyDefaultLib/__init__.py 19 | # Vision will generate this file automatically if it can't find it 20 | # 21 | 22 | from os import sep, path 23 | from Vision.VPE import NodeLibrary 24 | from Vision.UserLibBuild import userLibBuild, addDirToSysPath, addTypes 25 | 26 | dependents = {} # {'scipy':'0.6.0',} the numbers indicate the highest tested version of the needed packages 27 | libraryColor = '#4444FF' 28 | 29 | addDirToSysPath(path.dirname(__file__)+sep+'..') 30 | fileSplit = __file__.split(sep) 31 | if fileSplit[-1] == '__init__.pyc' or fileSplit[-1] == '__init__.py': 32 | libInstanceName = fileSplit[-2] 33 | else: 34 | libInstanceName = path.splitext(fileSplit[-1])[0] 35 | try: 36 | from Vision import ed 37 | except: 38 | ed = None 39 | if ed is not None and libInstanceName in ed.libraries: 40 | locals()[libInstanceName] = ed.libraries[libInstanceName] 41 | else: 42 | locals()[libInstanceName] = NodeLibrary(libInstanceName, libraryColor, mode='readWrite') 43 | success = userLibBuild(eval(libInstanceName), __file__, dependents=dependents) 44 | if success is False: 45 | locals().pop(libInstanceName) 46 | elif path.isfile(path.dirname(__file__)+sep+'libTypes.py'): 47 | addTypes(locals()[libInstanceName], libInstanceName + '.libTypes') 48 | 49 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/autogrid_results.py: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # 3 | # Date: Nov 2001 Authors: Michel Sanner 4 | # 5 | # sanner@scripps.edu 6 | # 7 | # The Scripps Research Institute (TSRI) 8 | # Molecular Graphics Lab 9 | # La Jolla, CA 92037, USA 10 | # 11 | # Copyright: Michel Sanner and TSRI 12 | # 13 | ######################################################################### 14 | 15 | import os 16 | from NetworkEditor.items import NetworkNode 17 | from Vision.make_zip_file import make_zip_file 18 | 19 | class autogrid_results: 20 | """ 21 | Autogrid Result Object 22 | """ 23 | 24 | def __init__(self, path=None, type=None): 25 | self.path = path 26 | self.type = type 27 | 28 | if self.type == "local" and os.path.isdir(path): 29 | zip_name = os.path.basename(path) + '.zip' 30 | self.path = make_zip_file(input_directory=path, output_name=zip_name) 31 | 32 | 33 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/dpf_template.py: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # 3 | # Author: J. Ren 4 | # 5 | ############################################################################# 6 | 7 | """ 8 | TBD 9 | """ 10 | 11 | import os 12 | 13 | class dpf_template: 14 | 15 | def __init__(self, dpf_template_file=None): 16 | 17 | self.fullpath = os.path.abspath(dpf_template_file) 18 | self.basename = os.path.basename(dpf_template_file) 19 | self.id = self.basename.split('.')[0] 20 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/gpf_template.py: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # 3 | # Author: J. Ren 4 | # 5 | ############################################################################# 6 | 7 | """ 8 | TBD 9 | """ 10 | 11 | import os 12 | 13 | class gpf_template: 14 | 15 | def __init__(self, gpf_template_file=None): 16 | 17 | self.fullpath = os.path.abspath(gpf_template_file) 18 | self.basename = os.path.basename(gpf_template_file) 19 | self.id = self.basename.split('.')[0] 20 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/libTypes.py: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # 3 | # Date: Jan 2006 Authors: Guillaume Vareille, Michel Sanner 4 | # 5 | # vareille@scripps.edu 6 | # sanner@scripps.edu 7 | # 8 | # The Scripps Research Institute (TSRI) 9 | # Molecular Graphics Lab 10 | # La Jolla, CA 92037, USA 11 | # 12 | # Copyright: Guillaume Vareille, Michel Sanner and TSRI 13 | # 14 | # Vision Library Types 15 | # 16 | ######################################################################### 17 | # 18 | # /home/vareille/.mgltools/1.6.0/Vision/UserLibs/MyDefaultLib/libTypes.py 19 | # Vision will generate this file automatically if it can't find it 20 | # 21 | from .LigandDB import LigandDB 22 | from .receptor import receptor 23 | from .receptor_prepared import receptor_prepared 24 | from .dpf_template import dpf_template 25 | from .gpf_template import gpf_template 26 | from .autogrid_results import autogrid_results 27 | from NetworkEditor.datatypes import AnyArrayType 28 | 29 | ################################################### 30 | # add new types to your library 31 | ################################################### 32 | 33 | #class ThingType(AnyArrayType): 34 | # 35 | # from ThingPackage import Thing 36 | # def __init__(self, name='thing', color='#995699', shape='rect', 37 | # klass=Thing): 38 | # 39 | # AnyArrayType.__init__(self, name=name, color=color, shape=shape, 40 | # klass=klass) 41 | # 42 | ## in NetworkEditor.datatypes, you should have a look at the class IntType 43 | 44 | class LigandDBType(AnyArrayType): 45 | 46 | from AutoDockTools.VisionInterface.Adt.LigandDB import LigandDB 47 | def __init__(self, name='LigandDB', color='#FFCCFF', shape='rect', 48 | klass=LigandDB): 49 | 50 | AnyArrayType.__init__(self, name=name, color=color, shape=shape, 51 | klass=klass) 52 | 53 | class receptor(AnyArrayType): 54 | 55 | from AutoDockTools.VisionInterface.Adt.receptor import receptor 56 | def __init__(self, name='receptor', color='#99FF33', shape='triangle', 57 | klass=receptor): 58 | 59 | AnyArrayType.__init__(self, name=name, color=color, shape=shape, 60 | klass=klass) 61 | 62 | class receptor_prepared(AnyArrayType): 63 | 64 | from AutoDockTools.VisionInterface.Adt.receptor_prepared import receptor_prepared 65 | def __init__(self, name='receptor_prepared', color='#009900', shape='triangle', 66 | klass=receptor_prepared): 67 | 68 | AnyArrayType.__init__(self, name=name, color=color, shape=shape, 69 | klass=klass) 70 | 71 | class dpf_template(AnyArrayType): 72 | 73 | from AutoDockTools.VisionInterface.Adt.dpf_template import dpf_template 74 | def __init__(self, name='dpf_template', color='#9933FF', shape='triangle', 75 | klass=dpf_template): 76 | 77 | AnyArrayType.__init__(self, name=name, color=color, shape=shape, 78 | klass=klass) 79 | 80 | class gpf_template(AnyArrayType): 81 | 82 | from AutoDockTools.VisionInterface.Adt.gpf_template import gpf_template 83 | def __init__(self, name='gpf_template', color='#FF3333', shape='triangle', 84 | klass=gpf_template): 85 | 86 | AnyArrayType.__init__(self, name=name, color=color, shape=shape, 87 | klass=klass) 88 | 89 | class autogrid_results(AnyArrayType): 90 | 91 | from AutoDockTools.VisionInterface.Adt.autogrid_results import autogrid_results 92 | def __init__(self, name='autogrid_results', color='#FF33CC', shape='triangle', 93 | klass=autogrid_results): 94 | 95 | AnyArrayType.__init__(self, name=name, color=color, shape=shape, 96 | klass=klass) 97 | 98 | ## in NetworkEditor.datatypes, you should have a look at the class IntType 99 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/receptor.py: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # 3 | # Author: J. Ren 4 | # 5 | ############################################################################# 6 | 7 | """ 8 | Receptor - can be a pdb, pqr, or pdbqt 9 | """ 10 | 11 | import os 12 | 13 | class receptor: 14 | 15 | def __init__(self, filename=None): 16 | self.ext_loc = {'pdb': [None, None], 'pqr': [None, None], 'pdbqt': [None, None]} 17 | self.workdir = None 18 | self.id = None 19 | 20 | if filename != None: 21 | self.set_ext_loc(filename) 22 | self.set_workdir(filename) 23 | 24 | def set_workdir(self, d): 25 | if not(d.startswith('http://')): 26 | d = os.path.abspath(d) 27 | 28 | if d.endswith('.pdb') or d.endswith('.pqr') or d.endswith('.pdbqt'): 29 | d = os.path.dirname(d) 30 | 31 | self.workdir = d 32 | 33 | def set_id(self, id): 34 | bn = os.path.basename(id) 35 | self.id = bn.split(os.extsep)[0] 36 | 37 | def set_ext_loc(self, filename): 38 | ext = os.path.splitext(filename)[1].strip(os.extsep) 39 | self.set_id(filename) 40 | 41 | if filename.startswith('http://'): 42 | self.ext_loc[ext] = [filename, 'url'] 43 | else: 44 | full_path = os.path.abspath(filename) 45 | dir_name = os.path.dirname(full_path) 46 | 47 | ext_list = ['pdb', 'pqr', 'pdbqt'] 48 | 49 | for i in ext_list: 50 | f = dir_name + os.sep + self.id + os.extsep + i 51 | if os.path.exists(f): 52 | self.ext_loc[i] = [f, 'local'] 53 | self.set_workdir(full_path) 54 | 55 | def get_workdir(self): 56 | if self.workdir == None: 57 | exts = ['pdb', 'pqr', 'pdbqt'] 58 | 59 | for i in exts: 60 | if self.get_ext_type(i) == "local": 61 | self.set_workdir(self.get_ext_loc(i)) 62 | break 63 | 64 | return self.workdir 65 | 66 | def get_id(self): 67 | return self.id 68 | 69 | def get_ext_loc(self, ext): 70 | return self.ext_loc[ext][0] 71 | 72 | def get_ext_type(self, ext): 73 | return self.ext_loc[ext][1] 74 | 75 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Adt/receptor_prepared.py: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # 3 | # Author: J. Ren 4 | # 5 | ############################################################################# 6 | 7 | """ 8 | TBD 9 | """ 10 | 11 | import os 12 | 13 | class receptor_prepared: 14 | 15 | def __init__(self, receptor_path=None): 16 | 17 | if receptor_path.startswith('http://'): 18 | self.type = 'url' 19 | self.path = receptor_path 20 | else: 21 | self.type = 'local' 22 | self.path = os.path.abspath(receptor_path) 23 | 24 | self.basename = os.path.basename(receptor_path) 25 | self.id = self.basename.rstrip('.pdbqt') 26 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/Docking.py: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # 3 | # Vision Node - Python source code - file generated by vision 4 | # Tuesday 25 July 2006 11:40:00 5 | # 6 | # The Scripps Research Institute (TSRI) 7 | # Molecular Graphics Lab 8 | # La Jolla, CA 92037, USA 9 | # 10 | # Copyright: Daniel Stoffler, Michel Sanner and TSRI 11 | # 12 | # revision: Guillaume Vareille 13 | # 14 | ######################################################################### 15 | # 16 | # $Header: /opt/cvs/python/packages/share1.5/AutoDockTools/VisionInterface/Docking.py,v 1.1 2006/07/25 23:35:30 rhuey Exp $ 17 | # 18 | # $Id: Docking.py,v 1.1 2006/07/25 23:35:30 rhuey Exp $ 19 | # 20 | 21 | # import node's base class node 22 | from NetworkEditor.items import NetworkNode 23 | class Docking(NetworkNode): 24 | mRequiredTypes = {} 25 | mRequiredSynonyms = [ 26 | ] 27 | def __init__(self, constrkw = {}, name='Docking', **kw): 28 | kw['constrkw'] = constrkw 29 | kw['name'] = name 30 | NetworkNode.__init__(*(self,), **kw) 31 | code = """def doit(self, docking_logs, rmsTool): 32 | from AutoDockTools.Docking import Docking 33 | d = Docking() 34 | for f in docking_logs: 35 | d.readDlg(f) 36 | d.clusterer.rmsTool = rmsTool 37 | self.outputData(docking = d) 38 | 39 | 40 | ## to ouput data on port docking use 41 | ## self.outputData(docking=data) 42 | 43 | 44 | """ 45 | self.configure(function=code) 46 | self.inputPortsDescr.append( 47 | {'name': 'docking_logs', 'cast': True, 'datatype': 'list', 'balloon': 'list of docking log files to be read into as a single Docking', 'height': 12, 'width': 12, 'shape': 'oval', 'color': 'cyan'}) 48 | self.inputPortsDescr.append( 49 | {'name': 'rmsTool', 'cast': True, 'datatype': 'None', 'balloon': 'rmsTool to be used for clustering', 'height': 8, 'width': 12, 'shape': 'diamond', 'color': 'white'}) 50 | self.outputPortsDescr.append( 51 | {'name': 'docking', 'datatype': 'None', 'balloon': 'docking instance', 'height': 8, 'width': 12, 'shape': 'diamond', 'color': 'white'}) 52 | 53 | 54 | def beforeAddingToNetwork(self, net): 55 | try: 56 | ed = net.getEditor() 57 | except: 58 | import traceback; traceback.print_exc() 59 | print('Warning! Could not import widgets') 60 | 61 | -------------------------------------------------------------------------------- /AutoDockTools/VisionInterface/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/AutoDockTools/VisionInterface/__init__.py -------------------------------------------------------------------------------- /AutoDockTools/adthosts.py: -------------------------------------------------------------------------------- 1 | hostMacros = { 2 | 'localhost': { 'host' : 'localhost', 3 | 'autogrid' : 'autogrid4', 4 | 'autodock' : 'autodock4', 5 | 'vina' : 'vina', 6 | 'queuetype' : 'int', 7 | 'userSpecific' : 0 }, 8 | 9 | } 10 | 11 | -------------------------------------------------------------------------------- /AutoDockTools/autodockHosts.py: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # 3 | # Author: Ruth HUEY, Michel F. SANNER 4 | # 5 | # Copyright: M. Sanner TSRI 2000 6 | # 7 | ############################################################################# 8 | # 9 | # $Header: /opt/cvs/python/packages/share1.5/AutoDockTools/autodockHosts.py,v 1.2 2012/08/07 17:36:20 rhuey Exp $ 10 | # 11 | # $Id: autodockHosts.py,v 1.2 2012/08/07 17:36:20 rhuey Exp $ 12 | # 13 | # 14 | # 15 | 16 | from collections import UserDict 17 | 18 | class AutoDockHosts(UserDict): 19 | 20 | def __init__(self, localHostDict): 21 | UserDict.__init__(self) 22 | self.update(localHostDict) 23 | 24 | def buildEntry(self, host=None,agPath=None, adPath=None, vinaPath=None, qType='int', userSpecific=0): 25 | d={} 26 | d['host']=host 27 | d['autogrid']=agPath 28 | d['autodock']=adPath 29 | d['vina']=vinaPath 30 | d['queuetype']=qType 31 | d['userSpecific']=userSpecific 32 | return d 33 | 34 | def addHost(self,macroName, hostdict=None, **kw): 35 | host = kw['host'] 36 | agPath = kw['autogrid'] 37 | adPath = kw['autodock'] 38 | vinaPath = kw['vina'] 39 | qType = kw['queuetype'] 40 | userSpecific = kw['userSpecific'] 41 | if not hostdict: 42 | hostdict=self.buildEntry(host=host, agPath=agPath, adPath=adPath, 43 | qType=qType,userSpecific=userSpecific) 44 | self[macroName]=hostdict 45 | #nb: preexisting macroName entry is overwritten 46 | 47 | def saveHostFile(self, filename, whichOnes='all'): 48 | #will be in file called .adthosts.py 49 | #and consist of python code for dictionary called 'newhosts' 50 | fptr = open(filename, 'w') 51 | outstr = 'hostMacros={' 52 | #outstr = 'hosts={' 53 | fptr.write(outstr) 54 | #always write a localHost line 55 | #get the correct macroList here 56 | if whichOnes=='all': 57 | macroList=list(self.keys()) 58 | elif whichOnes=='userSpecific': 59 | #get the one with userSpecific=1, only 60 | macroList=[] 61 | for item in list(self.items()): 62 | if item[1]['userSpecific']: 63 | macroList.append(item) 64 | else: 65 | macroList=[] 66 | for item in list(self.items()): 67 | if not item[1]['userSpecific']: 68 | macroList.append(item) 69 | #get the other ones... 70 | for i in range(len(macroList)): 71 | h=macroList[i][0] 72 | self.writeEntry(h,fptr) 73 | if i DIST_CUTOFF: continue 69 | angle = getAngle(acc.getCoords(), donor.getCoords(), donorh.getCoords()) 70 | if angle > ANGLE_CUTOFF: continue 71 | routines.write("Donor: %s %s\tAcceptor: %s %s\tHdist: %.2f\tAngle: %.2f\n" % \ 72 | (donor.residue, donor.name, acc.residue, acc.name, dist, angle)) 73 | file.write("Donor: %s %s\tAcceptor: %s %s\tHdist: %.2f\tAngle: %.2f\n" % \ 74 | (donor.residue, donor.name, acc.residue, acc.name, dist, angle)) 75 | 76 | routines.write("\n") 77 | file.close() 78 | -------------------------------------------------------------------------------- /MolKit/pdb2pqr/extensions/phi.py: -------------------------------------------------------------------------------- 1 | """ 2 | Psi extension 3 | 4 | Print the phi backbone angle for each residue in the structure. 5 | Psi angle is determined by the coordinates of the C(i-1), N(i), CA(i), and 6 | C(i). atoms. 7 | 8 | Author: Mike Bradley and Todd Dolinsky 9 | """ 10 | 11 | __date__ = "17 February 2006" 12 | __author__ = "Mike Bradley, Todd Dolinsky" 13 | 14 | from src.utilities import * 15 | from src.routines import * 16 | 17 | def usage(): 18 | str = " --phi : Print the per-residue backbone phi\n" 19 | str += " angle to {output-path}.phi\n" 20 | return str 21 | 22 | def phi(routines, outroot): 23 | """ 24 | Print the list of phi angles 25 | 26 | Parameters 27 | routines: A link to the routines object 28 | outroot: The root of the output name 29 | """ 30 | 31 | outname = outroot + ".phi" 32 | file = open(outname, "w") 33 | 34 | routines.write("\nPrinting phi angles for each residue...\n") 35 | routines.write("Residue Phi\n") 36 | routines.write("----------------\n") 37 | 38 | # Initialize some variables 39 | 40 | protein = routines.protein 41 | 42 | for residue in protein.getResidues(): 43 | try: 44 | if residue.peptideC != None: 45 | pepcoords = residue.peptideC.getCoords() 46 | else: continue 47 | except AttributeError: # Non amino acids 48 | continue 49 | 50 | if residue.hasAtom("N"): ncoords = residue.getAtom("N").getCoords() 51 | else: continue 52 | 53 | if residue.hasAtom("CA"): cacoords = residue.getAtom("CA").getCoords() 54 | else: continue 55 | 56 | if residue.hasAtom("C"): ccoords = residue.getAtom("C").getCoords() 57 | else: continue 58 | 59 | phi = getDihedral(pepcoords, ncoords, cacoords, ccoords) 60 | routines.write("%s\t%.4f\n" % (residue, phi)) 61 | file.write("%s\t%.4f\n" % (residue, phi)) 62 | 63 | routines.write("\n") 64 | file.close() 65 | -------------------------------------------------------------------------------- /MolKit/pdb2pqr/extensions/psi.py: -------------------------------------------------------------------------------- 1 | """ 2 | Psi extension 3 | 4 | Print the psi backbone angle for each residue in the structure. 5 | Psi angle is determined by the coordinates of the N(i), CA(i), C(i), N(i+1) 6 | atoms. 7 | 8 | Author: Mike Bradley and Todd Dolinsky 9 | """ 10 | 11 | __date__ = "17 February 2006" 12 | __author__ = "Mike Bradley, Todd Dolinsky" 13 | 14 | from src.utilities import * 15 | from src.routines import * 16 | 17 | def usage(): 18 | str = " --psi : Print the per-residue backbone psi\n" 19 | str += " angle to {output-path}.psi\n" 20 | return str 21 | 22 | def psi(routines, outroot): 23 | """ 24 | Print the list of psi angles 25 | 26 | Parameters 27 | routines: A link to the routines object 28 | outroot: The root of the output name 29 | """ 30 | 31 | outname = outroot + ".psi" 32 | file = open(outname, "w") 33 | 34 | routines.write("\nPrinting psi angles for each residue...\n") 35 | routines.write("Residue Psi\n") 36 | routines.write("----------------\n") 37 | 38 | # Initialize some variables 39 | 40 | protein = routines.protein 41 | 42 | for residue in protein.getResidues(): 43 | if residue.hasAtom("N"): ncoords = residue.getAtom("N").getCoords() 44 | else: continue 45 | 46 | if residue.hasAtom("CA"): cacoords = residue.getAtom("CA").getCoords() 47 | else: continue 48 | 49 | if residue.hasAtom("C"): ccoords = residue.getAtom("C").getCoords() 50 | else: continue 51 | 52 | try: 53 | if residue.peptideN != None: 54 | pepcoords = residue.peptideN.getCoords() 55 | else: continue 56 | except AttributeError: # Non amino acids 57 | continue 58 | 59 | psi = getDihedral(ncoords, cacoords, ccoords, pepcoords) 60 | routines.write("%s\t%.4f\n" % (residue, psi)) 61 | file.write("%s\t%.4f\n" % (residue, psi)) 62 | 63 | routines.write("\n") 64 | file.close() 65 | -------------------------------------------------------------------------------- /MolKit/pdb2pqr/extensions/rama.py: -------------------------------------------------------------------------------- 1 | """ 2 | Ramachandran extension 3 | 4 | Print both the phi and psi angles to standard out. See the individual 5 | functions for more info. 6 | 7 | Author: Mike Bradley and Todd Dolinsky 8 | """ 9 | 10 | __date__ = "17 February 2006" 11 | __author__ = "Mike Bradley, Todd Dolinsky" 12 | 13 | from src.utilities import * 14 | from src.routines import * 15 | 16 | def usage(): 17 | str = " --rama : Print the per-residue phi and psi\n" 18 | str += " angles to {output-path}.rama for\n" 19 | str += " Ramachandran plots\n" 20 | return str 21 | 22 | def rama(routines, outroot): 23 | """ 24 | Print the list of phi and psi angles for use in a Ramachandran plot. 25 | 26 | Parameters 27 | routines: A link to the routines object 28 | outroot: The root of the output name 29 | """ 30 | 31 | outname = outroot + ".rama" 32 | file = open(outname, "w") 33 | 34 | routines.write("\nPrinting phi and psi angles for each residue...\n") 35 | routines.write("Residue Phi Psi\n") 36 | routines.write("-------------------------------\n") 37 | 38 | # Initialize some variables 39 | 40 | protein = routines.protein 41 | 42 | for residue in protein.getResidues(): 43 | if residue.hasAtom("N"): ncoords = residue.getAtom("N").getCoords() 44 | else: continue 45 | 46 | if residue.hasAtom("CA"): cacoords = residue.getAtom("CA").getCoords() 47 | else: continue 48 | 49 | if residue.hasAtom("C"): ccoords = residue.getAtom("C").getCoords() 50 | else: continue 51 | 52 | try: 53 | if residue.peptideN != None: 54 | pepncoords = residue.peptideN.getCoords() 55 | else: continue 56 | 57 | if residue.peptideC != None: 58 | pepccoords = residue.peptideC.getCoords() 59 | else: continue 60 | except AttributeError: # Non amino acids 61 | continue 62 | 63 | phi = getDihedral(pepccoords, ncoords, cacoords, ccoords) 64 | psi = getDihedral(ncoords, cacoords, ccoords, pepncoords) 65 | routines.write("%s\t%.4f\t%.4f\n" % (residue, phi, psi)) 66 | file.write("%s\t%.4f\t%.4f\n" % (residue, phi, psi)) 67 | 68 | routines.write("\n") 69 | file.close() 70 | -------------------------------------------------------------------------------- /MolKit/pdb2pqr/pdb2pka/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/MolKit/pdb2pqr/pdb2pka/__init__.py -------------------------------------------------------------------------------- /MolKit/pdb2pqr/pdb2pka/ligandclean/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/MolKit/pdb2pqr/pdb2pka/ligandclean/__init__.py -------------------------------------------------------------------------------- /MolKit/pdb2pqr/pdb2pka/ligandclean/lookuptable.py: -------------------------------------------------------------------------------- 1 | templates_attributes = {} 2 | templates_attributes['IDD594'] ={'type': 'Carboxylic_Acid','modelpka':3.90, 'titratableatoms': ['O1', 'O2','C']} 3 | templates_attributes['CarboxyGroup'] ={'type': 'Carboxylic_Acid','modelpka':4.75, 'titratableatoms': ['O10', 'O20','C3']} 4 | templates_attributes['AceticAcid'] ={'type': 'Carboxylic_Acid','modelpka':4.80, 'titratableatoms': ['O1', 'O2','C']} 5 | templates_attributes['imidazole'] ={'type': 'Base','modelpka':6.30, 'titratableatoms': ['N10','C10','N20','C30','C40']} 6 | templates_attributes['piperidine'] ={'type': 'Base','modelpka':6.33, 'titratableatoms': ['XXX1']} 7 | templates_attributes['PropanoicAcid']={'type': 'Carboxylic_Acid','modelpka':4.20, 'titratableatoms': ['O10', 'O20','C30']} 8 | templates_attributes['acetylsalicylicacid'] ={'type': 'Carboxylic_Acid','modelpka':4.99, 'titratableatoms': ['O1', 'O2','C','C30','C50','C80','C60','C40']} 9 | #templates_attributes['CRAP'] ={'type': 'Acid','modelpka':4.555, 'titratableatoms': ['O10', 'O20','C30']} 10 | -------------------------------------------------------------------------------- /MolKit/pdb2pqr/pdb2pka/substruct/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/MolKit/pdb2pqr/pdb2pka/substruct/__init__.py -------------------------------------------------------------------------------- /MolKit/pdb2pqr/propka/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/MolKit/pdb2pqr/propka/__init__.py -------------------------------------------------------------------------------- /MolKit/pdb2pqr/propka/propkalib.py: -------------------------------------------------------------------------------- 1 | # This file was created automatically by SWIG. 2 | # Don't modify this file, modify the SWIG interface instead. 3 | # This file is compatible with both classic and new-style classes. 4 | 5 | import _propkalib 6 | 7 | def _swig_setattr_nondynamic(self,class_type,name,value,static=1): 8 | if (name == "this"): 9 | if isinstance(value, class_type): 10 | self.__dict__[name] = value.this 11 | if hasattr(value,"thisown"): self.__dict__["thisown"] = value.thisown 12 | del value.thisown 13 | return 14 | method = class_type.__swig_setmethods__.get(name,None) 15 | if method: return method(self,value) 16 | if (not static) or hasattr(self,name) or (name == "thisown"): 17 | self.__dict__[name] = value 18 | else: 19 | raise AttributeError("You cannot add attributes to %s" % self) 20 | 21 | def _swig_setattr(self,class_type,name,value): 22 | return _swig_setattr_nondynamic(self,class_type,name,value,0) 23 | 24 | def _swig_getattr(self,class_type,name): 25 | method = class_type.__swig_getmethods__.get(name,None) 26 | if method: return method(self) 27 | raise AttributeError(name) 28 | 29 | import types 30 | try: 31 | _object = object 32 | _newclass = 1 33 | except AttributeError: 34 | class _object : pass 35 | _newclass = 0 36 | del types 37 | 38 | 39 | 40 | runPKA = _propkalib.runPKA 41 | 42 | -------------------------------------------------------------------------------- /MolKit/pdb2pqr/src/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/MolKit/pdb2pqr/src/__init__.py -------------------------------------------------------------------------------- /MolKit/sets.py: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # 3 | # Authors: Michel F. SANNER, Ruth Huey 4 | # 5 | # Copyright: M. Sanner TSRI 2005 6 | # 7 | ############################################################################# 8 | # 9 | # $Header: /opt/cvs/python/packages/share1.5/MolKit/sets.py,v 1.2 2006/06/12 18:28:35 sargis Exp $ 10 | # 11 | # 12 | # 13 | # 14 | # 15 | 16 | from .tree import TreeNodeSet 17 | import types 18 | 19 | class Sets(dict): 20 | """ 21 | Object used to manage a collection of explicit sets of TreeNodes 22 | """ 23 | 24 | def add(self, name, set, overwrite=True): 25 | assert isinstance(set, TreeNodeSet) 26 | assert type(name) in (str,) 27 | 28 | if not overwrite: 29 | assert name not in list(self.keys()) 30 | self[name] = set 31 | 32 | 33 | def remove(self, name): 34 | # remove a set by name. Silently ignore non existing sets but returns 35 | # true when a set gets deleted, else returns False 36 | if name in list(self.keys()): 37 | del self[name] 38 | return True 39 | return False 40 | 41 | 42 | def removeByInstance(self, set): 43 | # remove a set that is specified by a TreeNodeSet. 44 | # Silently ignore non existing sets but returns 45 | # true when a set gets deleted, else returns False 46 | for n,s in list(self.items()): 47 | if s==set: 48 | del self[n] 49 | return True 50 | return False 51 | 52 | 53 | def get(self, stype=None): 54 | # return a dict of sets optionally restricted to a user specified type 55 | # if stype is specified it has to be a subclass of TreeNodeSet 56 | if stype is None: 57 | return self 58 | else: # select the sets of a given type 59 | assert issubclass(stype, TreeNodeSet) 60 | result = {} 61 | for name,set in list(self.items()): 62 | if isinstance(set, stype): 63 | result[name] = set 64 | return result 65 | 66 | -------------------------------------------------------------------------------- /PyBabel/tools.py: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # 3 | # Author: Michel F. SANNER 4 | # Reimplemented from Babel v1.6 from Pat Walters and Math Stahl 5 | # 6 | # Copyright: M. Sanner TSRI 2000 7 | # 8 | ############################################################################# 9 | # 10 | # $Header: /opt/cvs/python/packages/share1.5/PyBabel/tools.py,v 1.1.1.1 2001/04/03 19:47:47 gillet Exp $ 11 | # 12 | # $Id: tools.py,v 1.1.1.1 2001/04/03 19:47:47 gillet Exp $ 13 | # 14 | # 15 | # 16 | 17 | import _py2k_string as string 18 | 19 | def read_element_table(filename): 20 | """void <- read_element_table(filename) 21 | populates the elementsTable dictionary from the a given file. 22 | the file provides: 23 | line number, element string, cov_rad, bond_ord_rad, vdw_rad, bs_rad, 24 | max_bonds, red, green, blue 25 | """ 26 | f = open(filename) 27 | lines = f.readlines() 28 | f.close() 29 | elemTable = {} 30 | for i in range(len(lines)): 31 | dd = string.split(lines[i]) 32 | elemTable[dd[1]] = { 'num':i, 33 | 'cov_rad':float(dd[2]), 34 | 'bond_ord_rad':float(dd[3]), 35 | 'vdw_rad':float(dd[4]), 36 | 'bs_rad':float(dd[5]), 37 | 'max_bonds':int(dd[6]), 38 | 'rgb': (float(dd[7]),float(dd[8]),float(dd[9])) 39 | } 40 | return elemTable 41 | 42 | 43 | def writeElementTableAsPythonCode(elemTab, inFileName, outFileName): 44 | """write elemTable as a python dictionary that can be imported""" 45 | 46 | f = open(outFileName,'w') 47 | f.write("# File generated from %s\n#\n"%inFileName) 48 | f.write("babel_elements = {\n") 49 | for k,v in list(elemTab.items()): 50 | f.write(" '%s': %s, \n" % (k,str(v))) 51 | f.write('}\n#END\n'); 52 | f.close() 53 | 54 | 55 | def read_types_table(filename): 56 | f = open(filename) 57 | typestab = {} 58 | nrow, ncol = list(map( int, string.split(f.readline()))) 59 | typeFormats = string.split(f.readline()) 60 | for t in typeFormats: 61 | typestab[t] = [] 62 | for i in range(nrow-1): 63 | typeNames = string.split(f.readline()) 64 | for j in range(ncol): 65 | typestab[typeFormats[j]].append(typeNames[j]) 66 | f.close() 67 | return typestab 68 | 69 | 70 | def writeTypesTableAsPythonCode(typestab, inFileName, outFileName): 71 | """write typestab as a python dictionary that can be imported""" 72 | 73 | f = open(outFileName,'w') 74 | f.write("# File generated from %s\n#\n"%inFileName) 75 | f.write("babel_types = {\n") 76 | for k,v in list(typestab.items()): 77 | f.write(" '%s': %s, \n" % (k,str(v))) 78 | f.write('}\n#END\n'); 79 | f.close() 80 | 81 | 82 | if __name__ == '__main__': 83 | # write tables 84 | et = read_element_table('element.lis') 85 | writeElementTableAsPythonCode(et, 'element.lis', 'babelElements.py') 86 | 87 | tt = read_types_table('types.lis') 88 | writeTypesTableAsPythonCode(tt, 'types.lis', 'babelAtomTypes.py') 89 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AutoDockTools (Prepare subset) for Py3k 2 | 3 | Subset of [AutoDockTools v1.5.7](http://autodock.scripps.edu/resources/adt), tailored just to run: 4 | - `prepare_receptor4.py` 5 | - `prepare_ligand4.py` 6 | 7 | This was ported by running `2to3` and then manually fixing incompatibilities, such as: 8 | 9 | - Python 2.7's `string` module wrapper (admire the hackiness in `_py2k_string.py`) 10 | - Inconsistent indentation (spaces vs tabs) - might have introduced one bug or two... 11 | - Raised `"string exceptions"` 12 | - `map(None, [...])` -> `zip_longest([...])` 13 | 14 | # Disclaimer 15 | 16 | This has not been tested thoroughly _at all_. Results are not guaranteed to be the same as in the original distribution. 17 | -------------------------------------------------------------------------------- /Support/__init__.py: -------------------------------------------------------------------------------- 1 | # This package provides support for setting up and updating MGLTools. 2 | # Author: Sargis Dallakyan (sargis at scripps.edu) $ 3 | # $Header: /opt/cvs/Support/__init__.py,v 1.1 2006/11/28 00:47:22 sargis Exp $ 4 | # $Id: __init__.py,v 1.1 2006/11/28 00:47:22 sargis Exp $ 5 | -------------------------------------------------------------------------------- /Support/path.py: -------------------------------------------------------------------------------- 1 | # This modules sets MGLTools path 2 | # Author: Sargis Dallakyan (sargis at scripps.edu) 3 | # $Header: /opt/cvs/Support/path.py,v 1.16 2007/11/20 23:24:40 sargis Exp $ 4 | # $Id: path.py,v 1.16 2007/11/20 23:24:40 sargis Exp $ 5 | import os, sys 6 | from user import home 7 | from Support.version import __version__ 8 | rc = home + os.sep + ".mgltools" + os.sep + __version__ 9 | 10 | if rc: 11 | updates_rc_dir = rc + os.sep + 'update' 12 | else: 13 | updates_rc_dir = 'update' 14 | tested_rc = updates_rc_dir + os.sep + 'tested' 15 | nightly_rc = updates_rc_dir + os.sep + 'nightly' #may or may not be tested 16 | release_path = '' 17 | path_text = '' 18 | 19 | def setSysPath(path): 20 | """Sets sys.path for MGLTools""" 21 | global release_path, path_text 22 | sys.path.insert(1,path + os.sep + 'PIL') 23 | release_path = path 24 | 25 | if os.path.exists(tested_rc): 26 | p = open(tested_rc).read().split('\t') 27 | if os.path.exists(p[0]): 28 | if os.listdir(p[0]): 29 | sys.path.insert(0, p[0]) 30 | path_text = ' Tested '+ p[1]+ ' : ' + p[0] +'\n' + path_text 31 | else: 32 | os.remove(tested_rc) 33 | 34 | if os.path.exists(nightly_rc): 35 | p = open(nightly_rc).read().split('\t') 36 | if os.path.exists(p[0]): 37 | if os.listdir(p[0]): 38 | sys.path.insert(0, p[0]) 39 | path_text = ' Nightly '+ p[1]+ ' : ' + p[0] +'\n' + path_text 40 | -------------------------------------------------------------------------------- /Support/sitecustomize.py: -------------------------------------------------------------------------------- 1 | # specify mglroot here 2 | import sys, os 3 | path = os.path.join(mglroot, "MGLToolsPckgs") 4 | sys.path.append(path) 5 | 6 | from os import getenv 7 | if getenv('MGLPYTHONPATH'): 8 | sys.path.insert(0, getenv('MGLPYTHONPATH')) 9 | 10 | from Support.path import setSysPath 11 | setSysPath(path) 12 | #sys.path.insert(0,os.path.abspath('.')) 13 | -------------------------------------------------------------------------------- /Support/version.py: -------------------------------------------------------------------------------- 1 | __version__ = '1.5.7' 2 | -------------------------------------------------------------------------------- /_py2k_string/__init__.py: -------------------------------------------------------------------------------- 1 | from textwrap import dedent 2 | 3 | methods = [m for m in dir(str) if not m.startswith("_")] 4 | 5 | for method in methods: 6 | exec(dedent(f""" 7 | def {method}(s, *args): 8 | return s.{method}(*args) 9 | """ 10 | ) 11 | ) 12 | 13 | from string import * 14 | letters = ascii_letters -------------------------------------------------------------------------------- /bhtree/__init__.py: -------------------------------------------------------------------------------- 1 | from .bhtreelib import * 2 | 3 | __MGLTOOLSVersion__ = '1-4alpha3' 4 | CRITICAL_DEPENDENCIES = ['mglutil'] 5 | NONCRITICAL_DEPENDENCIES = [] 6 | -------------------------------------------------------------------------------- /cMolKit/__init__.py: -------------------------------------------------------------------------------- 1 | #init of mglutilc module 2 | -------------------------------------------------------------------------------- /conda-recipe/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | tar xf MGLToolsPckgs.tar.gz 4 | cd MGLToolsPckgs 5 | 6 | mv AutoDockTools bhtree cMolKit mglutil MolKit PyBabel Support $PREFIX/lib/python2.7/site-packages/ 7 | 8 | BINARY_HOME=$PREFIX/bin 9 | UTILITIES_HOME=$PREFIX/lib/python2.7/site-packages/AutoDockTools/Utilities24 10 | ln -s $UTILITIES_HOME/prepare_ligand4.py $BINARY_HOME/prepare_ligand4.py 11 | ln -s $UTILITIES_HOME/prepare_receptor4.py $BINARY_HOME/prepare_receptor4.py -------------------------------------------------------------------------------- /conda-recipe/meta.yaml: -------------------------------------------------------------------------------- 1 | {% set build = 0 %} 2 | 3 | package: 4 | name: autodocktools-prepare 5 | version: 1.5.7 6 | 7 | build: 8 | number: {{ build }} 9 | noarch: python 10 | script: python -m pip install . 11 | 12 | source: 13 | path: ../ 14 | 15 | requirements: 16 | build: 17 | - python 18 | run: 19 | - python 20 | - numpy 21 | 22 | test: 23 | commands: 24 | - prepare_ligand4.py 25 | - prepare_receptor4.py 26 | 27 | about: 28 | home: http://mgltools.scripps.edu/ 29 | license_file: LICENSE.txt 30 | summary: AutoDockTools, or ADT, is the free GUI for AutoDock developed by the same laboratory that develops AutoDock. -------------------------------------------------------------------------------- /mglutil/TestUtil/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/mglutil/TestUtil/__init__.py -------------------------------------------------------------------------------- /mglutil/__init__.py: -------------------------------------------------------------------------------- 1 | CRITICAL_DEPENDENCIES = [] 2 | NONCRITICAL_DEPENDENCIES = ['numpy', 'MolKit', 'Pmw', 'bhtree', '_subprocess', 'Pmv', 'ViewerFramework', 'PIL', 'FlexTree', 'idlelib', 'DejaVu','distutils', 'Support'] 3 | __revision__= 'May_01_17' 4 | -------------------------------------------------------------------------------- /mglutil/bhtfunctions.py: -------------------------------------------------------------------------------- 1 | import numpy 2 | from bhtree import bhtreelib 3 | # 4 | # $Header: /opt/cvs/python/packages/share1.5/mglutil/bhtfunctions.py,v 1.9.12.1 2016/02/11 19:04:09 annao Exp $ 5 | # 6 | # $Id: bhtfunctions.py,v 1.9.12.1 2016/02/11 19:04:09 annao Exp $ 7 | # 8 | 9 | # ClosePointsDist2: result and dist are empty arrays large enough to contain 10 | # all the points expected to be found. To be safe, they should be the same 11 | # size as the list of coordinates. This function then puts in the results 12 | # array the indices of the close points in the list (as supplied in the array 13 | # ids): the dist array contains the corresponding distances. 14 | 15 | def findNearestAtoms(mol,vertices, **kw): 16 | """None <- color(mol,vertices2,**kw) 17 | mol: reference molecule 18 | vertices: list of lists(coordinates): the first three items in each list 19 | must be coordinates x,y,z of a point. 20 | 21 | atomIndices is the index of the nearest atom to the vertex, such that 22 | mol.allAtoms[atomIndices[x]] is the nearest atom to vertices[x] 23 | vertexIndices is the list of nearest vertices to an atom, such that 24 | vertexIndices[x] = [vertex1,vertex2,...] are the vertices associated with 25 | mol.allAtoms[x] 26 | """ 27 | 28 | coords = mol.allAtoms.coords 29 | if not hasattr(mol,'bhtree'): 30 | print("Building bhtree for ",mol) 31 | ids = numpy.arange(len(coords)).astype('i') 32 | bhtree = bhtreelib.TBHTree(coords,ids,10,10,9999.0) 33 | mol.bhtree = bhtree 34 | 35 | vertexIndices={} 36 | atomIndices={} 37 | for x in range(len(coords)): 38 | vertexIndices[x+1]=[] 39 | 40 | cutoff=5. 41 | for x in range(len(vertices)): 42 | xyz = vertices[x] 43 | result = numpy.zeros( (len(vertices),) ).astype('i') 44 | dist = numpy.zeros( (len(vertices),) ).astype('f') 45 | nb2 = mol.bhtree.ClosePointsDist2(tuple(xyz[:3]), cutoff, result, dist ) 46 | while nb2==0: 47 | cutoff = cutoff+5. 48 | nb2 = mol.bhtree.ClosePointsDist2(tuple(xyz[:3]), cutoff, result, dist ) 49 | result = result[:nb2] 50 | dist = dist[:nb2] 51 | idx = dist.tolist().index(min(dist)) 52 | atnum = result[idx]+1 53 | atomIndices[x]=atnum 54 | vertexIndices[atnum].append(x) 55 | 56 | return atomIndices,vertexIndices 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /mglutil/gui/BasicWidgets/Tk/RelabelingCascadeMenu.py: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # 3 | # Date: Novembre 2005 Authors: Guillaume Vareille, Michel Sanner 4 | # 5 | # vareille@scripps.edu 6 | # sanner@scripps.edu 7 | # 8 | # The Scripps Research Institute (TSRI) 9 | # Molecular Graphics Lab 10 | # La Jolla, CA 92037, USA 11 | # 12 | # Copyright: Guillaume Vareille, Michel Sanner and TSRI 13 | # 14 | ######################################################################### 15 | # 16 | # $Header: /opt/cvs/python/packages/share1.5/mglutil/gui/BasicWidgets/Tk/RelabelingCascadeMenu.py,v 1.4 2007/05/01 22:48:05 vareille Exp $ 17 | # 18 | # $Id: RelabelingCascadeMenu.py,v 1.4 2007/05/01 22:48:05 vareille Exp $ 19 | # 20 | 21 | import tkinter 22 | import weakref 23 | 24 | class RelabelingCascadeMenu(tkinter.Menu): 25 | """ 26 | """ 27 | def __init__(self, label, variable, master=None, cnf={}, **kw): 28 | #print "RelabelingCascadeMenu.__init__", cnf, kw 29 | tkinter.Menu.__init__(self, *(master, cnf), **kw) 30 | self.baseLabel = label 31 | self.cascadeVariable = variable 32 | self._upperMenu = weakref.ref(master) 33 | self._cascadeMenuIndex = None 34 | self._externalCallbackFunction = None 35 | self._valuesLabels = {} 36 | 37 | if hasattr(self._upperMenu(), 'relabelingCascadeMenus') is False: 38 | self._upperMenu().relabelingCascadeMenus = {} 39 | self._upperMenu().relabelingCascadeMenus[self.baseLabel] = self 40 | 41 | 42 | def add_radiobutton(self, cnf={}, **kw): 43 | #print "add_radiobutton", cnf, kw 44 | if self._cascadeMenuIndex is None: 45 | self._cascadeMenuIndex = self._upperMenu().index(self.baseLabel) 46 | 47 | self._valuesLabels[kw['value']] = kw['label'] 48 | 49 | if 'command' in kw and kw['command'] is not None: 50 | self._externalCallbackFunction = kw['command'] 51 | kw['command'] = self._envelopeCallbackFunction 52 | tkinter.Menu.add_radiobutton( self, *(cnf,), **kw) 53 | 54 | 55 | def setWithoutCallbackFunction(self, value): 56 | #print "setWithoutCallbackFunction", self.baseLabel, value 57 | self.cascadeVariable.set(value) 58 | self._relabelCascade() 59 | 60 | 61 | def setWithCallbackFunction(self, value=None): 62 | #print "setWithCallbackFunction", value 63 | if value is None: 64 | value = self.cascadeVariable.get() 65 | lLabel = self._valuesLabels[value] 66 | if lLabel == 'none': # because self.index can't deal with label 'none' 67 | lIndex = 0 # be sure to put label 'none' in index 0 !!!! 68 | else: # self.index also have problems with numeric label such as '1' 69 | # use ' 1' instead 70 | lIndex = self.index(lLabel) 71 | self.invoke(lIndex) 72 | 73 | 74 | def _relabelCascade(self): 75 | #print "_relabelCascade" 76 | self._upperMenu().entryconfigure( 77 | self._cascadeMenuIndex, 78 | label=self.baseLabel \ 79 | +' [ ' \ 80 | +str(self._valuesLabels[self.cascadeVariable.get()])+' ]') 81 | 82 | 83 | def _envelopeCallbackFunction(self): 84 | #print "_envelopeCallbackFunction" 85 | self._relabelCascade() 86 | if self._externalCallbackFunction is not None: 87 | self._externalCallbackFunction() 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /mglutil/gui/BasicWidgets/Tk/TreeWidget/TV_sample.py: -------------------------------------------------------------------------------- 1 | from TreeWidget.tree import TreeView 2 | 3 | if __name__ == '__main__': 4 | tv = TreeView() 5 | # addNode(nodename, parentname = None) 6 | tv.addNode('protein_1') 7 | tv.addNode('residue_11', parent='protein_1') 8 | tv.addNode('AminoAcid', parent='protein_1|residue_11') 9 | tv.addNode('A', parent='protein_1|residue_11|AminoAcid') 10 | tv.addNode('H', parent='protein_1|residue_11|AminoAcid') 11 | 12 | 13 | tv.addNode('protein_2') 14 | tv.addNode('protein_3') 15 | 16 | 17 | tv.addNode('residue_21', parent='protein_2') 18 | tv.addNode('residue_25', parent='protein_2') 19 | tv.addNode('basdfe', parent='protein_2|residue_21') 20 | tv.addNode('AminoAcid', parent='protein_2|residue_21') 21 | 22 | 23 | tv.addNode('etc', parent='protein_1|residue_11') 24 | tv.addNode('color', parent='protein_1|residue_11|etc') 25 | tv.addNode('density', parent='protein_1|residue_11|etc') 26 | tv.addNode('residue_12',parent='protein_1') 27 | 28 | 29 | for a in range(1): 30 | name = 'AA' + str(a) 31 | tv.addNode(name, parent='protein_1|residue_11|AminoAcid') 32 | 33 | 34 | tv.addNode('2', parent='protein_2|residue_21') 35 | tv.addNode('3', parent='protein_2|residue_21') 36 | tv.addNode('4', parent='protein_2|residue_21') 37 | 38 | tv.addNode('L', parent='protein_2|residue_21|AminoAcid') 39 | tv.addNode('S', parent='protein_2|residue_21|AminoAcid') 40 | 41 | 42 | for a in range(10): 43 | name = 'A' + str(a) 44 | tv.addNode(name, parent='protein_2|residue_21|AminoAcid') 45 | 46 | 47 | tv.addNode('protein_4') 48 | tv.addNode('residue_22', parent='protein_2') 49 | 50 | ## to delete a node: 51 | # tv.deleteNode(nodename, parentname) 52 | # e.g. >>> tv.deleteNode('residue_21', 'protein_2') 53 | # e.g. >>> tv.deleteNode('protein_2') 54 | -------------------------------------------------------------------------------- /mglutil/gui/BasicWidgets/Tk/TreeWidget/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/mglutil/gui/BasicWidgets/Tk/TreeWidget/__init__.py -------------------------------------------------------------------------------- /mglutil/gui/BasicWidgets/Tk/TreeWidget/icons/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/mglutil/gui/BasicWidgets/Tk/TreeWidget/icons/__init__.py -------------------------------------------------------------------------------- /mglutil/gui/BasicWidgets/Tk/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/mglutil/gui/BasicWidgets/Tk/__init__.py -------------------------------------------------------------------------------- /mglutil/gui/BasicWidgets/Tk/defaultColors.py: -------------------------------------------------------------------------------- 1 | defaultColor = {'1':(1,1,1),# white 2 | '2':(0,0,0),#black 3 | '3':(0.,0.,1.),#blue 4 | '4':(0.,1.,0.),#green 5 | '5': (1.,0.,0.,),#red 6 | '6':(0.,1.,1.),#cyan 7 | '7':(1.,0.,1.),#magenta 8 | '8':(1.,1.,0.)}#yellow 9 | -------------------------------------------------------------------------------- /mglutil/gui/BasicWidgets/Tk/dirDialog.py: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # 3 | # Date: May 2003 Authors: Sophie COON 4 | # 5 | 6 | ######################################################################### 7 | # This is a fix to use the askdirectory widget developped by written by 8 | # Fredrik Lundh but only available for Python2.2 and higher. 9 | ######################################################################### 10 | 11 | from tkinter.commondialog import Dialog 12 | 13 | class Directory(Dialog): 14 | "Ask for a directory" 15 | 16 | command = "tk_chooseDirectory" 17 | 18 | def _fixresult(self, widget, result): 19 | self.widget = widget 20 | if result: 21 | # keep directory until next time 22 | self.options["initialdir"] = result 23 | self.directory = result # compatibility 24 | return result 25 | 26 | class CreateDirectory(Dialog): 27 | command = "tk_getSaveFile" 28 | def _fixresult(self, widget, result): 29 | if result: 30 | # keep directory until next time 31 | self.options["initialdir"] = result 32 | self.directory = result # compatibility 33 | return result 34 | 35 | 36 | def askdirectory (**options): 37 | "Ask for a directory, and return the file name" 38 | return apply(Directory, (), options).show() 39 | 40 | def createdirectory(**options): 41 | "Ask for a directory, and return the file name" 42 | return apply(CreateDirectory, (), options).show() 43 | 44 | -------------------------------------------------------------------------------- /mglutil/gui/BasicWidgets/Tk/fileBrowsers.py: -------------------------------------------------------------------------------- 1 | import user 2 | import tkinter.filedialog, os 3 | 4 | 5 | def fileOpenAsk(master, idir=None, ifile=None, types=None, 6 | title='Open'): 7 | if types==None: types = [ ('All files', '*') ] 8 | file = tkinter.filedialog.askopenfilename( filetypes=types, 9 | initialdir=idir, 10 | initialfile=ifile, 11 | title=title) 12 | if file=='': file = None 13 | return file 14 | 2 15 | def fileSaveAsk(master, idir=None, ifile=None, types = None, 16 | title='Save'): 17 | if types==None: types = [ ('All files', '*') ] 18 | file = tkinter.filedialog.asksaveasfilename( filetypes=types, 19 | initialdir=idir, 20 | initialfile=ifile, 21 | title=title) 22 | if file=='': file = None 23 | return file 24 | 25 | from mglutil.gui.BasicWidgets.Tk.dirDialog import askdirectory 26 | 27 | class DirOpenBrowser: 28 | 29 | def __init__(self, lastDir=None, title=None, parent=None): 30 | self.lastDir = lastDir 31 | if lastDir is None: 32 | self.lastDir = user.home 33 | self.title = title 34 | if title is None: 35 | self.title = 'Choose Directory' 36 | self.parent = parent 37 | 38 | 39 | def get(self): 40 | folder = tkinter.filedialog.askdirectory(parent = self.parent, 41 | initialdir = self.lastDir, 42 | title=self.title) 43 | if folder: 44 | self.lastDir = os.path.split(folder)[0] 45 | return folder 46 | else: 47 | return None 48 | 49 | 50 | class FileOpenBrowser: 51 | 52 | def __init__(self, lastDir=None, title=None, filetypes=None, parent=None): 53 | self.lastDir = lastDir 54 | if lastDir is None: 55 | self.lastDir = user.home 56 | self.title = title 57 | if title is None: 58 | self.title = 'Choose File' 59 | self.filetypes = filetypes 60 | self.parent = parent 61 | if filetypes is None: 62 | self.filetypes = [('all', '*')] 63 | 64 | 65 | def get(self): 66 | file = tkinter.filedialog.askopenfilename(parent = self.parent, 67 | initialdir = self.lastDir, filetypes=self.filetypes, 68 | title=self.title) 69 | 70 | if file: 71 | self.lastDir = os.path.split(file)[0] 72 | return file 73 | else: 74 | return None 75 | 76 | class FileSaveBrowser: 77 | 78 | def __init__(self, lastDir=None, title=None, filetypes=None): 79 | self.lastDir = lastDir 80 | if lastDir is None: 81 | self.lastDir = user.home 82 | self.title = title 83 | if title is None: 84 | self.title = 'Choose File' 85 | self.filetypes = filetypes 86 | if filetypes is None: 87 | self.filetypes = [('all', '*')] 88 | 89 | 90 | def get(self): 91 | file = tkinter.filedialog.asksaveasfilename( 92 | initialdir = self.lastDir, filetypes=self.filetypes, 93 | title=self.title) 94 | 95 | if file: 96 | self.lastDir = os.path.split(file)[0] 97 | return file 98 | else: 99 | return None 100 | 101 | -------------------------------------------------------------------------------- /mglutil/gui/BasicWidgets/Tk/trees/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/mglutil/gui/BasicWidgets/Tk/trees/__init__.py -------------------------------------------------------------------------------- /mglutil/gui/BasicWidgets/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/mglutil/gui/BasicWidgets/__init__.py -------------------------------------------------------------------------------- /mglutil/gui/InputForm/Tk/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/mglutil/gui/InputForm/Tk/__init__.py -------------------------------------------------------------------------------- /mglutil/gui/InputForm/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/mglutil/gui/InputForm/__init__.py -------------------------------------------------------------------------------- /mglutil/gui/Misc/Tk/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/mglutil/gui/Misc/Tk/__init__.py -------------------------------------------------------------------------------- /mglutil/gui/Misc/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/mglutil/gui/Misc/__init__.py -------------------------------------------------------------------------------- /mglutil/gui/Spline/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | #$Id: __init__.py,v 1.1 2007/07/13 18:29:39 sowjanya Exp $ 4 | 5 | -------------------------------------------------------------------------------- /mglutil/gui/__init__.py: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # 3 | # Date: 2000 Authors: Guillaume Vareille, Michel Sanner 4 | # 5 | # vareille@scripps.edu 6 | # sanner@scripps.edu 7 | # 8 | # The Scripps Research Institute (TSRI) 9 | # Molecular Graphics Lab 10 | # La Jolla, CA 92037, USA 11 | # 12 | # Copyright: Guillaume Vareille, Michel Sanner and TSRI 13 | # 14 | ######################################################################### 15 | # 16 | # $Header: /opt/cvs/python/packages/share1.5/mglutil/gui/__init__.py,v 1.13 2010/04/14 22:39:42 sanner Exp $ 17 | # 18 | # $Id: __init__.py,v 1.13 2010/04/14 22:39:42 sanner Exp $ 19 | # 20 | 21 | import os 22 | import sys 23 | import warnings 24 | 25 | mglutilrcText = """######################################################################## 26 | # 27 | # Date: Decembre 2006 Authors: Guillaume Vareille, Michel Sanner 28 | # 29 | # vareille@scripps.edu 30 | # sanner@scripps.edu 31 | # 32 | # The Scripps Research Institute (TSRI) 33 | # Molecular Graphics Lab 34 | # La Jolla, CA 92037, USA 35 | # 36 | # Copyright: Guillaume Vareille, Michel Sanner and TSRI 37 | # 38 | # mglutil Resource File 39 | # 40 | ######################################################################### 41 | # To customize mglutil, you can modify the _mglutilrc file: 42 | # unix: ~/.mgltools/[version number]/mglutil/_mglutilrc 43 | # windows: \Documents and Settings\(user name)\.mgltools\(version numer)\mglutil\_mglutilrc 44 | # DejaVu will generate this file automatically if it can't find it 45 | # Do not modify the original source file 46 | ################################################################## 47 | 48 | import os 49 | 50 | widgetsOnBackWindowsCanGrabFocus = (os.name != 'nt') # True, False 51 | 52 | """ 53 | 54 | def ensureMglutilResourceFile(): 55 | """verify or generate _mglutilrc file 56 | """ 57 | #print "ensureMglutilResourceFile" 58 | 59 | from mglutil.util.packageFilePath import getResourceFolderWithVersion 60 | rcFolder = getResourceFolderWithVersion() 61 | if rcFolder is None: 62 | return None 63 | rcFolder += os.sep + 'mglutil' 64 | if not os.path.isdir(rcFolder): 65 | try: 66 | os.mkdir(rcFolder) 67 | except: 68 | txt = "Cannot create the Resource Folder %s" %rcFolder 69 | warnings.warn(txt) 70 | return None 71 | 72 | rcFile = rcFolder + os.sep + '_mglutilrc' 73 | if os.path.isfile(rcFile) is False: 74 | try: 75 | f = open(rcFile, "w") 76 | global mglutilrcText 77 | list(map( lambda x, f=f: f.write(x), mglutilrcText )) 78 | f.close() 79 | except: 80 | txt = "can not create _mglutilrc" 81 | warnings.warn(txt) 82 | return None 83 | 84 | return rcFile 85 | 86 | 87 | # after this we can access variables in _mglutilrc with 88 | # from mglutil.gui import widgetsOnBackWindowsCanGrabFocus 89 | rcFile = ensureMglutilResourceFile() 90 | if rcFile is None: 91 | exec( mglutilrcText ) 92 | else: 93 | exec(compile(open( rcFile, "rb" ).read(), rcFile, 'exec')) 94 | 95 | if os.name != 'nt': #sys.platform != 'win32': 96 | # we create a symbolic link to the shell script that launch python 97 | # this is link is used by the self-running saved vision network to 98 | # find mgltools 99 | # (we create this each time we run mglutils, 100 | # this way the last running vision will be used) 101 | mgltoolsDir = os.path.split(os.path.split(os.path.split(os.path.split( 102 | __file__)[0])[0])[0])[0] 103 | pythonshFile = os.path.join(mgltoolsDir, 'bin', 'pythonsh') 104 | if os.path.isfile(pythonshFile) is False: 105 | pythonshFile = os.path.realpath(sys.executable)+'sh' 106 | try: 107 | os.system('ln -f -s ' + pythonshFile + ' ~' + os.sep +'.mgltools'+ os.sep +'pythonsh') 108 | except: 109 | pass 110 | 111 | 112 | -------------------------------------------------------------------------------- /mglutil/math/__init__.py: -------------------------------------------------------------------------------- 1 | import numpy 2 | import types 3 | 4 | def crossProduct (A, B, normal=True): 5 | """ Return cross product of two vectors A and B 6 | normal: return normalized vector 7 | """ 8 | res=[ A[1]*B[2] - A[2]*B[1], 9 | A[2]*B[0] - A[0]*B[2], 10 | A[0]*B[1] - A[1]*B[0] ] 11 | if normal: 12 | return norm(res) 13 | else: 14 | return res 15 | 16 | def norm (A): 17 | """ Return normalized vector A. 18 | """ 19 | if type(A) == list: 20 | A=numpy.array(A,'f') 21 | res= A/numpy.sqrt(numpy.dot(A,A)) 22 | return res.tolist() 23 | elif type(A)==numpy.ndarray: 24 | return A/numpy.sqrt(numpy.dot(A,A)) 25 | else: 26 | print("Need a list or numpy array") 27 | return None 28 | 29 | def getCenter(coords): 30 | """ get center of all the coords """ 31 | coords=numpy.array(coords, 'f') 32 | return (numpy.sum(coords, 0)/len(coords)).tolist() 33 | -------------------------------------------------------------------------------- /mglutil/math/ncoords.py: -------------------------------------------------------------------------------- 1 | # 2 | # Last modified on Tue Sep 4 16:32:29 PDT 2001 by lindy 3 | # 4 | # $Header: /opt/cvs/python/packages/share1.5/mglutil/math/ncoords.py,v 1.2.12.1 2016/02/11 19:04:10 annao Exp $ 5 | # 6 | 7 | """ncoords.py - Numeric coordinates 8 | 9 | This class is intented to be the base class of a number 10 | of classes which transform and generally operate on lists 11 | of homogeneous coordinates. 12 | """ 13 | 14 | import numpy 15 | 16 | class Ncoords: 17 | def __init__(self, refCoords, tolist=1): 18 | """refCoords is an nx3 list of n points 19 | 20 | resultCoords is set up and maintained as homogeneous coords 21 | if tolist then return the result coords as a python list 22 | """ 23 | try: 24 | self.refCoords = numpy.array(numpy.concatenate( 25 | (refCoords, numpy.ones( (len(refCoords), 1), 'f')), 1)) 26 | except TypeError: 27 | raise ValueError("invalid input array") 28 | 29 | self.resultCoords = self.refCoords 30 | self.tolist = tolist 31 | 32 | 33 | def reset(self): 34 | self.resultCoords = self.refCoords 35 | 36 | 37 | def getResultCoords(self): 38 | """Return the list of result coordinates 39 | 40 | if tolist is set, return an nx3 Python ListType. 41 | if tolist is not set, return an nx4 numpy array. 42 | """ 43 | if self.tolist: 44 | return self.resultCoords[:,:3].tolist() 45 | else: 46 | return self.resultCoords 47 | 48 | 49 | -------------------------------------------------------------------------------- /mglutil/math/ncoordstest.py: -------------------------------------------------------------------------------- 1 | # 2 | # Last modified on Tue Sep 4 17:02:59 PDT 2001 by lindy 3 | # 4 | # $Header: /opt/cvs/python/packages/share1.5/mglutil/math/ncoordstest.py,v 1.2.12.1 2016/02/11 19:04:10 annao Exp $ 5 | # 6 | 7 | """Unit test for ncoords.py 8 | 9 | Requirements for ncoords.py: 10 | A. __init__: 11 | 1. make Numeric, homogenious coordinates out of refCoords 12 | 2. raise ValueError if refCoords is bad 13 | B. reset(): 14 | 3. nx3 slice of resultCoords must be equal to refCoords 15 | C. getResultCoords: 16 | 4. return nx3 (not nx4) coordinates 17 | 5. return as numpy.array or ListType accorinding to self.tolist 18 | """ 19 | 20 | from mglutil.math.ncoords import Ncoords 21 | import unittest, math 22 | import numpy 23 | import numpy.random as RandomArray 24 | 25 | 26 | 27 | 28 | class NcoordsTest(unittest.TestCase): 29 | def setUp(self): 30 | """Called for every test.""" 31 | 32 | npts = 500 33 | dim = 3 34 | self.max = 9999999. 35 | self.min = -self.max 36 | self.random_points = RandomArray.uniform(self.min, 37 | self.max, (npts,dim)).tolist() 38 | 39 | 40 | def tearDown(self): 41 | pass 42 | 43 | 44 | 45 | class InputOutputValues(NcoordsTest): 46 | 47 | 48 | def test_constructor_shape(self): 49 | """__init__ -- make refCoords and resultCoords homogeneous""" 50 | n = len(self.random_points) 51 | ncoords = Ncoords( self.random_points) ### tested call ### 52 | # confirm shape to be nx4 53 | self.assertEqual( (n, 4), numpy.shape(ncoords.resultCoords)) 54 | self.assertEqual( (n, 4), numpy.shape(ncoords.refCoords)) 55 | # cofirm that the last column is all ones 56 | self.assertEqual(numpy.ones(n).tolist(), 57 | ncoords.resultCoords[:,3].tolist()) 58 | self.assertEqual(numpy.ones(n).tolist(), 59 | ncoords.refCoords[:,3].tolist()) 60 | 61 | 62 | def test_input_error(self): 63 | """__init__ -- ValueError on bad input""" 64 | self.assertRaises(ValueError, Ncoords, list(range(10))) 65 | self.assertRaises(ValueError, Ncoords, [(1,1,1),(1,1)] ) 66 | 67 | 68 | def test_reset_values(self): 69 | """reset -- points equal input values after reset""" 70 | nc = Ncoords( self.random_points, tolist=1) 71 | nc.reset() ### tested call ### 72 | result = nc.getResultCoords() 73 | # compare input and output point lists 74 | self.assertEqual( self.random_points, result) 75 | 76 | 77 | def test_getResultCoords_shape(self): 78 | """getResultCoords -- if tolist: return nx3 ListType""" 79 | n = len(self.random_points) 80 | nc = Ncoords(self.random_points, tolist=0) 81 | nc.tolist=1 82 | result = nc.getResultCoords() ### tested call ### 83 | # confirm shape 84 | self.assertEqual((n, 3), numpy.shape(result)) 85 | # confirm type 86 | self.assertEqual(type([]), type(result)) 87 | 88 | 89 | def test_getResultCoords_type(self): 90 | """getResultCoords -- if not tolist: return nx4 numpy.array""" 91 | n = len(self.random_points) 92 | nc = Ncoords(self.random_points, tolist=1) 93 | nc.tolist=0 94 | result = nc.getResultCoords() ### tested call ### 95 | # confirm shape 96 | self.assertEqual((n, 4), numpy.shape(result)) 97 | # confirm type 98 | self.assertEqual(type(numpy.array([])), type(result)) 99 | 100 | 101 | 102 | if __name__ == '__main__': 103 | unittest.main() 104 | 105 | # for example: 106 | # py mglutil/math/ncoordstest.py -v 107 | # or, to redirect output to a file: 108 | # py ncoordstest.py -v > & ! /tmp/nct.out 109 | 110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /mglutil/math/rmsdtest.py: -------------------------------------------------------------------------------- 1 | # 2 | # Last modified on Thu Jan 31 10:27:11 PST 2002 by lindy 3 | # 4 | # $Header: /opt/cvs/python/packages/share1.5/mglutil/math/rmsdtest.py,v 1.4.12.1 2016/02/11 23:15:05 annao Exp $ 5 | # 6 | """Unit test for rmsd.py 7 | 8 | Requirements for rmsd: 9 | A. RMSDCalculator.__init__ 10 | 0. should .. 11 | B. RMSDCalculator.setRefCoords 12 | 0. should .. 13 | C. RMSDCalculator.computeRMSD 14 | 1. should return known result with known input 15 | 2. raise ValueError for input of unlike dimensions 16 | 3. for two random sets of points, rmsd(x,y) == rmsd(y,x) 17 | 4. raise ValueError if the reference coords have not been set 18 | D. 19 | 20 | """ 21 | 22 | from mglutil.math import rmsd 23 | import unittest, math 24 | import numpy 25 | from numpy import random as RandomArray 26 | 27 | class ComputedValues(unittest.TestCase): 28 | decimals = 4 # decimal places to round to for float comparison 29 | point_list_0 = numpy.zeros((5,3)) 30 | point_list_1 = numpy.ones( (5,3)) 31 | 32 | knowValues = ( (point_list_0, point_list_0, 0.0), 33 | (point_list_1, point_list_1, 0.0), 34 | (point_list_0, point_list_1, math.sqrt(3.0)), 35 | (point_list_1, point_list_0, math.sqrt(3.0))) 36 | 37 | def test_computeRMSD_KnowValues(self): 38 | """1. should return known result with known input""" 39 | for ref, input, known in self.knowValues: 40 | self.assertEqual(known, 41 | rmsd.RMSDCalculator(ref).computeRMSD(input)) 42 | 43 | 44 | def test_computeRMSD_RandomOffset(self): 45 | """5. offset point by random value returns offset*sqrt(3)""" 46 | min = -10000. 47 | max = 10000. 48 | num_points = 20 49 | dimension = 3 50 | point_list_1 = RandomArray.uniform(min, max, (num_points, dimension)) 51 | delta = point_list_1[0][0] 52 | point_list_2 = point_list_1 + delta 53 | answer = rmsd.RMSDCalculator(point_list_1).computeRMSD(point_list_2) 54 | self.assertEqual( 55 | round(answer, self.decimals), 56 | round(abs(delta)*math.sqrt(3.0), self.decimals)) 57 | 58 | 59 | def test_computeRMSD_Random(self): 60 | """3. for two random sets of points, rmsd(x,y) == rmsd(y,x)""" 61 | min = -10000. 62 | max = 10000. 63 | num_points = 20 64 | dimension = 3 65 | point_list_1 = RandomArray.uniform(min, max, (num_points, dimension)) 66 | point_list_2 = RandomArray.uniform(min, max, (num_points, dimension)) 67 | self.assertEqual( 68 | rmsd.RMSDCalculator(point_list_1).computeRMSD(point_list_2), 69 | rmsd.RMSDCalculator(point_list_2).computeRMSD(point_list_1)) 70 | 71 | 72 | class InputValues(unittest.TestCase): 73 | point_list_0 = numpy.zeros((3,3)) 74 | point_list_1 = numpy.ones( (4,3)) # different lengths 75 | 76 | def test_computeRMSD_dimensions(self): 77 | """2. raise ValueError for input of unlike dimensions""" 78 | ruler = rmsd.RMSDCalculator(self.point_list_0) 79 | self.assertRaises(ValueError, ruler.computeRMSD, self.point_list_1) 80 | 81 | def test_computeRMSD_noRefCoords(self): 82 | """4. raise ValueError if the reference coords have not been set""" 83 | ruler = rmsd.RMSDCalculator() 84 | self.assertRaises(ValueError, ruler.computeRMSD, self.point_list_1) 85 | 86 | if __name__ == "__main__": 87 | unittest.main() 88 | 89 | # for example: py mglutil/math/rmsdtest.py -v 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /mglutil/math/stats.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | 3 | def stats(values): 4 | """returns the mimn, max, mean and standard deviation of a list of values""" 5 | 6 | warnings.warn( 7 | "\n\nWARNING!! This function has been deprecated!!\n \ 8 | Use the stats in Volume/Grid3D.py\n",DeprecationWarning,2) 9 | 10 | npts = len(values) 11 | if npts: 12 | from math import sqrt 13 | sum = 0.0 14 | sumsq = 0.0 15 | mini = maxi = values[0] 16 | for v in values: 17 | sum += v 18 | sumsq += float(v)*float(v) 19 | if vmaxi: 22 | maxi = v 23 | mean = float(sum)/npts 24 | stdev = sqrt(( sumsq - (sum*sum/float(npts)))/(npts-1)) 25 | return mini, maxi, mean, stdev 26 | 27 | else: 28 | return (0., 0., 1., 1.) 29 | 30 | -------------------------------------------------------------------------------- /mglutil/math/torsion.py: -------------------------------------------------------------------------------- 1 | #taken from Pmv/measureCommands.py 2 | import numpy 3 | 4 | def torsion( x1, x2, x3, x4): 5 | """ 6 | Compute the torsion angle between x1, x2, x3, x4. 7 | All coordinates are cartesian; result is in degrees. 8 | Raises a ValueError if angle is not defined. 9 | """ 10 | from math import sqrt, acos 11 | 12 | tang=0.0 13 | x1 = numpy.array(x1, 'f') 14 | x2 = numpy.array(x2, 'f') 15 | x3 = numpy.array(x3, 'f') 16 | x4 = numpy.array(x4, 'f') 17 | 18 | assert x1.shape == (3, ) 19 | assert x2.shape == (3, ) 20 | assert x3.shape == (3, ) 21 | assert x4.shape == (3, ) 22 | 23 | a = x1-x2 24 | b = x3-x2 25 | c = vvmult(a, b) 26 | 27 | a = x2-x3 28 | b = x4-x3 29 | d = vvmult(a, b) 30 | 31 | dd=sqrt(numpy.sum(c*c)) 32 | de=sqrt(numpy.sum(d*d)) 33 | 34 | if dd<0.001 or de<0.001: 35 | raise ValueError ( 'Torsion angle undefined, degenerate points') 36 | 37 | vv = numpy.dot(c, d) / (dd*de); 38 | if vv<1.0: tang=vv 39 | else: tang= 1.0 40 | if tang<-1.0: tang=-1.0 41 | tang = acos(tang) 42 | tang = tang*57.296 43 | 44 | b = vvmult(c, d) 45 | if numpy.dot(a, b) > 0.0: tang = -tang 46 | return tang 47 | 48 | def vvmult( a, b): 49 | """ 50 | Compute a vector product for 3D vectors 51 | """ 52 | res = numpy.zeros(3, 'f') 53 | res[0] = a[1]*b[2] - a[2]*b[1] 54 | res[1] = a[2]*b[0] - a[0]*b[2] 55 | res[2] = a[0]*b[1] - a[1]*b[0] 56 | return res 57 | -------------------------------------------------------------------------------- /mglutil/regression/__init__.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import _py2k_string as string 3 | 4 | VERSION = string.split(sys.version)[0] 5 | 6 | if VERSION >= '2.1': 7 | from . import testplus 8 | else: 9 | from . import testplus_before_2_1 10 | testplus = testplus_before_2_1 11 | 12 | -------------------------------------------------------------------------------- /mglutil/splashregister/__init__.py: -------------------------------------------------------------------------------- 1 | # This package handles splash screen creation and user registration 2 | # 3 | # $Author: sargis $ 4 | # $Header: /opt/cvs/python/packages/share1.5/mglutil/splashregister/__init__.py,v 1.1 2006/05/10 20:25:31 sargis Exp $ 5 | # $Date: 2006/05/10 20:25:31 $ 6 | # $Id: __init__.py,v 1.1 2006/05/10 20:25:31 sargis Exp $ 7 | -------------------------------------------------------------------------------- /mglutil/splashregister/about.py: -------------------------------------------------------------------------------- 1 | # $Header: /opt/cvs/python/packages/share1.5/mglutil/splashregister/about.py,v 1.10 2011/05/16 18:28:03 sargis Exp $ 2 | # $Id: about.py,v 1.10 2011/05/16 18:28:03 sargis Exp $ 3 | import tkinter, os 4 | from mglutil.util.misc import ensureFontCase 5 | 6 | try: 7 | from PIL import Image, ImageTk 8 | except: 9 | pass 10 | 11 | 12 | class About: 13 | """ 14 | package : mglutil 15 | module : splashregister.about 16 | class : About 17 | description: 18 | Displays information needed for About widget 19 | """ 20 | def __init__(self, title=None, image_dir='.', version='', revision=None, authors=None, 21 | icon=None, copyright=None, third_party='', path_data=''): 22 | self.title = title 23 | self.image_dir = image_dir 24 | self.version = version 25 | self.revision = revision 26 | self.authors = authors 27 | self.icon = icon 28 | self.copyright = copyright 29 | self.third_party = third_party 30 | self.path_data = path_data 31 | 32 | def gui(self, master): 33 | 34 | tkinter.Label(master, text=self.title, font =(ensureFontCase('helvetica'), 16, 'bold') ).\ 35 | pack(side='top') 36 | text = 'Version ' + self.version 37 | if self.revision is not None: 38 | text += ' ' + self.revision 39 | night = self.path_data.find(" Nightly ") 40 | if night != -1: 41 | tmpTxt = self.path_data[night:].split() 42 | text += " - Update Nightly Build " + tmpTxt[1] 43 | else: 44 | tested = self.path_data.find(" Tested ") 45 | if tested != -1: 46 | tmpTxt = self.path_data[tested:].split() 47 | text += " - Update Tested Build " + tmpTxt[1] 48 | 49 | tkinter.Label(master, text=text).pack(side='top') 50 | 51 | files = os.listdir(self.image_dir) 52 | import fnmatch 53 | files = fnmatch.filter(files,'*.jpg') + fnmatch.filter(files,'*.png') 54 | import random 55 | rand = random.randint(0,len(files)-1) 56 | image_file = os.path.join(os.path.join(self.image_dir ,files[rand])) 57 | image = Image.open(image_file) 58 | self.image1 = ImageTk.PhotoImage(image, master=master) 59 | self.imageTk = tkinter.Label(master,image=self.image1 ) 60 | self.imageTk.pack() 61 | tkinter.Label(master, text=self.copyright, relief='sunken' ).pack() 62 | logoFrame = tkinter.Frame(master, bg='white') 63 | logoFrame.pack(fill='x',expand=True) 64 | basepath = os.path.split(__file__)[0] 65 | 66 | NBCR = Image.open(os.path.join(basepath,'NBCR.jpg')) 67 | self.NBCR1 = ImageTk.PhotoImage(NBCR, master=master) 68 | self.NBCRTk = tkinter.Label(logoFrame,image=self.NBCR1, bd=0 ) 69 | self.NBCRTk.pack(side='left', padx=40, expand=True) 70 | NIH = Image.open(os.path.join(basepath,'NIH.gif')) 71 | self.NIH1 = ImageTk.PhotoImage(NIH, master=master) 72 | self.NIHTk = tkinter.Label(logoFrame,image=self.NIH1, bd=0) 73 | self.NIHTk.pack(side='left', padx=40,expand=True) 74 | NSF = Image.open(os.path.join(basepath,'NSF.gif')) 75 | self.NSF1 = ImageTk.PhotoImage(NSF, master=master) 76 | self.NSFTk = tkinter.Label(logoFrame,image=self.NSF1, bd=0) 77 | self.NSFTk.pack(side='left', padx=40, expand=True) 78 | 79 | if __name__ == '__main__': 80 | root = tkinter.Tk() 81 | about = About(image_dir='../../Pmv/Icons/Images') 82 | about.gui(root) 83 | root.mainloop() -------------------------------------------------------------------------------- /mglutil/splashregister/license.py: -------------------------------------------------------------------------------- 1 | # $Header: /opt/cvs/python/packages/share1.5/mglutil/splashregister/license.py,v 1.15 2010/08/19 20:14:31 sargis Exp $ 2 | # $Id: license.py,v 1.15 2010/08/19 20:14:31 sargis Exp $ 3 | # 4 | 5 | import tkinter 6 | 7 | tk_root = tkinter.Tk() 8 | tk_root.title("Commercial Usage") 9 | txt = """ 10 | The software component for computing molecular surfaces (MSMS) 11 | is not free for commercial usage. If you plan to use MSMS for commercial 12 | research please contact sanner@scripps.edu 13 | 14 | Some software components such at the volume rendering and 15 | isocontouring were developed at UT Austin. 16 | 17 | If you publish scientific results generated using this software 18 | please cite the appropriate software components. 19 | A list of papers is provided under Help -> Citation Information 20 | menu in PMV and ADT. 21 | """ 22 | tkinter.Label(tk_root, text=txt, justify=tkinter.LEFT).pack() 23 | tkinter.Button(tk_root, text="OK", command=tk_root.quit).pack() 24 | tk_root.mainloop() 25 | -------------------------------------------------------------------------------- /mglutil/util/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/mglutil/util/__init__.py -------------------------------------------------------------------------------- /mglutil/util/callback.py: -------------------------------------------------------------------------------- 1 | # 2 | # Author Michel F. Sanner (may 2001) Copyright M. Sanner, TSRI 3 | # 4 | # $Id: callback.py,v 1.10.12.2 2017/04/06 23:02:57 annao Exp $ 5 | # 6 | # $Author: annao $ 7 | # 8 | import traceback 9 | import types 10 | 11 | class CallbackManager: 12 | """Class to manage a list of callback functions""" 13 | 14 | def __init__(self): 15 | self.callbacks = [] 16 | 17 | 18 | def FindFunctionByName(self, funcName): 19 | """find a function with a given name in a list of functions""" 20 | 21 | for f in self.callbacks: 22 | if f.__name__==funcName: return f 23 | return None 24 | 25 | 26 | def SetCallback(self, func): 27 | """Delete all and set a callback fuction""" 28 | 29 | assert func is None or callable(func) 30 | if func is None: 31 | self.callbacks = [] 32 | else: 33 | self.callbacks = [func, ] 34 | 35 | 36 | def AddCallback(self, func): 37 | """Add a callback fuction""" 38 | 39 | assert callable(func) 40 | self.callbacks.append(func) 41 | 42 | 43 | def CallCallbacks(self, *args, **kw): 44 | """call all callback fuctions""" 45 | 46 | results = [] 47 | for func in self.callbacks: 48 | try: 49 | results.append( func(*args, **kw) ) 50 | 51 | except: 52 | print('ERROR ************************************************') 53 | traceback.print_exc() 54 | return 'ERROR' 55 | 56 | return results 57 | 58 | 59 | def ListCallbacks(self): 60 | for func in self.callbacks: 61 | print(func.__name__,func) 62 | 63 | 64 | def RemoveCallback(self, func): 65 | """Delete a callback fuction""" 66 | if type(func)==bytes: 67 | func = self.FindFunctionByName(func) 68 | if func is None: return "function %s not found"%func 69 | if func in self.callbacks: 70 | self.callbacks.remove(func) 71 | else: 72 | return "function %s not found"%func.__name__ 73 | 74 | 75 | class CallbackFunction: 76 | """Class to allow to specify arguments to a callback function""" 77 | 78 | def __init__(self, function, *args, **kw): 79 | self.function = function 80 | if hasattr(function, '__name__'): 81 | self.__name__ = function.__name__ 82 | elif hasattr(function, 'name'): 83 | self.__name__ = function.name 84 | elif hasattr(function, '__class__') and hasattr(function.__class__, '__name__'): 85 | self.__name__ = f.__class__.__name__ 86 | else: 87 | self.__name__ = 'noname' 88 | self.args = args 89 | self.kw = kw 90 | 91 | def __call__(self, *args, **kw): 92 | args = self.args + args 93 | kw.update(self.kw) 94 | return self.function(*args, **kw) 95 | 96 | CallBackFunction = CallbackFunction 97 | -------------------------------------------------------------------------------- /mglutil/util/defaultPalettes.py: -------------------------------------------------------------------------------- 1 | # 2 | # $Header: /opt/cvs/python/packages/share1.5/mglutil/util/defaultPalettes.py,v 1.6 2011/06/13 21:40:34 sargis Exp $ 3 | # 4 | # $Id: defaultPalettes.py,v 1.6 2011/06/13 21:40:34 sargis Exp $ 5 | # 6 | """ This file contains the default ColorPalette.""" 7 | ChooseColor = {'red':(1.,0.,0.), 'green':(0.,1.,0.), 8 | 'blue':(0.,0.,1.), 'white':(1.,1.,1.), 9 | 'black':(0.,0.,0.), 'cyan':(0.,1.,1.), 10 | 'yellow':(1.,1.,0.), 'magenta':(1.,0.,1.) 11 | } 12 | ChooseColorSortedKeys = [ 'white', 'black', 'red', 'green', 'blue', 13 | 'cyan', 'yellow', 'magenta' ] 14 | #Rainbow= {0: (0.,0.,1.), 1: (0.,1.,0.), 2: (1.,0.,0.), 15 | # 3: (0.,1.,1.), 4: (1.,1.,0.), 5: (1.,0.,1.), 16 | # 6: (0.,.75,1.), 7: (0.,1.,.5), 8: (.6,1.,0.), 17 | # 9: (1.,.5,0.), 10: (1.,0.,.5), 11:(.5,0.,1.), 18 | # 12:(.5,0.,.2), 13: (0.,.5,.2), 14:(0.75,0,1), 19 | # 15:(1.,0.75,0),16:(1.,0.,0.75,),17:(0., 1., .75), 20 | # 18:(1.,0.,0.25,), 19: (0.,.5,1.)} 21 | # 22 | #RainbowSortedKey = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19] 23 | 24 | Rainbow = {'0': (0.,0.,1.), '1': (0.,1.,0.), '2': (1.,0.,0.), 25 | '3': (0.,1.,1.), '4': (1.,1.,0.), '5': (1.,0.,1.), 26 | '6': (0.,.75,1.), '7': (0.,1.,.5), '8': (.6,1.,0.), 27 | '9': (1.,.5,0.), '10': (1.,0.,.5), '11':(.5,0.,1.), 28 | '12':(.5,0.,.2), '13': (0.,.5,.2), '14':(0.75,0,1), 29 | '15':(1.,0.75,0),'16':(1.,0.,0.75,),'17':(0., 1., .75), 30 | '18':(1.,0.,0.25,), '19': (0.,.5,1.)} 31 | 32 | MolColors = {'0': (1.,0.5,1.), '1': (0., 0.509,0.), '2': (1.,0.5,0.5), 33 | '3': (0.25,0.75,1.), '4': (0.517,0.2549,0.2588), '5': (1.,0.,1.), 34 | '6': (0.,.75,1.), '7': (0.,1.,.5), '8': (.6,1.,0.), 35 | '9': (1.,.5,0.), '10': (1.,0.,.5), '11':(.5,0.,1.), 36 | '12':(.5,0.,.2), '13': (0.,.5,.2), '14':(0.75,0,1), 37 | '15':(1.,0.75,0),'16':(1.,0.,0.75,),'17':(0., 1., .75), 38 | '18':(1.,0.,0.25,), '19': (0.,.5,1.)} 39 | 40 | RainbowSortedKey = ['0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19'] 41 | -------------------------------------------------------------------------------- /mglutil/util/idleUtil.py: -------------------------------------------------------------------------------- 1 | from idlelib import PyShell 2 | #from idlelib.PyShell import PyShell, PyShellFileList, use_subprocess 3 | from idlelib.EditorWindow import fixwordbreaks 4 | import tkinter, sys, os 5 | def getShell(thread, rootTk = None, subprocess = False, debug=False, 6 | enable_shell=False, enable_edit=True): 7 | """ 8 | This function creates and returns a shell PyShell instance 9 | required arguments: 10 | thread -- 11 | 12 | optional arguments: 13 | rootTk -- 14 | subprocess -- boolean flag when set to True a the pyshell 15 | runs a new interpreter in a sub process 16 | when set to False it the user has access to the main 17 | interpreter. (default = False) 18 | enable_shell -- boolean flag when set to True a python shell is 19 | created (by default True) 20 | enable_edit -- boolean flag when set to True a edit shell is created 21 | aware of the python syntax (by default False) 22 | debug -- boolean flag when set to True starts the debugger when 23 | the pyshell is created. (by default = False) 24 | """ 25 | cmd = None 26 | script = None 27 | startup = False 28 | 29 | # try: 30 | # sys.ps1 31 | # except AttributeError: 32 | # sys.ps1 = '>>> ' 33 | 34 | if hasattr(sys, 'ps1') is False: 35 | sys.ps1 = '>>> ' 36 | 37 | global mainThread 38 | 39 | PyShell.use_subprocess = subprocess 40 | mainThread = thread 41 | for i in range(len(sys.path)): 42 | sys.path[i] = os.path.abspath(sys.path[i]) 43 | 44 | pathx = [] 45 | for dir in pathx: 46 | dir = os.path.abspath(dir) 47 | if not dir in sys.path: 48 | sys.path.insert(0, dir) 49 | 50 | global flist, root 51 | if rootTk is None: root = tkinter.Tk() 52 | else: root = rootTk 53 | fixwordbreaks(root) 54 | 55 | flist = PyShell.PyShellFileList(root) 56 | if enable_edit: 57 | flist.new() 58 | if enable_shell : 59 | flist.open_shell() 60 | elif enable_shell: 61 | flist.pyshell = PyShell.PyShell() 62 | #flist.pyshell.begin() 63 | shell = flist.pyshell 64 | if debug: 65 | shell.open_debugger() 66 | return shell 67 | 68 | 69 | -------------------------------------------------------------------------------- /mglutil/util/relpath.py: -------------------------------------------------------------------------------- 1 | """ Author: Alan Ezust 2 | Version: 2.2 3 | Date: October 30, 2004 4 | (relpath.py v1 originally by Cimarron Taylor 5 | from Oreilly/Activestate Python cookbook 2003) 6 | 7 | helper functions for relative paths. 8 | This package includes rel2abs() and abs2rel(), 9 | based on the perl functions from cpan File::Spec 10 | 11 | Version 2.1 fixes/simplifies pathsplit - uses the string split instead of 12 | a very inefficient recursive routine. 13 | Also fixed rel2abs to do a normpath on already absolute paths. 14 | 15 | """ 16 | 17 | import os 18 | import os.path 19 | import re 20 | 21 | # matches http:// and ftp:// and mailto:// 22 | protocolPattern = re.compile(r'^\w+://') 23 | parent = ".." + os.path.sep # use urlparse.urljoin for relative urls 24 | 25 | 26 | def isabs(string): 27 | """ 28 | 29 | @return true if string is an absolute path or protocoladdress 30 | for addresses beginning in http:// or ftp:// or ldap:// - 31 | they are considered "absolute" paths. 32 | """ 33 | if protocolPattern.match(string): return 1 34 | return os.path.isabs(string) 35 | 36 | 37 | def rel2abs(path, base = os.curdir): 38 | """ converts a relative path to an absolute path. 39 | 40 | @param path the path to convert - if already absolute, is returned 41 | normalized 42 | @param base - optional. Defaults to the current location 43 | The base is intelligently concatenated to the given relative path. 44 | @return the relative path of path from base 45 | """ 46 | if isabs(path): return os.path.normpath(path) 47 | retval = os.path.join(base,path) 48 | return os.path.abspath(retval) 49 | 50 | 51 | def commonpath(l1, l2, common=[]): 52 | if len(l1) < 1: return (common, l1, l2) 53 | if len(l2) < 1: return (common, l1, l2) 54 | if l1[0] != l2[0]: return (common, l1, l2) 55 | return commonpath(l1[1:], l2[1:], common+[l1[0]]) 56 | 57 | 58 | def relpath(base, path): 59 | """ returns the relative path from base to path """ 60 | baselist = base.split(os.path.sep) 61 | pathlist = path.split(os.path.sep) 62 | (common,l1,l2) = commonpath(baselist, pathlist) 63 | p = [] 64 | if len(l1) > 0: 65 | p = [ parent * len(l1) ] 66 | p = p + l2 67 | if len(p) is 0: 68 | return "." 69 | return os.path.join( *p ) 70 | 71 | 72 | def abs2rel(path, base = os.curdir): 73 | """ @return a relative path from base to path. 74 | 75 | base can be absolute, or relative to curdir, or defaults 76 | to curdir. 77 | """ 78 | if protocolPattern.match(path): return path 79 | base = rel2abs(base) 80 | return relpath(base, path) 81 | 82 | 83 | if __name__ == "__main__" : 84 | filename = "/home/alan/public_html/oopdocbook/icons/home.png" 85 | path1 = "/home/alan/public_html/oopdocbook" 86 | path2 = "/home/alan/public_html/oopdocbook/" 87 | 88 | rel1 = abs2rel(filename, path1) 89 | rel2 = abs2rel(filename, path2) 90 | assert (rel1 == rel2) 91 | 92 | assert (rel2 == "icons/home.png") 93 | 94 | path3 = "/home/alan/public_html/photos/misc/jewel.png" 95 | path4 = "/home/alan/public_html/oopdocbook/docs/" 96 | relpath = abs2rel(path3, path4) 97 | 98 | expected = os.path.join("..", "..", "photos", "misc", "jewel.png") 99 | assert (relpath == expected) 100 | 101 | print("done") 102 | -------------------------------------------------------------------------------- /mglutil/util/repeatPrinter.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | class RepeatPrinter: 4 | """ 5 | The class allows printing repeating messages on the last line of a terminal (Unix only). This can be used to display a counter that does not scroll the terminal 6 | 7 | example: 8 | printer = RepeatPrinter() 9 | printer.prompt('Hello World') 10 | for i in range(20): 11 | printer.update(str(i)) 12 | 13 | thsi code will display 'Hello World' followed by a counter 14 | """ 15 | 16 | def __init__(self): 17 | # use tcup lines to find out how many lines in the terminal 18 | self.nbLines = int(os.popen("tput lines").readlines()[0]) 19 | self.repeatingPosition = None 20 | 21 | 22 | def prompt(self, prompt): 23 | # print a message leading the repeating messages 24 | 25 | #os.system("tput sc") 26 | os.system("tput cup %d 0"%(self.nbLines-1)) 27 | self.repeatingPosition = len(prompt) + 1 28 | print(prompt) 29 | 30 | def update(self, msg): 31 | os.system("tput cup %d %d"%(self.nbLines-2, self.repeatingPosition)) 32 | print(msg) 33 | 34 | 35 | 36 | if __name__ == '__main__': 37 | from time import sleep 38 | 39 | printer = RepeatPrinter() 40 | printer.prompt('Hello World') 41 | 42 | sleep(0.5) 43 | for i in range(20): 44 | printer.update(str(i)) 45 | sleep(0.2) 46 | 47 | -------------------------------------------------------------------------------- /mglutil/util/uniq.py: -------------------------------------------------------------------------------- 1 | ## def uniq(l, func=None): 2 | ## """Return a new list with duplicate items removed.""" 3 | 4 | ## l2 = l[:] # make a copy 5 | ## d = {} 6 | ## def add_to_dict(value,d=d): 7 | ## d[`value`] = value 8 | ## map(add_to_dict,l2) 9 | ## l3 = d.values() 10 | ## if len(l2)==len(l3): return(l2) 11 | ## if func: l3.sort(func) 12 | ## else: l3.sort() 13 | ## return l3 14 | 15 | def uniq(alist): # Fastest order preserving 16 | set = {} 17 | return [set.setdefault(e,e) for e in alist if e not in set] 18 | 19 | def uniq3(alist): # Fastest without order preserving 20 | set = {} 21 | list(map(set.__setitem__, alist, [])) 22 | return list(set.keys()) 23 | 24 | """ 25 | from mglutil.util.uniq import uniq, uniq2, uniq3 26 | import time 27 | a=range(100) 28 | b=range(10) 29 | c=a+b 30 | 31 | t1=time.time() 32 | for i in range(5000): x=uniq(c) 33 | print time.time()-t1 34 | 35 | t1=time.time() 36 | for i in range(5000): x=uniq2(c) 37 | print time.time()-t1 38 | 39 | t1=time.time() 40 | for i in range(5000): x=uniq3(c) 41 | print time.time()-t1 42 | 43 | 44 | >>> 45 | 0.865363121033 46 | 0.463307857513 47 | 0.260641098022 48 | """ 49 | -------------------------------------------------------------------------------- /mglutil/web/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/mglutil/web/__init__.py -------------------------------------------------------------------------------- /mglutil/web/regression/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/mglutil/web/regression/__init__.py -------------------------------------------------------------------------------- /mglutil/web/regression/testAll.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from mglutil.regression import testplus 3 | from . import test_htmlparser 4 | 5 | harness = testplus.TestHarness( __name__, 6 | funs = [], 7 | dependents = [test_htmlparser.harness, 8 | ], 9 | ) 10 | 11 | if __name__ == '__main__': 12 | print(harness) 13 | sys.exit( len( harness)) 14 | -------------------------------------------------------------------------------- /mglutil/web/regression/test_htmlparser.py: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # 3 | # Date: Nov. 2002 Author: Daniel Stoffler 4 | # 5 | # Copyright: Daniel Stoffler and TSRI 6 | # 7 | ######################################################################### 8 | 9 | import sys 10 | from mglutil.regression import testplus 11 | from mglutil.web import HTMLParser 12 | from time import sleep 13 | 14 | def pause(sleepTime=0.4): 15 | ed.master.update() 16 | sleep(sleepTime) 17 | 18 | def test_ParseCGIForms(): 19 | f = open('testfile.html','r') 20 | txt = f.readlines() 21 | P = HTMLParser.ParseHTML(mode='forms') 22 | forms = P.parse(txt) 23 | f.close() 24 | 25 | # we have 4 forms in this testfile (INPUT) 26 | assert len(forms) == 4 27 | 28 | # FORM 0: 29 | # form 0 has a text entry and a sumbit button (INPUT) 30 | assert len(list(forms[0].input.keys())) == 2 31 | # form 0 has no name, the parser should set the name to 'form_0' 32 | assert forms[0].name == 'form_0' 33 | # the method of form 0 is 'post' 34 | assert forms[0].method == 'post' 35 | # the action of form 0 is http://hoohoo.ncsa.uiuc.edu/cgi-bin/post-query 36 | assert forms[0].action == 'http://hoohoo.ncsa.uiuc.edu/cgi-bin/post-query' 37 | # testing the inputs: 38 | 39 | assert forms[0].input['input_0']['type'] == 'submit' 40 | assert forms[0].input['input_0']['value'] == 'Submit Query' 41 | 42 | ########################################################################## 43 | # FORM 1 44 | # form[1] has 2 text entry, 3 checkbuttons, 7 radiobuttons, 1 submit button 45 | 46 | assert len(list(forms[1].input.keys())) == 3 # 2 text entries, 1 submit button 47 | assert len(list(forms[1].radiobutton.items())) == 2 # 2 categories 48 | assert len(forms[1].radiobutton['paymethod']) == 5 49 | assert len(forms[1].radiobutton['callfirst']) == 2 # 5 + 2 = 7 50 | 51 | assert len(list(forms[1].checkbutton.items())) == 1 # 1 category 52 | assert len(forms[1].checkbutton['topping']) == 3 # 3 buttons 53 | 54 | ########################################################################## 55 | # FORM 2 56 | # form[2] has 2 comboboxes (SELECT) and 2 buttons (INPUT) 57 | assert len(list(forms[2].select.keys())) == 2 58 | assert len(list(forms[2].input.keys())) == 2 59 | # testing comboboxes: 60 | assert len(forms[2].select['what-to-do']['options']) == 5 61 | assert forms[2].select['what-to-do']['options'][0] == 'Drink Coffee' 62 | 63 | assert len(forms[2].select['who-to-do-it-with']['options']) == 6 64 | assert forms[2].select['who-to-do-it-with']['options'][-1] == 'Chouck' 65 | 66 | ########################################################################## 67 | # FORM 3 68 | # form[3] has 3 textareas (TEXTAREA) and 2 buttons (INPUT) 69 | 70 | print(forms[3].textarea) 71 | assert len(list(forms[3].textarea.items())) == 3 72 | assert len(forms[3].input) == 2 73 | # testing textareas: 74 | assert forms[3].textarea['positive']['cols'] == '60' 75 | assert forms[3].textarea['positive']['rows'] == '20' 76 | assert forms[3].textarea['username']['text'][0] == 'Your Name Here' 77 | 78 | 79 | harness = testplus.TestHarness( __name__, 80 | funs = testplus.testcollect( globals()), 81 | ) 82 | 83 | if __name__ == '__main__': 84 | print(harness) 85 | sys.exit( len( harness)) 86 | -------------------------------------------------------------------------------- /mglutil/web/services/SecurityuserimportImplService_services.py: -------------------------------------------------------------------------------- 1 | ################################################## 2 | # ./SecurityuserimportImplService_services.py 3 | # generated by ZSI.wsdl2python 4 | # 5 | # 6 | ################################################## 7 | 8 | 9 | import urllib.parse, types 10 | from ZSI.TCcompound import Struct 11 | from ZSI import client 12 | import ZSI 13 | 14 | class SecurityuserimportImplServiceInterface: 15 | def getSecurityuserimportImpl(self, portAddress=None, **kw): 16 | raise NonImplementationError("method not implemented") 17 | 18 | 19 | class SecurityuserimportImplServiceLocator(SecurityuserimportImplServiceInterface): 20 | SecurityuserimportImpl_address = "https://gama.nbcr.net:9443/axis/services/SecurityUserImportService" 21 | def getSecurityuserimportImplAddress(self): 22 | return SecurityuserimportImplServiceLocator.SecurityuserimportImpl_address 23 | 24 | def getSecurityuserimportImpl(self, portAddress=None, **kw): 25 | return SecurityUserImportServiceSoapBindingSOAP(portAddress or SecurityuserimportImplServiceLocator.SecurityuserimportImpl_address, **kw) 26 | 27 | 28 | class SecurityUserImportServiceSoapBindingSOAP: 29 | 30 | def __init__(self, addr, **kw): 31 | netloc = (urllib.parse.urlparse(addr)[1]).split(":") + [80,] 32 | if "host" not in kw: 33 | kw["host"] = netloc[0] 34 | if "port" not in kw: 35 | kw["port"] = int(netloc[1]) 36 | if "url" not in kw: 37 | kw["url"] = urllib.parse.urlparse(addr)[2] 38 | self.binding = client.Binding(**kw) 39 | 40 | 41 | def listUsers(self, request): 42 | """ 43 | @param: request to listUsersRequest 44 | @return: response from listUsersResponse:: 45 | _listUsersReturn: str 46 | """ 47 | 48 | if not isinstance(request, listUsersRequest) and\ 49 | not issubclass(listUsersRequest, request.__class__): 50 | raise TypeError("%s incorrect request type" %(request.__class__)) 51 | kw = {} 52 | response = self.binding.Send(None, None, request, soapaction="", **kw) 53 | response = self.binding.Receive(listUsersResponseWrapper()) 54 | 55 | if not isinstance(response, listUsersResponse) and\ 56 | not issubclass(listUsersResponse, response.__class__): 57 | raise TypeError("%s incorrect response type" %(response.__class__)) 58 | return response 59 | 60 | 61 | 62 | class listUsersRequest (ZSI.TCcompound.Struct): 63 | def __init__(self, name=None, ns=None): 64 | 65 | oname = None 66 | if name: 67 | oname = name 68 | if ns: 69 | oname += ' xmlns="%s"' % ns 70 | ZSI.TC.Struct.__init__(self, listUsersRequest, [], pname=name, aname="%s" % name, oname=oname ) 71 | 72 | class listUsersRequestWrapper(listUsersRequest): 73 | """wrapper for rpc:encoded message""" 74 | 75 | typecode = listUsersRequest(name='listUsers', ns='urn:axis') 76 | def __init__( self, name=None, ns=None, **kw ): 77 | listUsersRequest.__init__( self, name='listUsers', ns='urn:axis' ) 78 | 79 | class listUsersResponse (ZSI.TCcompound.Struct): 80 | def __init__(self, name=None, ns=None): 81 | self._listUsersReturn = None 82 | 83 | oname = None 84 | if name: 85 | oname = name 86 | if ns: 87 | oname += ' xmlns="%s"' % ns 88 | ZSI.TC.Struct.__init__(self, listUsersResponse, [ZSI.TC.String(pname="listUsersReturn",aname="_listUsersReturn",optional=1),], pname=name, aname="%s" % name, oname=oname ) 89 | 90 | class listUsersResponseWrapper(listUsersResponse): 91 | """wrapper for rpc:encoded message""" 92 | 93 | typecode = listUsersResponse(name='listUsersResponse', ns='urn:axis') 94 | def __init__( self, name=None, ns=None, **kw ): 95 | listUsersResponse.__init__( self, name='listUsersResponse', ns='urn:axis' ) 96 | -------------------------------------------------------------------------------- /mglutil/web/services/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaimergp/autodocktools-prepare-py3k/ce1ce320684fef18718ab9febd98f1e428953839/mglutil/web/services/__init__.py -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | """ 2 | AutoDockTools-prepare-py3k 3 | Preparation routines from ADT, ported to Python 3 4 | """ 5 | import sys 6 | from setuptools import setup, find_packages 7 | 8 | short_description = __doc__.split("\n") 9 | 10 | 11 | try: 12 | with open("README.md", "r") as handle: 13 | long_description = handle.read() 14 | except: 15 | long_description = "\n".join(short_description[2:]) 16 | 17 | 18 | setup( 19 | name='autodocktools-prepare', 20 | author='Jaime RG', 21 | author_email='jaime.rodriguez@charite.de', 22 | description=short_description[0], 23 | long_description=long_description, 24 | long_description_content_type="text/markdown", 25 | version="1.5.7", 26 | license='MPL', 27 | packages=find_packages(), 28 | scripts=[ 29 | 'AutoDockTools/Utilities24/prepare_receptor4.py', 30 | 'AutoDockTools/Utilities24/prepare_ligand4.py' 31 | ] 32 | ) 33 | --------------------------------------------------------------------------------