def __init__(self, inputFileName): # variables used in this class self.multiSum = 0 # multitargetting sum taken from the previous version of make_graphs self.multiCount = 0 # multitargetting count taken from the previous version of make_graphs self.seqTrans = SeqTranslate( ) # SeqTranslate variable. for decrompressing the data self.chromesomeList = list( ) # list of a list for the chromesomes. As it currently stands, this variable is used in both read_chromesomes and in read_targets self.karystatsList = list( ) # list of (ints) of the karyStats (whatever those are) to be used for the get_chrom_length function self.genome = "" # genome name self.misc = "" # anything from the misc line self.repeats = { } # dictionary of the number of repeats. See the read_repeats function for more info self.seeds = { } # dictionary of which chromesomes are repeats. See the read_repeats function for more info self.dec_tup_data = {} self.chromesomesSelectedList = list() # data for population analysis # dict: # key = the seed # value = tuple (org name, chom #, location, sequence, pam, score, strand, endo) self.popData = {} # file path variable self.fileName = inputFileName
def __init__(self, casper_seq_file, output_file_path, ofa): self.csffile = casper_seq_file self.ST = SeqTranslate() self.allTargets = {} self.location = tuple() self.output = output_file_path self.off_target_all = ofa
def __init__(self): # qt stuff super(genLibrary, self).__init__() uic.loadUi('library_prompt.ui', self) self.setWindowTitle('Generate Library') self.setWindowIcon(Qt.QIcon('cas9image.png')) # button connections self.cancel_button.clicked.connect(self.cancel_function) self.BrowseButton.clicked.connect(self.browse_function) self.submit_button.clicked.connect(self.submit_data) self.progressBar.setValue(0) # variables self.anno_data = dict() self.cspr_file = '' self.parser = CSPRparser('') self.kegg_nonKegg = '' self.gen_lib_dict = dict() self.S = SeqTranslate() self.cspr_data = dict() self.Output = dict() self.off_tol = .05 self.off_max_misMatch = 4 self.off_target_running = False # set the numbers for the num genes combo box item for i in range(10): self.numGenescomboBox.addItem(str(i + 1)) # set the numbers for the minOn combo box for i in range(19, 70): self.minON_comboBox.addItem(str(i + 1))
def __init__(self, parent=None): super(Multitargeting, self).__init__() uic.loadUi('multitargetingwindow.ui', self) self.setWindowIcon(QtGui.QIcon("cas9image.png")) # Storage containers for the repeats and seed sequences self.sq = SeqTranslate() # SeqTranslate object used in class # Initializes the three graphs self.chart_view_chro_bar = QChartView() self.chart_view_repeat_bar = QChartView() self.chart_view_repeat_line = QChartView() self.data = "" self.shortHand = "" self.chromo_length = list() # Listeners for changing the seed sequence or the .cspr file self.max_chromo.currentIndexChanged.connect(self.fill_seed_id_chrom) self.min_chromo.currentIndexChanged.connect(self.fill_seed_id_chrom) self.chromo_seed.currentIndexChanged.connect(self.chro_bar_data) self.Analyze_Button.clicked.connect(self.make_graphs) #go back to main button self.back_button.clicked.connect(self.go_back) #Tool Bar options self.actionCASPER.triggered.connect(self.changeto_main) # Statistics storage variables self.max_repeats = 1 self.average = 0 self.median = 0 self.mode = 0 self.average_unique = 0 self.average_rep = 0 self.bar_coords = [] self.seed_id_seq_pair = {} self.positions = [] #parser object self.parser = CSPRparser("") self.ready_chromo_min_max = True self.ready_chromo_make_graph = True self.directory = 'Cspr files' self.info_path = os.getcwd() ################################## self.scene = QtWidgets.QGraphicsScene() self.graphicsView.setScene(self.scene) self.scene2 = QtWidgets.QGraphicsScene() self.graphicsView_2.setScene(self.scene2) self.graphicsView.viewport().installEventFilter(self)
def decode_targets(self): f = open(self.filename) # make sure to recognize chromosome number data = f.readline()[:-1] while data != "REPEATS": data = f.readline()[:-1] # parse location and sequence midpoint = data.find(',') location = data[:midpoint] sequence = data[midpoint + 1:] # decompress the location and sequence information s = SeqTranslate() location = s.decompress64(location, toseq=False) sequence = s.decompress64(sequence, toseq=True) # add location to storage vector self.targets.append((location, sequence))
def __init__(self, info_path): super(NewGenome, self).__init__() uic.loadUi('NewGenome.ui', self) self.setWindowTitle('New Genome') self.k = KEGG() self.info_path = info_path #---Button Modifications---# self.setWindowIcon(Qt.QIcon("cas9image.png")) self.whatsthisButton.clicked.connect(self.whatsthisclicked) self.KeggSearchButton.clicked.connect(self.updatekegglist) self.resetButton.clicked.connect(self.reset) self.submitButton.clicked.connect(self.submit) self.browseForFile.clicked.connect(self.selectFasta) self.NCBI_File_Search.clicked.connect(self.prep_ncbi_search) self.JobsQueueBox.setReadOnly(True) self.output_browser.setText("Waiting for program initiation...") self.CompletedJobs.setText(" ") self.contButton.clicked.connect(self.continue_to_main) self.comboBoxEndo.currentIndexChanged.connect(self.endo_settings) self.runButton.clicked.connect(self.run_jobs) self.clearButton.clicked.connect(self.clear_job_queue) self.viewStatButton.setEnabled(False) self.JobsQueue = [] # holds Job classes. self.Endos = dict() self.file = "" self.process = QtCore.QProcess() self.process.setProcessChannelMode(QtCore.QProcess.MergedChannels) self.process.finished.connect(self.upon_process_finishing) self.seqTrans = SeqTranslate() self.first = False #show functionalities on window self.fillEndo() #self.show() self.num_chromo_next = False
def __init__(self, output_path, base_org_path, base_org, endo, other_genomes, csize): # initialize SeqTranslate object self.ST = SeqTranslate() self.output_path = output_path # my_orgs contains just the self.organisms = other_genomes self.organisms.append(base_org) self.organisms = sorted(self.organisms) self.db_path = base_org_path # This sets the size of the subsets. NOTE: DO NOT SET THIS TO A LARGE NUMBER IF THERE ARE A LOT OF ORGANISMS self.combo_size = csize # Dictionary of dictionaries. Key1: generic total sequence Key2: org Value: position self.searchableseqs = {} # Container that stores all the sequences seen the combination of organisms defined by the key # An example key would be (sce, yli) for the shared sequences between S.cerevisiae and Y.lipolytica self.buckets = {} # Intitialize the self.buckets container to contain the tuple of every organism subset for i in range(2, csize+1): for subset in itertools.combinations(self.organisms, i): self.buckets[subset] = [] print(subset) self.endo = endo # The object that is iterated over to decompress the output into readable form self.compressed_output = {} # Generates the sequence lists for org in self.organisms: print(org) self.make_lists(org) # Runs the comparison self.create_comparison() self.write_to_file()
def get_instances(self): ST = SeqTranslate() os.chdir(path) f = open(self.file_name, 'r') while True: x = f.readline() if x == 'REPEATS\n': print("reached repeat sequences") break while True: t = f.readline() if t == 'END_OF_FILE': print("reached end of repeat sequences") break ukey = t[:-1] # takes away the "\n" in the string key = ST.decompress64(ukey, slength=20, toseq=True) key = ST.fill_As(key, 16) self.BAD_instances[key] = list() # Add sequences and locations to the list v = f.readline().split('\t')[:-1] for item in v: loctup = item.split(',') chrom = loctup[0] location = ST.decompress64(loctup[1]) seq = ST.decompress64(loctup[2][1:], slength=20, toseq=True) seq = ST.fill_As( seq, 4 ) # when A's get lost in the compression this fills them back in mytup = (chrom, location, seq) self.BAD_instances[key].append(mytup) f.close() print("currently sorting") for key in self.BAD_instances: size = len(self.BAD_instances[key]) newtuple = (key, self.BAD_instances[key], size ) # sequence, location, size self.sorted_instances.append(newtuple)
def __init__(self, threshold, endo, base_org, csf_file, other_orgs, casperofflist, output_path): self.ST = SeqTranslate() self.rSequences = [] self.get_rseqs(casperofflist) self.mypath = csf_file[:csf_file.find(base_org)] self.ref_genomes = [base_org] self.ref_genomes += other_orgs self.endo = endo self.threshold = threshold self.dSequence = str( ) # global to class so that all scoring functions can use it # This is for autofilling the HsuMatrix self.matrixKeys = [ "GT", "AC", "GG", "TG", "TT", "CA", "CT", "GA", "AA", "AG", "TC", "CC" ] self.matrix = {} self.fill_matrix() # This is where the data is stored before it is written self.output_data = dict() for myseq in self.rSequences: self.output_data[myseq[0]] = list() # BEGIN RUNNING THROUGH SEQUENCES for sequence in self.rSequences: print(sequence) for genome in self.ref_genomes: f = open(self.mypath + genome + self.endo + ".cspr", 'r') while True: line = f.readline() if line.find("CHROMOSOME") != -1: curchrom = line[line.find("#") + 1:-1] print("Finished checking " + curchrom) else: if line[0:-1] == "REPEATS": break # Checks for a signifcant number of mismatches: #locseq = line[:-1].split(",") if self.critical_similarity( sequence[0], self.ST.decompress_csf_tuple(line)[1]): # This is where the real fun begins: off target analysis print('found a similarity') seqscore = self.get_scores( sequence[1], self.ST.decompress_csf_tuple(line)[1]) if seqscore > self.threshold: self.output_data[sequence[0]].append( (str(curchrom), self.ST.decompress_csf_tuple(line[:-1]), int(seqscore * 100), genome)) # END SEQUENCES RUN # Output the data acquired: out = open( output_path + "off_results" + str(datetime.datetime.now().time()) + '.txt', 'w') out.write( "Off-target sequences identified. Scores are between O and 1. A higher value indicates greater" "probability of off-target activity at that location.\n") for sequence in self.output_data: out.write(sequence + "\n") for off_target in self.output_data[sequence]: outloc = off_target[0] + "," + str( off_target[1][0]) + "," + off_target[1][1] out.write(off_target[3] + "," + outloc + "\t" + str(off_target[2] / 100) + '\n') out.close()
def __init__(self, parent=None): super(Multitargeting, self).__init__() uic.loadUi(GlobalSettings.appdir + 'multitargetingwindow.ui', self) self.setWindowIcon(QtGui.QIcon(GlobalSettings.appdir + "cas9image.png")) self.sq = SeqTranslate() # SeqTranslate object used in class # Initializes the three graphs self.chart_view_chro_bar = QChartView() self.chart_view_repeat_bar = QChartView() self.chart_view_repeat_line = QChartView() self.data = "" self.shortHand = "" self.chromo_length = list() # Listeners for changing the seed sequence or the .cspr file self.chromo_seed.currentIndexChanged.connect(self.seed_chromo_changed) self.update_min_max.clicked.connect(self.update) self.Analyze_Button.clicked.connect(self.make_graphs) # go back to main button self.back_button.clicked.connect(self.go_back) # Tool Bar options self.actionCASPER.triggered.connect(self.changeto_main) # Statistics storage variables self.max_repeats = 1 self.average = 0 self.median = 0 self.mode = 0 self.average_unique = 0 self.average_rep = 0 self.bar_coords = [] self.seed_id_seq_pair = {} # parser object self.parser = CSPRparser("") self.ready_chromo_min_max = True self.ready_chromo_make_graph = True self.directory = 'Cspr files' self.info_path = os.getcwd() ################################## self.scene = QtWidgets.QGraphicsScene() self.graphicsView.setScene(self.scene) self.scene2 = QtWidgets.QGraphicsScene() self.graphicsView_2.setScene(self.scene2) self.graphicsView.viewport().installEventFilter(self) self.loading_window = loading_window() screen = QtGui.QGuiApplication.screenAt(QtGui.QCursor().pos()) self.mwfg = self.frameGeometry() ##Center window self.cp = QtWidgets.QDesktopWidget().availableGeometry().center( ) ##Center window self.mwfg.moveCenter(self.cp) ##Center window self.move(self.mwfg.topLeft()) ##Center window self.hide()
def __init__(self, info_path): super(NewGenome, self).__init__() uic.loadUi(GlobalSettings.appdir + 'NewGenome.ui', self) self.setWindowTitle('New Genome') self.setWindowTitle('New Genome') self.info_path = info_path #---Style Modifications---# groupbox_style = """ QGroupBox:title{subcontrol-origin: margin; left: 10px; padding: 0 5px 0 5px;} QGroupBox#Step1{border: 2px solid rgb(111,181,110); border-radius: 9px; font: 15pt "Arial"; font: bold; margin-top: 10px;}""" self.Step1.setStyleSheet(groupbox_style) self.Step2.setStyleSheet(groupbox_style.replace("Step1", "Step2")) self.Step3.setStyleSheet(groupbox_style.replace("Step1", "Step3")) #---Button Modifications---# self.setWindowIcon(Qt.QIcon(GlobalSettings.appdir + "cas9image.png")) self.resetButton.clicked.connect(self.reset) self.submitButton.clicked.connect(self.submit) self.browseForFile.clicked.connect(self.selectFasta) self.remove_job.clicked.connect(self.remove_from_queue) self.output_browser.setText("Waiting for program initiation...") self.contButton.clicked.connect(self.continue_to_main) self.comboBoxEndo.currentIndexChanged.connect(self.endo_settings) self.runButton.clicked.connect(self.run_jobs_wrapper) self.clearButton.clicked.connect(self.clear_job_queue) self.JobsQueue = [] # holds Job classes. self.Endos = dict() self.file = "" self.process = QtCore.QProcess() self.process.setProcessChannelMode(QtCore.QProcess.MergedChannels) self.process.finished.connect(self.upon_process_finishing) self.seqTrans = SeqTranslate() self.exit = False self.first = False #show functionalities on window self.fillEndo() #self.show() self.num_chromo_next = False #Jobs Table #self.job_Table.setColumnCount(3) self.job_Table.setShowGrid(False) #self.job_Table.setHorizontalHeaderLabels(["Job Queue","Job in Progress", "Completed Jobs"]) self.job_Table.horizontalHeader().setSectionsClickable(True) #self.job_Table.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents) #self.job_Table.horizontalHeader().setSectionResizeMode(2, QHeaderView.Stretch) self.job_Table.setSelectionBehavior( QtWidgets.QAbstractItemView.SelectRows) self.job_Table.setEditTriggers( QtWidgets.QAbstractItemView.NoEditTriggers) self.job_Table.setSelectionMode( QtWidgets.QAbstractItemView.MultiSelection) self.job_Table.setSizeAdjustPolicy( QtWidgets.QAbstractScrollArea.AdjustToContents) self.fin_index = 0 self.mwfg = self.frameGeometry() ##Center window self.cp = QtWidgets.QDesktopWidget().availableGeometry().center( ) ##Center window self.total_chrom_count = 0 self.perc_increase = 0 self.progress = 0 #toolbar button actions self.visit_repo.triggered.connect(self.visit_repo_func) self.go_ncbi.triggered.connect(self.open_ncbi_web_page) self.comboBoxEndo.currentIndexChanged.connect(self.changeEndos) #ncbi tool self.NCBI_File_Search.clicked.connect(self.open_ncbi_tool) self.seed_length.setEnabled(False) self.five_length.setEnabled(False) self.three_length.setEnabled(False) self.repeats_box.setEnabled(False) #user prompt class self.goToPrompt = goToPrompt() self.goToPrompt.goToMain.clicked.connect(self.continue_to_main) self.goToPrompt.goToMT.clicked.connect(self.continue_to_MT) self.goToPrompt.goToPop.clicked.connect(self.continue_to_pop)