def start_analysis(self):
     if not self.lineEdit.text():
         QMessageBox.critical(self, "严重错误", "文件夹路径为空")
         return
     if self.label_analysis_status.text() != "分析中":
         self.label_analysis_status.setText("分析中")
         QMessageBox.information(self, "消息", "开始分析...")
         analysis(self.lineEdit.text(), self.comboBox.currentText())
         self.label_analysis_status.setText("完 成")
 def __init__(self):
     self.services = []
     self.resources = []
     self.total_req = 0
     self.timeout = 100000
     self.plat = kube()
     self.analysis = analysis()
     self.vm_types = list()
     self.vm_types.append(vm_type(2, 16000, 30))
     self.vm_types.append(vm_type(4, 16000, 60))
     self.vm_types.append(vm_type(4, 32000, 80))
Exemple #3
0
	def call_graph(self,graph_type,params):
		self.m = mongo('10.0.0.1', 27017,'rktest','sensors')
		self.a = analysis()
		self.p = plotting()
		self.t = truth('test.txt')
		self.z = zone('zone.txt')
		print params
		dates = params[4][1].split("/")[0].split("-")
		times = params[4][1].split("/")[1].split(":")
		start = datetime.datetime(int(dates[2]),int(dates[1]),int(dates[0]),int(times[0]),int(times[1]),int(times[2]));
		dates = params[5][1].split("/")[0].split("-")
		times = params[5][1].split("/")[1].split(":")
		end = datetime.datetime(int(dates[2]),int(dates[1]),int(dates[0]),int(times[0]),int(times[1]),int(times[2]));
		start = time.mktime(start.timetuple())-36000
		end = time.mktime(end.timetuple())-36000
		self.start = start
		self.end = end
		print start
		print end
		self.m_time = self.m.get_array_time(start, end,self.m.get_array())
		if(graph_type == "occupancy"):
			self.p.new(self.fig)
			try:
				c = self.a.room_occupency(self.m, 0,start,end)
				self.p.add_line(c[0], c[1], 'b')
				self.p.show_legend()
			except:
				a = 1
			self.p.show()
		if(graph_type == "average"):
			self.p.new(self.fig)
			self.average(params)
			self.p.show_legend()
			self.p.show()
		if(graph_type == "weighted"):
			self.p.new(self.fig)
			self.weighted_vote(params)
			self.p.show_legend()
			self.p.show()
		if(graph_type == "joined"):
			self.p.new(self.fig)
			self.average(params)
			self.weighted_vote(params)
			self.p.show_legend()
			self.p.show()
		if(graph_type == "heat"):
			self.heatmap(params)
		self.fig = self.fig+1
Exemple #4
0
def main():
    my_data = acquisition()
    my_data = cleaning(my_data)
    my_data = analysis(my_data)
Exemple #5
0
from mongo import *
from truth import *
from analysis import *
from plotting import *
import pylab

t = truth('test.txt')
m = mongo('10.0.0.1', 27017,'rktest','sensors')
a = analysis()
p = plotting()

master = m.get_array()
#print m.get_nodes()
end_time = a.get_time_bounds(master)[1]
start_time = end_time-800
master = m.get_array_time(start_time,end_time,master)
#print m.get_array_time(0,end_time,master)
#print m.get_sensortype(master)
#print m.get_sensortype_activation('VC',master)
#print m.get_sensortype_activation('ACCL',master) 
#print t.get_table()
tmaster = t.parse_raw(master)
i = 0
for d in m.get_nodes():
	print d
	col = a.collective_average(m,t,{d:master[d]})
	wv = a.weighted_vote(m,t,{d:master[d]})
	#print col
	#print wv
	pos = []
	neg = []
    for f in mf_names:
        df = pd.read_csv(f + ".csv")
        df['TG'] = df['FT'].map(total_goals_scored)  # Total goals.
        df['GD'] = df['FT'].map(goal_difference)  # Goal difference.

        samples.append(df)

    samples_min_length = min([len(s) for s in samples])  # We find the minimum length among all samples.
    samples = [s.head(samples_min_length) for s in samples]  # We truncate all samples.
    samples = [{'title': pair[0], 'df': pair[1]} for pair in zip(samples_names, samples)]

    # Now we'll plot some histograms.
    for i in range(len(samples)):
        plot_histogram(samples[i]['df'], mf_names[i] + ".png")

    # Finally, run a proper analysis.
    statistics = descriptive_statistics(samples)
    anova_table, tukey_hsd_table = analysis(samples)

    # Print the results
    if store_results:
        with open(file, 'w') as f:
            f.write(statistics)
            f.write(anova_table)
            f.write(tukey_hsd_table)
    else:
        print statistics
        print anova_table
        print tukey_hsd_table

while True:
# keep reading year from user input until input == 'finish'
	try:
		year_input = input("Enter year or 'finish' to exit:")
		if year_input == 'finish':
			break
		else:
			try:
				year = int(year_input)
				if year < 1800 or year > 2012:
					raise InvalidInput
				income_distribution(year)
			except InvalidInput:
				print('Value out of range!')
				continue
			except ValueError:
				print('Invalid Input!')
	except KeyboardInterrupt:
		print('User Interrupt')
	except EOFError:
		print('Input Error')


for year in range(2007,2013):
    merged = merge_by_year(year)
    analysis_year = analysis(merged, year)
    analysis_year.histogram_by_region()
    analysis_year.boxplot_by_region()


from config import *
from utils import *
from pull_csk_data import *
from pull_utd_data import *
from combine_files import *
from clean_csvs import *
from unify import *
from get_result import *
from played_first import *
from analysis import *

pull_csk_data()
pull_utd_data()
combine_files()
clean_csvs()
unify_data()
get_match_result()
set_played_first()
analysis()
income = income.drop(['gdp pc test'],axis=0)
print('The head of income dataset:')
print(income.head())

'''
The program asks the user to enter a year, then display the distribution of income per person for that year
until 'finish' is typed.
Then, use the class analysis to generate graphs for the years 2007-2012
'''
while True:
    try:
        year_input = input('Enter a year(type finish to quit):')
        if year_input.lower() == 'finish':
            for year in range(2007,2013):
                merged_df = merge_by_year(year,income,countries)
                plot = analysis(merged_df,year)
                plot.histogram()
                plot.boxplot()
            sys.exit()
        if int(year_input) not in income.index:
            raise InvalidInput
        else:
            year = int(year_input)
            distr_income(income, year)
    except KeyboardInterrupt:
        sys.exit(0)
    except EOFError:
        sys.exit(0)
    
    
    
Exemple #10
0
    def selection(self):
        """ KC - selection according to selection criteria """
        self.best_model = self.blank_model

        # #KC# loop with arbitrary number
        for step in xrange(self.N_models):
            self.actions = []
            # #CG# random choice of restraints which will be done
            for donor in self.list_donor:
                donor_idx = self.list_donor.index(donor)
                acceptor_idx = self.list_acceptor.index(acceptor)
                acceptors = [
                    acceptor for acceptor in self.list_acceptor
                    if self.contact_matrix_probas[donor_idx][acceptor_idx] > 0
                ]
                for acceptor in rd.sample(acceptors, len(acceptors) / 2):
                    random_number = int(rd.random() * 100)
                    if random_number >= 0 and random_number < \
                       self.contact_matrix_probas[donor_idx][acceptor_idx]:
                        self.actions.append([
                            "restraint", "upperdistance", donor, acceptor, 6, 3
                        ])
            self.actions.append(["modelisation", "selection" + str(step + 1)])
            self.set_actions()
            self.modelisation_run("selection")
            for model in self.modeling.models:
                model.interactions.Hbonds_dist_model(self.list_donor, step + 1)

        if self.best_model != self.blank_model:
            print "\n Best model :"
            print "filename : " + str(self.best_model.filename)
            print "GA341 score : " + str(self.best_model.GA341[0])
            print "molpdf score : " + str(self.best_model.molpdf)
            print "DOPE score : " + str(self.best_model.DOPE)
            print self.selection_criteria + " : " + str(
                self.best_selection_criteria)
            for restraint in self.best_modelisation.restraints:
                if [restraint[1], restraint[2]] in \
                   self.best_model.interactions.get_bonds(self.opt):
                    donor_idx = self.list_donor.index(restraint[1])
                    acceptor_idx = self.list_acceptor.index(restraint[2])
                    self.contact_matrix_best_model[donor_idx][acceptor_idx] = 1
            save_matrix(self.contact_matrix_best_model,
                        "contact_matrix_best_model", self.list_acceptor,
                        self.list_donor)
            analysis(None, None, None, None, self.query_structure_model,
                     self.list_donor, self.list_acceptor, None, None, None,
                     self.opt, None, None, None, None, None, None, None, True,
                     self.best_model, "final")
            self.best_model.structure_alignement(self.query_structure_model)
            self.best_model.interactions.network_distribution("Hbond")
            self.best_model.interactions.accessibility_VS_Hbond()
        else:
            print "No better model than blank found !"
            print "filename : " + str(self.blank_model.filename)
            print "GA341 score : " + str(self.blank_model.GA341[0])
            print "molpdf score : " + str(self.blank_model.molpdf)
            print "DOPE score : " + str(self.blank_model.DOPE)
            print self.selection_criteria + " : " + \
                str(-(self.best_selection_criteria))
            analysis(None, None, None, None, self.query_structure_model,
                     self.list_donor, self.list_acceptor, None, None, None,
                     self.opt, None, None, None, None, None, None, None, True,
                     self.blank_model, "final")
        os.mkdir("selection")
        os.system("mv *matrix* sel* Hbonds_dist* selection/. > /dev/null 2>&1")
Exemple #11
0
    otpion1=input("Do you want to see the current functionality? Yes or No ")
    if(otpion1.lower()=="yes"):
        functionality()
    while(1):
        while(1):
            print()
            print("1 for Voice Input")
            print("2 for Text Input")
            print("3 to create own functionality")
            option=input("Enter Option: ")
            if(option=="1"):
                command=speech_recog().lower()
                break
            elif(option=="3"):
                define_usr_fun()
                continue
            else:
                command=input("What do you want to do? ")
                break
        with open('usr_triggers.json', 'r') as fp:
            usr_triggers= json.load(fp)
        if(command in usr_triggers):
            run_usr_fun(command)
            continue
        command,command_sentence=run_classifier(command)
        analysis(command,command_sentence)
        temp_var_1=input("Do you want to continue? yes or no").lower()
        if(temp_var_1=="no"):
            break

Exemple #12
0
from analysis import *
import optparse
parser = optparse.OptionParser()
parser.add_option('-i', '--inFileName',           dest="inFileName",         default="", help="")
parser.add_option('-o', '--outFileName',          dest="outFileName",        default="", help="")
parser.add_option('-n', '--nEvents',              dest="nEvents",            default=None, help="Number of events to process")
parser.add_option('-d', '--debug',                dest="debug",    action="store_true", default=False, help="Debug")
o, a = parser.parse_args()


f=ROOT.TFile(o.inFileName)
tree=f.Get("LHEF")

a = analysis(tree, o.outFileName, o.debug)
a.lumi = 24.3e3
a.kFactor = 1
if "ZH" in o.inFileName:
    a.kFactor = 1.5
if "ZZ" in o.inFileName:
    a.kFactor = 1.6

if o.nEvents: a.eventLoop(range(int(o.nEvents))) #loop over a subset of events
else:         a.eventLoop()                      #loop over all events in o.inFileName

f.Close()
a.Write()
Exemple #13
0
    "/Users/zoem/Documents/ds1007/assignment10/assignment9/indicator_gapminder_gdp_per_capita_ppp.xlsx"
)
income = income.transpose()

print("head: \n")
print(income.head(5))

while True:
    try:
        input_year = input(
            "Please enter a year to begin, enter finish if you want to quit: ")

        if input_year.lower() == 'finish':
            for year in range(2007, 2013):
                merged_df = merge_by_year(year, countries, income)
                anal = analysis(merged_df, year)
                anal.hist_plot()
                anal.box_plot()
            sys.exit()

        if int(input_year) not in income.index:
            raise ValueError(
                "Invalid input. Please enter an integer from 1800 to 2012")

        else:
            year = int(input_year)
            income_distribution(income, year)

    except KeyboardInterrupt:
        sys.exit(0)
    except EOFError:
Exemple #14
0
income = pd.read_excel(
    'indicator gapminder gdp_per_capita_ppp.xlsx').transpose()
income.columns = [income.ix[0]]
income = income.drop(['gdp pc test'], axis=0)
print('The head of income dataset:')
print(income.head())
'''
The program asks the user to enter a year, then display the distribution of income per person for that year
until 'finish' is typed.
Then, use the class analysis to generate graphs for the years 2007-2012
'''
while True:
    try:
        year_input = input('Enter a year(type finish to quit):')
        if year_input.lower() == 'finish':
            for year in range(2007, 2013):
                merged_df = merge_by_year(year, income, countries)
                plot = analysis(merged_df, year)
                plot.histogram()
                plot.boxplot()
            sys.exit()
        if int(year_input) not in income.index:
            raise InvalidInput
        else:
            year = int(year_input)
            distr_income(income, year)
    except KeyboardInterrupt:
        sys.exit(0)
    except EOFError:
        sys.exit(0)
 def test_vm_type(self):
     analysis_test = analysis()
     limits = analysis_test.get_limits(self.service, "max_strategy")
     vm_type_t = analysis_test.get_vm_type([self.service], self.vm_types)
     self.assertTrue(vm_type_t.limits["cpu"] == 2
                     and vm_type_t.limits["mem"] == 16)
 def test_calculate_limits(self):
     analysis_test = analysis()
     limits = analysis_test.get_limits(self.service, "max_strategy")
     self.assertTrue(limits["cpu"] == 2)
     self.assertTrue(limits["mem"] == 8)
Exemple #17
0
per person in relation to geographical region for that year. 
"""

while True:
    try:
        year_input = input(
            "Enter a year between 1800 and 2012 to display graphs: ")
        if year_input == "finish":
            break
        else:
            try:
                year = int(year_input)
                if year < 1800 or year > 2012:
                    raise InvalidInput
                income_dist(year)
            except InvalidInput:
                print("Value is not between 1800 - 2012.")
                continue
            except ValueError:
                print('Invalid Input')
    except EOFError:
        print('Input Error')
    except KeyboardInterrupt:
        print('Keyboard Interrupt')

for y in range(2007, 2013):
    merged = merge_by_year(y)
    analysis_by_year = analysis(merged, y)
    analysis_by_year.histogram_region()
    analysis_by_year.boxplot_region()
Exemple #18
0
from data import *
from exceptions import *

while True:
    # keep reading year from user input until input == 'finish'
    try:
        year_input = input("Enter year or 'finish' to exit:")
        if year_input == 'finish':
            break
        else:
            try:
                year = int(year_input)
                if year < 1800 or year > 2012:
                    raise InvalidInput
                income_distribution(year)
            except InvalidInput:
                print('Value out of range!')
                continue
            except ValueError:
                print('Invalid Input!')
    except KeyboardInterrupt:
        print('User Interrupt')
    except EOFError:
        print('Input Error')

for year in range(2007, 2013):
    merged = merge_by_year(year)
    analysis_year = analysis(merged, year)
    analysis_year.histogram_by_region()
    analysis_year.boxplot_by_region()
Exemple #19
0
    def optimization(self):
        """ KC - optimization of number of core hydrogen bonds """

        # #KC# list of donors/acceptors with parametres.py file
        if self.opt == "H_bonds":
            self.list_donor = [(donor.get_full_id()[4][0]) + ":" +
                               str(donor.get_full_id()[3][1]) + ":" +
                               str(donor.get_full_id()[2])
                               for donor in self.blank_model.get_donors()]
            self.list_acceptor = [
                (acceptor.get_full_id()[4][0] + ":" +
                 str(acceptor.get_full_id()[3][1]) + ":" +
                 str(acceptor.get_full_id()[2]))
                for acceptor in self.blank_model.get_acceptors()
            ]
        elif self.opt == "ionic_bonds":
            self.list_donor = [
                (donor.get_full_id()[4][0]) + ":" +
                str(donor.get_full_id()[3][1]) + ":" +
                str(donor.get_full_id()[2])
                for donor in self.blank_model.get_ionic_donors()
                if donor.get_full_id()[4][0] != "N"
            ]
            self.list_acceptor = [
                (acceptor.get_full_id()[4][0] + ":" +
                 str(acceptor.get_full_id()[3][1]) + ":" +
                 str(acceptor.get_full_id()[2]))
                for acceptor in self.blank_model.get_ionic_acceptors()
                if acceptor.get_full_id()[4][0] != "O"
            ]

        # #KC# matrix initialization
        self.contact_matrix_probas = [[
            self.p_min for i in xrange(len(self.list_acceptor))
        ] for j in xrange(len(self.list_donor))]
        self.contact_matrix_blank = [[
            0 for i in xrange(len(self.list_acceptor))
        ] for j in xrange(len(self.list_donor))]
        self.contact_matrix_query = [[
            0 for i in xrange(len(self.list_acceptor))
        ] for j in xrange(len(self.list_donor))]
        self.contact_matrix_best_model = [[
            0 for i in xrange(len(self.list_acceptor))
        ] for j in xrange(len(self.list_donor))]

        # #KC# negative weight applied in contact matrix
        self.zones_constraints()

        for (atom1,
             atom2) in self.blank_model.interactions.get_bonds(self.opt):
            atom1_idx = self.list_donor.index(atom1)
            atom2_idx = self.list_acceptor.index(atom2)
            self.contact_matrix_blank[atom1_idx][atom2_idx] = 1
            save_matrix(self.contact_matrix_blank, "contact_matrix_blank",
                        self.list_acceptor, self.list_donor)

        # self.num_query, self.num_model = get_aligned_residues('structure_sequence.ali')
        # dictionary = dict(zip(self.num_query, self.num_model))
        # for (atom1, atom2) in self.query_structure_model.interactions.get_bonds(self.opt):
        #     atom1 = atom1.split(":")
        #     atom2 = atom2.split(":")
        #     chain1 = [res.get_full_id()[2]
        #               for res in self.blank_model.res if res.get_full_id()[3][1] ==
        #               dictionary[int(atom1[1])]]
        #     chain2 = [res.get_full_id()[2]
        #               for res in self.blank_model.res if res.get_full_id()[3][1] ==
        #               dictionary[int(atom2[1])]]
        #     atom1 = atom1[0] + ":" + str(dictionary[int(atom1[1])]) + ":" + chain1[0]
        #     atom2 = atom2[0] + ":" + str(dictionary[int(atom2[1])]) + ":" + str(chain2[0])
        #     self.contact_matrix_query[self.list_donor.index(atom1)][self.list_acceptor.index(atom2)] = 1

        save_matrix(self.contact_matrix_query, "contact_matrix_query",
                    self.list_acceptor, self.list_donor)

        self.all_models = []
        self.list_tanimoto = []
        self.sum_probas = []
        self.sum_Hbonds = []
        self.sum_restraints = []
        self.blank_Hbonds_number = \
            len(self.blank_model.interactions.get_bonds(self.opt))
        for step in xrange(3):
            self.actions = []
            for donor in rd.sample(self.list_donor, len(self.list_donor) / 3):
                acceptors = []
                for acceptor in self.list_acceptor:
                    donor_idx = self.list_donor.index(donor)
                    acceptor_idx = self.list_acceptor.index(acceptor)
                    if self.contact_matrix_probas[donor_idx][acceptor_idx] > 0:
                        acceptors.append(acceptor)
                for acceptor in rd.sample(acceptors, len(acceptors) / 2):
                    donor_idx = self.list_donor.index(donor)
                    acceptor_idx = self.list_acceptor.index(acceptor)
                    random_number = int(rd.random() * 100)
                    if random_number >= 0 and random_number < \
                       self.contact_matrix_probas[donor_idx][acceptor_idx]:
                        self.actions.append([
                            "restraint", "upperdistance", donor, acceptor, 6, 3
                        ])
            self.actions.append(
                ["modelisation", "optimization" + str(step + 1)])
            self.set_actions()
            self.modelisation_run("optimization")
            if (step + 1) in [1, 50, 100, 200, 300, 500]:
                for model in self.modeling.models:
                    model.interactions.Hbonds_dist_model(
                        self.list_donor, step + 1)
                if self.query_structure_model is not None:
                    for model in self.modeling.models:
                        analysis(None, None, None, None,
                                 self.query_structure_model, self.list_donor,
                                 self.list_acceptor, None, None, None,
                                 self.opt, None, None, None, None, None, None,
                                 None, True, model, step + 1)
        save_matrix(self.contact_matrix_probas, "contact_matrix_probas",
                    self.list_acceptor, self.list_donor)
        # print self.contact_matrix_probas

        # #KC# models analysis
        analysis(self.all_models, self.n_models, self.blank_model,
                 self.template_model, self.query_structure_model,
                 self.list_donor, self.list_acceptor,
                 self.contact_matrix_probas, self.contact_matrix_best_model,
                 self.contact_matrix_query, self.opt, self.p_min, self.p_max,
                 self.p_step, self.list_tanimoto, self.sum_probas,
                 self.sum_Hbonds, self.sum_restraints, False, None, None)

        os.mkdir("optimization")
        os.system("mv *matrix* opt* models* probas_dist*" +
                  "Hbonds_dist* optimization/. > /dev/null 2>&1")
Exemple #20
0
    "/Users/zoem/Documents/ds1007/assignment10/assignment9/indicator_gapminder_gdp_per_capita_ppp.xlsx"
)
income = income.transpose()

print("head: \n")
print(income.head(5))


while True:
    try:
        input_year = input("Please enter a year to begin, enter finish if you want to quit: ")

        if input_year.lower() == "finish":
            for year in range(2007, 2013):
                merged_df = merge_by_year(year, countries, income)
                anal = analysis(merged_df, year)
                anal.hist_plot()
                anal.box_plot()
            sys.exit()

        if int(input_year) not in income.index:
            raise ValueError("Invalid input. Please enter an integer from 1800 to 2012")

        else:
            year = int(input_year)
            income_distribution(income, year)

    except KeyboardInterrupt:
        sys.exit(0)
    except EOFError:
        sys.exit(0)