Пример #1
0
def clock(x):
    '''
    allow user set the alarm in hour,min,sec
    '''
    if x == "1":
        set_alarm = int(input("Set your alarm in hours: "))
        t = set_alarm * 60 * 60
        alarm(t)
    elif x == "2":
        set_alarm = int(input("Set your alarm in mintues: "))
        t = set_alarm * 60
        alarm(t)
    elif x == "3":
        set_alarm = int(input("Set your alarm in seconds: "))
        t = set_alarm
        alarm(t)
    elif x == "4":
        h = int(input("Set your alarm in hours: "))
        m = int(input("Set your alarm in mintues: "))
        s = int(input("Set your alarm in seconds: "))
        t = h * 60 * 60 + m * 60 + s
        print(f"Your alarm: {h}:{m}:{s}")
        alarm(t)
    else:
        try:
            os.system("cls") # clear output for windows
            main()
        except:
            os.systme("clear") # clear output for linux or mac
            main()
        try:
            fileName = fullWorkspacesDir +\
                "/workspace__analytic__%s__%s__%s__%s__%s.root" % (
                    category, 
                    wargs["mass"], wargs["bmodel"], wargs["smode"], wargs["smodel"])
            wsFile = R.TFile(fileName, "UPDATE")
            ws = wsFile.Get("higgs")
            # this will raise if there is no ws
            print ws.allPdfs().contentsString()
            appending = True
            testModelName = getattr(models, wargs["bmodel"])(category=category,
                processName="VBF").getModelName()
            if testModelName in ws.allPdfs().contentsString():
                print "Duplicates are already present! Removing the file!"
                wsFile.Close()
                os.systme("rm %s" % fileName)
                ws = R.RooWorkspace("higgs")
                appending = False
                models.createVariables_Mass(ws, **wargs)
                ws.defineSet("obs", "x")
        except:
            ws = R.RooWorkspace("higgs")
            appending = False
            models.createVariables_Mass(ws, **wargs)
            ws.defineSet("obs", "x")
        R.RooMsgService.instance().setGlobalKillBelow(R.RooFit.FATAL)
        obs = ws.set("obs")

        #
        # Data RooDataHist creation and preserving in Workspace
        #
Пример #3
0
import os
import sys
import numpy as np

assay_all = ['M01', 'M02', 'M16', 'M17', 'M18', 'M20', 'M22', 'M29']

# prepare a wig header file
# 1. prepare the converted wig files
os.systme('python convert_bigwig_into_wig.py')

# 2. Global distance between datasets
os.system(
    'java -mx4000M -jar ChromImpute.jar ComputeGlobalDist CHALLENGE/CONVERTEDDATADIR table_train_vali.txt grch38sizes.txt CHALLENGE/DISTANCEDIR'
)

## with a=10, b=20
# 3. Generate the features
the_command = ''
for the_assay in assay_all:
    the_command += 'java -mx4000M -jar ChromImpute.jar GenerateTrainData -a 10 -b 20 -d 0 CHALLENGE/CONVERTEDDATADIR CHALLENGE/DISTANCEDIR table_train_vali.txt grch38sizes.txt CHALLENGE/TRAINDATA1 ' + the_assay + ' &\n'
the_command += 'wait'
os.system(the_command)

id_all = np.loadtxt('list_final.txt', dtype='str')

# 4. Generate the trained predictors for a specific mark in a specific sample type to be predicted
num_test = len(id_all)
num_parallel = 17
for aaa in np.arange(int(np.ceil(num_test / num_parallel))):
    start = num_parallel * aaa
    end = np.min((num_test, num_parallel * (aaa + 1)))
        try:
            fileName = fullWorkspacesDir +\
                "/workspace__analytic__%s__%s__%s__%s__%s.root" % (
                    category,
                    wargs["mass"], wargs["bmodel"], wargs["smode"], wargs["smodel"])
            wsFile = R.TFile(fileName, "UPDATE")
            ws = wsFile.Get("higgs")
            # this will raise if there is no ws
            print ws.allPdfs().contentsString()
            appending = True
            testModelName = getattr(models, wargs["bmodel"])(
                category=category, processName="VBF").getModelName()
            if testModelName in ws.allPdfs().contentsString():
                print "Duplicates are already present! Removing the file!"
                wsFile.Close()
                os.systme("rm %s" % fileName)
                ws = R.RooWorkspace("higgs")
                appending = False
                models.createVariables_Mass(ws, **wargs)
                ws.defineSet("obs", "x")
        except:
            ws = R.RooWorkspace("higgs")
            appending = False
            models.createVariables_Mass(ws, **wargs)
            ws.defineSet("obs", "x")
        R.RooMsgService.instance().setGlobalKillBelow(R.RooFit.FATAL)
        obs = ws.set("obs")

        #
        # Data RooDataHist creation and preserving in Workspace
        #
Пример #5
0
import os


try:
    while True:
        print(" FUS RO DA!!")
        os.system('cls')

except KeyboardInterrupt:
    os.systme("Pause")
Пример #6
0
            sock.send('1')
            time.sleep(0.005)
        sock.send('9')
        os.system(default)

    elif (why == '2'):
        os.system(cmd2)
        while (why == '2'):
            why = ser.readline(1)
            sock.send('2')
            time.sleep(0.005)
        sock.send('9')
        os.system(default)

    elif (why == '3'):
        os.system(smile)
        while (why == '3'):
            why = ser.readline(1)
            sock.send('3')
            time.sleep(0.005)
        sock.send('9')
        os.system(default)

    elif (why == '4'):
        sock.send('4')
        os.system(kill)

    if (sock.recv == '8'):
        os.system("python sms.py")
        os.systme("feh -F --auto-zoom img/4.png &")
# Subprocess is a library for creating child processes
# Those processes will execute anything we'd like
# A similar more simple way to do that is with os.system, however we have not much control with that
# With subprocess we can control where the stdout and stderr goes and control the process itself
import os
import subprocess

rc = os.systme("exec_path")

# We can simplay use subprocess in the following manner
# This will block until the binary ends
# Note that we can pass shell=True if we want the binary to open up on a new shell
rc = subprocess.call(['df', '-h'])

# We can control where the output goes with opening a subprocess but not blocking
# And telling where to output the stdout and stderr
# In this example we are only piping the stdout into our program
# The stderr will be printed into the screen and None will return to us
# Lastly, we can do the same for stdin and pipe data to the process
p = subprocess.Popen(["echo", "hello world"], stdout=subprocess.PIPE)
# The communicate returns a tuple of (stdout, stderr) and blocks the program
data = p.communicate()
print(data[0])  # stdout
print(data[1])  # stderr
# We can access the return code straight out
p.returncode

# We can use this to pipe one process to another:
# In this example we are opening an rst file and getting all the included files from it
cat = subprocess.Popen(['cat', 'index.rst'], stdout=subprocess.PIPE)
grep = subprocess.Popen(