Best Python code snippet using pyatom_python
TTAgP.py
Source:TTAgP.py  
1import sys2from PyQt5 import uic, QtWidgets34qtCreatorFile = "untitled.ui"  #Name of the file here56Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile)7class MyApp(QtWidgets.QMainWindow, Ui_MainWindow):8    def __init__(self):9        QtWidgets.QMainWindow.__init__(self)10        Ui_MainWindow.__init__(self)11        self.setupUi(self)12        self.setFixedSize(self.size())13        self.bottonpred_2.clicked.connect(self.calculation) 1415    def calculation(self):1617        from sklearn.externals import joblib1819        rfc = joblib.load('modelo_entrenado_9.pkl')2021        # Data entry2223        paste_seq = str(self.pasteseq_2.toPlainText())2425        # Computing26        kyte_doolittle = {'A': 1.80, 'C': 2.50, 'D': -3.50, 'E': -3.50, 'F': 2.80,27                          'G': -0.40, 'H': -3.20, 'I': 4.50, 'K': -3.90, 'L': 3.80,28                          'M': 1.90, 'N': -3.50, 'P': -1.60, 'Q': -3.50, 'R': -4.50,29                          'S': -0.80, 'T': -0.70, 'V': 4.20, 'W': -0.90, 'Y': -1.30}3031        net_charge = {'A': 0, 'C': 0, 'D': -1, 'E': -1, 'F': 0,32                      'G': 0, 'H': 0, 'I': 0, 'K': 1, 'L': 0,33                      'M': 0, 'N': 0, 'P': 0, 'Q': 0, 'R': 1,34                      'S': 0, 'T': 0, 'V': 0, 'W': 0, 'Y': 0}3536        net_hydrogen = {'A': 0, 'C': 0, 'D': 1, 'E': 1, 'F': 0,37                        'G': 0, 'H': 1, 'I': 0, 'K': 2, 'L': 0,38                        'M': 0, 'N': 2, 'P': 0, 'Q': 2, 'R': 4,39                        'S': 1, 'T': 1, 'V': 0, 'W': 1, 'Y': 1}4041        a_a = round(paste_seq.count("A")/len(paste_seq+str(0.000001)), 3)42        c_c = round(paste_seq.count("C")/len(paste_seq+str(0.000001)), 3)43        d_d = round(paste_seq.count("D")/len(paste_seq+str(0.000001)), 3)44        e_e = round(paste_seq.count("E")/len(paste_seq+str(0.000001)), 3)45        f_f = round(paste_seq.count("F")/len(paste_seq+str(0.000001)), 3)46        g_g = round(paste_seq.count("G")/len(paste_seq+str(0.000001)), 3)47        h_h = round(paste_seq.count("H")/len(paste_seq+str(0.000001)), 3)48        i_i = round(paste_seq.count("I")/len(paste_seq+str(0.000001)), 3)49        k_k = round(paste_seq.count("K")/len(paste_seq+str(0.000001)), 3)50        l_l = round(paste_seq.count("L")/len(paste_seq+str(0.000001)), 3)51        m_m = round(paste_seq.count("M")/len(paste_seq+str(0.000001)), 3)52        n_n = round(paste_seq.count("N")/len(paste_seq+str(0.000001)), 3)53        p_p = round(paste_seq.count("P")/len(paste_seq+str(0.000001)), 3)54        q_q = round(paste_seq.count("Q")/len(paste_seq+str(0.000001)), 3)55        r_r = round(paste_seq.count("R")/len(paste_seq+str(0.000001)), 3)56        s_s = round(paste_seq.count("S")/len(paste_seq+str(0.000001)), 3)57        t_t = round(paste_seq.count("T")/len(paste_seq+str(0.000001)), 3)58        v_v = round(paste_seq.count("V")/len(paste_seq+str(0.000001)), 3)59        w_w = round(paste_seq.count("W")/len(paste_seq+str(0.000001)), 3)60        y_y = round(paste_seq.count("Y")/len(paste_seq+str(0.000001)), 3)6162        a_kyte = paste_seq.count("A")*kyte_doolittle["A"]63        c_kyte = paste_seq.count("C")*kyte_doolittle["C"]64        d_kyte = paste_seq.count("D")*kyte_doolittle["D"]65        e_kyte = paste_seq.count("E")*kyte_doolittle["E"]66        f_kyte = paste_seq.count("F")*kyte_doolittle["F"]67        g_kyte = paste_seq.count("G")*kyte_doolittle["G"]68        h_kyte = paste_seq.count("H")*kyte_doolittle["H"]69        i_kyte = paste_seq.count("I")*kyte_doolittle["I"]70        k_kyte = paste_seq.count("K")*kyte_doolittle["K"]71        l_kyte = paste_seq.count("L")*kyte_doolittle["L"]72        m_kyte = paste_seq.count("M")*kyte_doolittle["M"]73        n_kyte = paste_seq.count("N")*kyte_doolittle["N"]74        p_kyte = paste_seq.count("P")*kyte_doolittle["P"]75        q_kyte = paste_seq.count("Q")*kyte_doolittle["Q"]76        r_kyte = paste_seq.count("R")*kyte_doolittle["R"]77        s_kyte = paste_seq.count("S")*kyte_doolittle["S"]78        t_kyte = paste_seq.count("T")*kyte_doolittle["T"]79        v_kyte = paste_seq.count("V")*kyte_doolittle["V"]80        w_kyte = paste_seq.count("W")*kyte_doolittle["W"]81        y_kyte = paste_seq.count("Y")*kyte_doolittle["Y"]8283        a_charge = paste_seq.count("A")*net_charge["A"]84        c_charge = paste_seq.count("C")*net_charge["C"]85        d_charge = paste_seq.count("D")*net_charge["D"]86        e_charge = paste_seq.count("E")*net_charge["E"]87        f_charge = paste_seq.count("F")*net_charge["F"]88        g_charge = paste_seq.count("G")*net_charge["G"]89        h_charge = paste_seq.count("H")*net_charge["H"]90        i_charge = paste_seq.count("I")*net_charge["I"]91        k_charge = paste_seq.count("K")*net_charge["K"]92        l_charge = paste_seq.count("L")*net_charge["L"]93        m_charge = paste_seq.count("M")*net_charge["M"]94        n_charge = paste_seq.count("N")*net_charge["N"]95        p_charge = paste_seq.count("P")*net_charge["P"]96        q_charge = paste_seq.count("Q")*net_charge["Q"]97        r_charge = paste_seq.count("R")*net_charge["R"]98        s_charge = paste_seq.count("S")*net_charge["S"]99        t_charge = paste_seq.count("T")*net_charge["T"]100        v_charge = paste_seq.count("V")*net_charge["V"]101        w_charge = paste_seq.count("W")*net_charge["W"]102        y_charge = paste_seq.count("Y")*net_charge["Y"]103104        a_hydrogen = paste_seq.count("A")*net_hydrogen["A"]105        c_hydrogen = paste_seq.count("C")*net_hydrogen["C"]106        d_hydrogen = paste_seq.count("D")*net_hydrogen["D"]107        e_hydrogen = paste_seq.count("E")*net_hydrogen["E"]108        f_hydrogen = paste_seq.count("F")*net_hydrogen["F"]109        g_hydrogen = paste_seq.count("G")*net_hydrogen["G"]110        h_hydrogen = paste_seq.count("H")*net_hydrogen["H"]111        i_hydrogen = paste_seq.count("I")*net_hydrogen["I"]112        k_hydrogen = paste_seq.count("K")*net_hydrogen["K"]113        l_hydrogen = paste_seq.count("L")*net_hydrogen["L"]114        m_hydrogen = paste_seq.count("M")*net_hydrogen["M"]115        n_hydrogen = paste_seq.count("N")*net_hydrogen["N"]116        p_hydrogen = paste_seq.count("P")*net_hydrogen["P"]117        q_hydrogen = paste_seq.count("Q")*net_hydrogen["Q"]118        r_hydrogen = paste_seq.count("R")*net_hydrogen["R"]119        s_hydrogen = paste_seq.count("S")*net_hydrogen["S"]120        t_hydrogen = paste_seq.count("T")*net_hydrogen["T"]121        v_hydrogen = paste_seq.count("V")*net_hydrogen["V"]122        w_hydrogen = paste_seq.count("W")*net_hydrogen["W"]123        y_hydrogen = paste_seq.count("Y")*net_hydrogen["Y"]124125        # PROPERTIES Q-P126127        aliphatic = round((i_i + l_l + v_v), 3)128129        negative_charged = round((d_d + e_e), 3)130131        total_charged = round((d_d + e_e + k_k + h_h + r_r), 3)132133        aromatic = round((f_f + h_h + w_w + y_y), 3)134135        polar = round((d_d + e_e + r_r + k_k + q_q + n_n), 3)136137        neutral = round((a_a + g_g + h_h + p_p + s_s + t_t + y_y), 3)138139        hydrophobic = round((c_c + f_f + i_i + l_l + m_m + v_v + w_w), 3)140141        positive_charged = round((k_k + r_r + h_h), 3)142143        tiny = round((a_a + c_c + d_d + g_g + s_s + t_t), 3)144145        small = round((e_e + h_h + i_i + l_l + k_k + m_m + n_n + p_p + q_q + v_v), 3)146147        large = round((f_f + r_r + w_w + y_y), 3)148149        # SCALES150151        kyleD = round(((a_kyte+c_kyte+d_kyte+e_kyte+f_kyte+g_kyte+h_kyte+i_kyte+k_kyte+l_kyte+m_kyte+n_kyte+p_kyte+q_kyte+r_kyte+s_kyte+t_kyte+v_kyte+w_kyte+y_kyte)/len(paste_seq+str(0.000001))),3)152153        netCharge = a_charge+c_charge+d_charge+e_charge+f_charge+g_charge+h_charge+i_charge+k_charge+l_charge+m_charge+n_charge+p_charge+q_charge+r_charge+s_charge+t_charge+v_charge+w_charge+y_charge154155        netH = round((a_hydrogen+c_hydrogen+d_hydrogen+e_hydrogen+f_hydrogen+g_hydrogen+h_hydrogen+i_hydrogen+k_hydrogen+l_hydrogen+m_hydrogen+n_hydrogen+p_hydrogen+q_hydrogen+r_hydrogen+s_hydrogen+t_hydrogen+v_hydrogen+w_hydrogen+y_hydrogen),3)156157        result = "Probable: " + str(rfc.predict([[netH,netCharge,kyleD,a_a,c_c,d_d,e_e,f_f,g_g,h_h,i_i,k_k,l_l,m_m,n_n,p_p,q_q,r_r,s_s,t_t,v_v,w_w,y_y,tiny,small,large,aliphatic,aromatic,total_charged,negative_charged,positive_charged,polar,neutral,hydrophobic]]))158159        self.textpred_2.setText(str(result))160        self.textpred1_2.setText(str(aliphatic))161        self.textpred2_2.setText(str(negative_charged))162        self.textpred3_2.setText(str(aromatic))163        self.textpred4_2.setText(str(polar))164        self.textpred5_2.setText(str(neutral))165        self.textpred6_2.setText(str(hydrophobic))166        self.textpred7_2.setText(str(positive_charged))167        self.textpred8_2.setText(str(tiny))168        self.textpred9_2.setText(str(small))169        self.textpred10_2.setText(str(large))170        self.textpred11_2.setText(str(kyleD))171        self.textpred13_2.setText(str(netCharge))172        self.textpred14_2.setText(str(netH))173        self.textpred15_2.setText(str(total_charged))174        self.textrelat_2.setText("A: " + str(a_a) + " , " + "C: " + str(c_c) + " , " + "D: " + str(d_d) + " , " + "E: " + str(e_e) + " , " + "F: " + str(f_f) + " , " + "E: " + str(e_e) + " , " + "G: " + str(g_g) + " , " + "I: " + str(i_i) + " , " + "K: " + str(k_k) + " , " + "L: " + str(l_l) + " , " + "M: " + str(m_m) + " , " + "N: " + str(n_n) + " , " + "P: " + str(p_p) + " , " + "Q: " + str(q_q) + " , " + "R: " + str(r_r) + " , " + "S: " + str(s_s) + " , " + "T: " + str(t_t) + " , " + "V: " + str(v_v) + " , " + "W: " + str(w_w) + " , " + "Y: " + str(y_y))175176177if __name__ == "__main__":178    app = QtWidgets.QApplication(sys.argv)179    window = MyApp()180    window.show()
...setup.py
Source:setup.py  
1# If true, then the svn revision won't be used to calculate the2# revision (set to True for real releases)3RELEASE = False4__version__ = '1.7.2'5from setuptools import setup, find_packages6import sys, os7sys.path.insert(0, os.path.join(os.path.dirname(__file__),8                                'paste', 'util'))9import finddata10setup(name="Paste",11      version=__version__,12      description="Tools for using a Web Server Gateway Interface stack",13      long_description="""\14These provide several pieces of "middleware" (or filters) that can be nested to build web applications.  Each15piece of middleware uses the WSGI (`PEP 333`_) interface, and should16be compatible with other middleware based on those interfaces.17.. _PEP 333: http://www.python.org/peps/pep-0333.html18Includes these features...19Testing20-------21* A fixture for testing WSGI applications conveniently and in-process,22  in ``paste.fixture``23* A fixture for testing command-line applications, also in24  ``paste.fixture``25* Check components for WSGI-compliance in ``paste.lint``26Dispatching27-----------28* Chain and cascade WSGI applications (returning the first non-error29  response) in ``paste.cascade``30* Dispatch to several WSGI applications based on URL prefixes, in31  ``paste.urlmap``32* Allow applications to make subrequests and forward requests33  internally, in ``paste.recursive``34Web Application35---------------36* Run CGI programs as WSGI applications in ``paste.cgiapp``37* Traverse files and load WSGI applications from ``.py`` files (or38  static files), in ``paste.urlparser``39* Serve static directories of files, also in ``paste.urlparser``; also40  in that module serving from Egg resources using ``pkg_resources``.41Tools42-----43* Catch HTTP-related exceptions (e.g., ``HTTPNotFound``) and turn them44  into proper responses in ``paste.httpexceptions``45* Several authentication techniques, including HTTP (Basic and46  Digest), signed cookies, and CAS single-signon, in the47  ``paste.auth`` package.48* Create sessions in ``paste.session`` and ``paste.flup_session``49* Gzip responses in ``paste.gzip``50* A wide variety of routines for manipulating WSGI requests and51  producing responses, in ``paste.request``, ``paste.response`` and52  ``paste.wsgilib``53Debugging Filters54-----------------55* Catch (optionally email) errors with extended tracebacks (using56  Zope/ZPT conventions) in ``paste.exceptions``57* Catch errors presenting a `cgitb58  <http://python.org/doc/current/lib/module-cgitb.html>`_-based59  output, in ``paste.cgitb_catcher``.60* Profile each request and append profiling information to the HTML,61  in ``paste.debug.profile``62* Capture ``print`` output and present it in the browser for63  debugging, in ``paste.debug.prints``64* Validate all HTML output from applications using the `WDG Validator65  <http://www.htmlhelp.com/tools/validator/>`_, appending any errors66  or warnings to the page, in ``paste.debug.wdg_validator``67Other Tools68-----------69* A file monitor to allow restarting the server when files have been70  updated (for automatic restarting when editing code) in71  ``paste.reloader``72* A class for generating and traversing URLs, and creating associated73  HTML code, in ``paste.url``74The latest version is available in a `Subversion repository75<http://svn.pythonpaste.org/Paste/trunk#egg=Paste-dev>`_.76For the latest changes see the `news file77<http://pythonpaste.org/news.html>`_.78""",79      classifiers=[80        "Development Status :: 5 - Production/Stable",81        "Intended Audience :: Developers",82        "License :: OSI Approved :: MIT License",83        "Programming Language :: Python",84        "Topic :: Internet :: WWW/HTTP",85        "Topic :: Internet :: WWW/HTTP :: Dynamic Content",86        "Topic :: Software Development :: Libraries :: Python Modules",87        "Topic :: Internet :: WWW/HTTP :: WSGI",88        "Topic :: Internet :: WWW/HTTP :: WSGI :: Application",89        "Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware",90        "Topic :: Internet :: WWW/HTTP :: WSGI :: Server",91        "Framework :: Paste",92        ],93      keywords='web application server wsgi',94      author="Ian Bicking",95      author_email="ianb@colorstudy.com",96      url="http://pythonpaste.org",97      license="MIT",98      packages=find_packages(exclude=['ez_setup', 'examples', 'packages']),99      package_data=finddata.find_package_data(),100      namespace_packages=['paste'],101      zip_safe=False,102      extras_require={103        'subprocess': [],104        'hotshot': [],105        'Flup': ['flup'],106        'Paste': [],107        'openid': ['python-openid'],108        },109      entry_points="""110      [paste.app_factory]111      cgi = paste.cgiapp:make_cgi_application [subprocess]112      static = paste.urlparser:make_static113      pkg_resources = paste.urlparser:make_pkg_resources114      urlparser = paste.urlparser:make_url_parser115      proxy = paste.proxy:make_proxy116      test = paste.debug.debugapp:make_test_app117      test_slow = paste.debug.debugapp:make_slow_app118      transparent_proxy = paste.proxy:make_transparent_proxy119      watch_threads = paste.debug.watchthreads:make_watch_threads120      [paste.composite_factory]121      urlmap = paste.urlmap:urlmap_factory122      cascade = paste.cascade:make_cascade123      [paste.filter_app_factory]124      error_catcher = paste.exceptions.errormiddleware:make_error_middleware125      cgitb = paste.cgitb_catcher:make_cgitb_middleware126      flup_session = paste.flup_session:make_session_middleware [Flup]127      gzip = paste.gzipper:make_gzip_middleware128      httpexceptions = paste.httpexceptions:make_middleware129      lint = paste.lint:make_middleware130      printdebug = paste.debug.prints:PrintDebugMiddleware 131      profile = paste.debug.profile:make_profile_middleware [hotshot]132      recursive = paste.recursive:make_recursive_middleware133      # This isn't good enough to deserve the name egg:Paste#session:134      paste_session = paste.session:make_session_middleware135      wdg_validate = paste.debug.wdg_validate:make_wdg_validate_middleware [subprocess]136      evalerror = paste.evalexception.middleware:make_eval_exception137      auth_tkt = paste.auth.auth_tkt:make_auth_tkt_middleware138      auth_basic = paste.auth.basic:make_basic139      auth_digest = paste.auth.digest:make_digest140      auth_form = paste.auth.form:make_form141      grantip = paste.auth.grantip:make_grantip142      openid = paste.auth.open_id:make_open_id_middleware [openid]143      pony = paste.pony:make_pony144      errordocument = paste.errordocument:make_errordocument145      auth_cookie = paste.auth.cookie:make_auth_cookie146      translogger = paste.translogger:make_filter147      config = paste.config:make_config_filter148      registry = paste.registry:make_registry_manager149      [paste.server_runner]150      http = paste.httpserver:server_runner151      """,...PastebinHandlers.py
Source:PastebinHandlers.py  
1# -*- coding: utf-8 -*-2'''3Created on Mar 18, 20124@author: haddaway5 Copyright 2012 Root the Box6   Licensed under the Apache License, Version 2.0 (the "License");7   you may not use this file except in compliance with the License.8   You may obtain a copy of the License at9       http://www.apache.org/licenses/LICENSE-2.010   Unless required by applicable law or agreed to in writing, software11   distributed under the License is distributed on an "AS IS" BASIS,12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13   See the License for the specific language governing permissions and14   limitations under the License.15----------------------------------------------------------------------------16This file contains handlers related to the pastebin functionality17'''18from handlers.BaseHandlers import BaseHandler19from models.PasteBin import PasteBin20from libs.SecurityDecorators import authenticated21class PasteHandler(BaseHandler):22    ''' Renders the main page '''23    @authenticated24    def get(self, *args, **kwargs):25        ''' Renders the main page for PasteBin '''26        self.render('pastebin/view.html', user=self.get_current_user())27class CreatePasteHandler(BaseHandler):28    ''' Creates paste bin shares '''29    @authenticated30    def get(self, *args, **kwargs):31        ''' AJAX // Display team text shares '''32        self.render('pastebin/create.html', errors=None)33    @authenticated34    def post(self, *args, **kwargs):35        ''' Creates a new text share '''36        name = self.get_argument("name", '')37        content = self.get_argument("content", '')38        if 0 < len(name) and 0 < len(content):39            user = self.get_current_user()40            paste = PasteBin(team_id=user.team.id)41            paste.name = name42            paste.contents = content43            self.dbsession.add(paste)44            self.dbsession.commit()45            self.event_manager.team_paste_shared(user, paste)46            self.redirect('/user/share/pastebin')47        else:48            self.render('pastebin/create.html',49                        errors=["Missing name or content"])50class DisplayPasteHandler(BaseHandler):51    ''' Displays shared texts '''52    @authenticated53    def get(self, *args, **kwargs):54        ''' AJAX // Retrieves a paste from the database '''55        paste_uuid = self.get_argument("paste_uuid")56        user = self.get_current_user()57        paste = PasteBin.by_uuid(paste_uuid)58        if paste is None or paste not in user.team.pastes:59            self.render("pastebin/display.html",60                        errors=["Paste does not exist."],61                        paste=None62                        )63        else:64            self.render("pastebin/display.html", errors=None, paste=paste)65class DeletePasteHandler(BaseHandler):66    ''' Deletes shared texts '''67    @authenticated68    def post(self, *args, **kwargs):69        ''' AJAX // Delete a paste object from the database '''70        paste = PasteBin.by_uuid(self.get_argument("uuid", ""))71        user = self.get_current_user()72        if paste is not None and paste in user.team.pastes:73            self.dbsession.delete(paste)74            self.dbsession.commit()...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
