Example #1
0
 def _get_payload(self, diccionario):
     diccionario["SDK"] = "Python"
     diccionario["SDKVERSION"] = ver
     try:
         diccionario["LENGUAGEVERSION"] = sys.version
     except Exception, err:
         try:
             diccionario["LENGUAGEVERSION"] = sys.version()
         except Exception, err2:
             diccionario["LENGUAGEVERSION"] = "version unknown"
Example #2
0
	def _get_payload(self,diccionario):
		diccionario["SDK"]="Python"
		diccionario["SDKVERSION"]=ver
		try:
			diccionario["LENGUAGEVERSION"]=sys.version
		except Exception, err:
			try:
				diccionario["LENGUAGEVERSION"]=sys.version()
			except Exception, err2:
				diccionario["LENGUAGEVERSION"]="version unknown"
Example #3
0
    def _get_payload(self, diccionario):
        diccionario["SDK"] = "Python"
        diccionario["SDKVERSION"] = ver
        try:
            diccionario["LENGUAGEVERSION"] = sys.version
        except Exception as err:
            try:
                diccionario["LENGUAGEVERSION"] = sys.version()
            except Exception as err2:
                diccionario["LENGUAGEVERSION"] = "version unknown"

        xmlpayload = "<Request>"
        for key in diccionario:
            xmlpayload += "<" + key + ">" + diccionario[key] + "</" + key + ">"
        xmlpayload += "</Request>"

        return xmlpayload
Example #4
0
def _new_figure_manager(num, *args, **kwargs):
    if pymol._ext_gui is None:
        return new_figure_manager(num, *args, **kwargs)
    backend_tkagg.show._needmain = False
    if sys.version().major >= 3:
        import tkinter as Tk
    else:
        import Tkinter as Tk
    from matplotlib.figure import Figure
    from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, FigureManagerTkAgg
    FigureClass = kwargs.pop('FigureClass', Figure)
    figure = FigureClass(*args, **kwargs)
    window = Tk.Toplevel(master=pymol._ext_gui.root)
    canvas = FigureCanvasTkAgg(figure, master=window)
    figManager = FigureManagerTkAgg(canvas, num, window)
    if matplotlib.is_interactive():
        figManager.show()
    return figManager
Example #5
0
    def _get_payload(self, diccionario):
        diccionario["SDK"] = "Python"
        diccionario["SDKVERSION"] = ver
        try:
            diccionario["LENGUAGEVERSION"] = sys.version
        except Exception as err:
            try:
                diccionario["LENGUAGEVERSION"] = sys.version()
            except Exception as err2:
                diccionario["LENGUAGEVERSION"] = "version unknown"

        # NOTE: added in order to avoid <ApplicationIdentification/> not mapped to message part error
        diccionario["LENGUAGEVERSION"] = diccionario[
            "LENGUAGEVERSION"].replace('\n', '')

        xmlpayload = "<Request>"
        for key in diccionario:
            xmlpayload += "<" + key + ">" + diccionario[key] + "</" + key + ">"
        xmlpayload += "</Request>"

        return xmlpayload
Example #6
0
#Name 


#Description:

#This is a generic python template that has functions from utils.py imported and can be used on CFCE1



#================================================================================
#=============================DEPENDENCIES=======================================
#================================================================================

import sys

print "Using python version %s" % sys.version()


#importing utils package
sys.path.append('/home/cl512/src/pipeline/')
import utils



#================================================================================
#============================GLOBAL PARAMETERS===================================
#================================================================================

#add locations of files and global parameters in this section

Example #7
0
#pythonTemplate.py <- change to title of your script
#130801 <- date
#Name

#Description:

#This is a generic python template that has functions from utils.py imported and can be used on CFCE1

#================================================================================
#=============================DEPENDENCIES=======================================
#================================================================================

import sys

print "Using python version %s" % sys.version()

#importing utils package
sys.path.append('/home/cl512/src/pipeline/')
import utils

#================================================================================
#============================GLOBAL PARAMETERS===================================
#================================================================================

#add locations of files and global parameters in this section

dataFile = '/location/file.txt'
genome = 'hg18'

#================================================================================
def mult(int):
    num = int * 10;
    return num 
a = map( mult, [1,2,3] )
for i in a:
    #print i
    pass

# regex

rex = re.compile('(?:A\d\d)+(A)')
a = "A42Abc"
result = rex.search(a)
#print result.group(1)

# replace/regex

regex = re.compile('hi')
replace = regex.sub('bye', "hi, I'm leaving")
print replace

# os module
cwd = os.getcwd()
#print cwd
ver = sys.version()
print ver



Example #9
0
# !/usr/bin/python
'''
Programmer: Matthew Griffin

Description: A script that deletes all files in a user-inputted dir

'''
try:
    import os
    import shutil
    import sys

except:
    print("Python " + str(sys.version()) + "Is not installed correctly. Try re-installing.")

class Delete:
    def __init__(self):
        direct = input("Enter a dir: ")

        # Making a seperation barrier
        for x in range(0,20):
            print("-", end = "")

        # Trying to find the dir the user inputted
        try:
            print("\n")
            
            # Checking if there are any files in the dir
            if not(os.listdir(direct) == []):
                for filename in os.listdir(direct):
                    print("FOUND FILE: " + str(filename))
			counter	+=1
	file.close()
	return counter

#ex6
file = open('/home/stefano/Università/PB/sequences.seq', 'r')
bases = ['A', 'T', 'G', 'C']
def other_letter(file):
    found = 0
	tot = 0
	for sequence in file:
		sequence = sequence.rstrip()
		for base in sequence:
			if not(base in bases6):
				found = 1
		if found == 1:
			tot += 1
		found = 0
	return tot



# print(line_count('/home/stefano/Università/PB/sequences.seq'))
# print(pattern_count('/home/stefano/Università/PB/sequences.seq', 'CTATA'))
# print(gc_comp('/home/stefano/Università/PB/sequences.seq', 0.5))
# print(length_limit('/home/stefano/Università/PB/sequences.seq', 1000))
print(other_letter(file))
file.close()
import sys
print(sys.version())
Example #11
0
    #"save" behavior
    if 'save' in func:
        plt.savefig("{0}.png".format(path.split('.graphml')[0]))
    #"show" behavior
    if 'show' in func:
        plt.show()

if __name__ == "__main__":
    """
    Script to visualize a graphml file (path as parameter)
    Works ONLY with python 2.7
    Arg 1: path of the graphml to visualize
    Arg 2: The id of the usegraph (to visualize)
    """

    version = sys.version()

    if not '2.7' in version:
        print("Please to install & run this script with Python2.7")
        sys.exit()

    #Get path of the graphml file
    path = sys.argv[1]

    #Get id of the usegraph to draw
    usegraph_id = sys.argv[2]

    func = ""

    #Ask the user if he wants to show or save the usegraph
    while (not 'show' in func) and (not 'save' in func):
Example #12
0
IDEAS:
- Add more file formats
- Add function to see/alert user if old dir is empty
- Add file that holds things like new/old dir, last name
- Name formatting(in case of bad user input)

'''
# Importing stuff
try:
    import os
    import shutil
    import sys

except ImportError:
    print("Python " + str(sys.version()) +
          "is not installed correctly. Try re-installing.")

DEBUG = False


class Rename:
    def __init__(self):
        # Making some basic variables, olddir, newdir, and lastName
        olddir = "old"
        newdir = "new"
        lastName = input(
            "What is your last name [i.e. 'Harris']?: ")  # Getting last name

        # If lastName has any other characters than letters
        if (lastName.isalpha() == False):
Example #13
0

def validate_base_sequence(base_sequence, RNAflag=False):
    """Return True if the string in base_sequence contains only T (or U if RNAflag), C, A, and G char; otherwise false"""
    seq = base_sequence.upper()
    return len(seq) == (seq.count('U' if RNAflag else 'T') +
                        seq.count('C') +
                        seq.count('A') +
                        seq.count('G'))


def gc_content(base_seq):
    assert validate_base_sequence(base_seq), \
        'argument has invalid chars'
    seq = base_seq.upper()
    return (base_seq.count('G') + base_seq.count('C') / len(base_seq))

if __name__ == '__main__':
    my_seq = 'ATGCGTGTGCAAGTGCTG'
    res = gc_content(my_seq)
    print res

import sys
sys.version()
import sys
print(sys.version)


# In[3]:


import sys
print(sys)


# In[4]:


import sys
print sys.version()


# In[5]:


import sys
print(sys.version)


# In[6]:


#introduction to variables
x=10
y=5
Example #15
0
import sys

v = sys.version()
if "2.7" in v:
    from Tkinter import *
    import tkFileDialog
elif "3.3" in v or "3.4" in v:
    from tkinter import *
    import tkinter.tkFileDialog
root = Tk("Text Editor")
text = Text(root)
text.grid()


def saveas():

    global text

    t = text.get("1.0", "end-1c")

    savelocation = tkFileDialog.asksaveasfilename()

    file1 = open(savelocation, "w+")

    file1.write(t)

    file1.close()


button = Button(root, text="Save", command=saveas)
button.grid()
Example #16
0
def version_check():
    return sys.version()
Example #17
0
 def testMultiPatch(self, mock1, mock2, mock3):
     mock1.return_value = "fake os.path"
     mock2.return_value = "fake sys.version"
     print("mock1 (os.path): {}".format(os.path()))
     print("mock2 (sys.version): {}".format(sys.version()))
     print("mock3 (sys.modules): {}".format(sys.modules()))
Example #18
0
 def testPatchB1(self):
     with mock.patch("sys.version",
                     return_value="a fack version info B") as mockEgB:
         r = sys.version()
         print(r)
Example #19
0
    def testPatchA(self, mockEgA):

        r1 = sys.version()
        print(r1)

        self.assertTrue(mockEgA.called)