def export(self): """Export selected text to new text window.""" seq = self.get_selection_or_sequence() if not seq: return np = NotePad() tid = np.text_id() tid.insert('end', seq)
def gcframe(self, direction='both'): seq = self.get_selection_or_sequence() if not seq: return np = NotePad() tid = np.text_id() tid.insert('end', self.translator.gcframe(seq, self.current_codon_table_id, direction))
def translate(self): seq = self.get_selection_or_sequence() frame = self.frame_int.get() if not seq: return np = NotePad() tid = np.text_id() tid.insert('end', self.translator.frame_nice(seq, frame, self.current_codon_table_id))
def extract(self): seq = self.get_selection_or_sequence() frame = self.frame_int.get() if not seq: return aa_seq = self.translator.frame(seq, frame, self.current_codon_table_id) aa_seq = re.sub('(.{50})', '\\1\n', str(aa_seq)) np = NotePad() tid = np.text_id() tid.insert('end', '>frame%d\n%s' % (frame, aa_seq))
def gcframe(self, direction='both'): seq = self.get_selection_or_sequence() if not seq: return np = NotePad() tid = np.text_id() tid.insert( 'end', self.translator.gcframe(seq, self.current_codon_table_id, direction))
def gcframe(self, direction="both"): """Run pretty print multiple frame translations.""" seq = self.get_selection_or_sequence() if not seq: return np = NotePad() tid = np.text_id() tid.insert( "end", self.translator.gcframe(seq, self.current_codon_table_id, direction) )
def translate(self): seq = self.get_selection_or_sequence() frame = self.frame_int.get() if not seq: return np = NotePad() tid = np.text_id() tid.insert( 'end', self.translator.frame_nice(seq, frame, self.current_codon_table_id))
def extract(self): """Make single frame translation and display aa sequence as fasta.""" seq = self.get_selection_or_sequence() frame = self.frame_int.get() if not seq: return aa_seq = self.translator.frame(seq, frame, self.current_codon_table_id) aa_seq = re.sub("(.{50})", "\\1\n", str(aa_seq)) np = NotePad() tid = np.text_id() tid.insert("end", ">frame%d\n%s" % (frame, aa_seq))
def translate(self): """Run pretty print single frame translation.""" seq = self.get_selection_or_sequence() frame = self.frame_int.get() if not seq: return np = NotePad() tid = np.text_id() tid.insert( "end", self.translator.frame_nice(seq, frame, self.current_codon_table_id) )
def Run(self): self.notepad = NotePad() tid = self.notepad.tid self.notepad.menubar.configure(bg='red') self.toplevel.destroy() blastbg = xbb_blastbg.BlastDisplayer(self.command, tid) blastbg.RunCommand() # indicate the finished run by changing color try: self.notepad.menubar.configure(bg='green4') except: pass
def Run(self): self.notepad = NotePad() tid = self.notepad.tid self.toplevel.destroy() blastbg = xbb_blastbg.BlastDisplayer(self.command_data, tid) blastbg.RunCommand()
def Run(self): """Open new notepad and initialize running BLAST.""" self.notepad = NotePad() tid = self.notepad.tid self.toplevel.destroy() blastbg = xbb_blastbg.BlastDisplayer(self.command_data, tid) blastbg.RunCommand()
def statistics(self): seq = self.get_selection_or_sequence() if not seq: return seq = seq.upper() aa = {'A': 0, 'C': 0, 'G': 0, 'T': 0, 'N': 0} for nt in seq: if nt not in aa: nt = 'N' aa[nt] = aa[nt] + 1 GC = (100.0 * (aa['G'] + aa['C'])) / len(seq) np = NotePad() tid = np.text_id() tid.insert('end', "%s\n\n" % (time.strftime('%y %b %d, %X\n', time.localtime(time.time()))) + "Length = %d\nA=%d C=%d G=%d T=%d other=%d\nGC=%f\n\n" % (len(seq), aa['A'], aa['C'], aa['G'], aa['T'], aa['N'], GC))
def statistics(self): seq = self.get_selection_or_sequence() if not seq: return seq = seq.upper() aa = {'A': 0, 'C': 0, 'G': 0, 'T': 0, 'N': 0} for nt in seq: if nt not in aa: nt = 'N' aa[nt] = aa[nt] + 1 GC = (100.0 * (aa['G'] + aa['C'])) / len(seq) np = NotePad() tid = np.text_id() tid.insert( 'end', "%s\n\n" % (time.strftime('%y %b %d, %X\n', time.localtime(time.time()))) + "Length = %d\nA=%d C=%d G=%d T=%d other=%d\nGC=%f\n\n" % (len(seq), aa['A'], aa['C'], aa['G'], aa['T'], aa['N'], GC))
def statistics(self): """Calculate statistics of sequence and display in new window.""" seq = self.get_selection_or_sequence() if not seq: return seq = seq.upper() aa = {"A": 0, "C": 0, "G": 0, "T": 0, "N": 0} for nt in seq: if nt not in aa: nt = "N" aa[nt] = aa[nt] + 1 GC = (100.0 * (aa["G"] + aa["C"])) / len(seq) np = NotePad() tid = np.text_id() tid.insert( "end", "%s\n\n" % (time.strftime("%y %b %d, %X\n", time.localtime(time.time()))) + "Length = %d\nA=%d C=%d G=%d T=%d other=%d\nGC=%f\n\n" % (len(seq), aa["A"], aa["C"], aa["G"], aa["T"], aa["N"], GC))
def oldRun(self): self.notepad = NotePad() self.notepad.menubar.configure(bg='red') self.notepad.bind('<Destroy>', self.Exit) self.Update() print(self.command) self.pipe = posix.popen(self.command) while 1: try: char = self.pipe.read(1) self.notepad.insert(END, char) self.notepad.update() except: break if not char: break try: self.notepad.menubar.configure(bg='green') except: pass
def oldRun(self): self.notepad = NotePad() self.notepad.menubar.configure(bg='red') self.notepad.bind('<Destroy>', self.Exit) self.Update() print(self.command) self.pipe = os.popen(self.command) while True: try: char = self.pipe.read(1) self.notepad.insert(END, char) self.notepad.update() except: break if not char: break try: self.notepad.menubar.configure(bg='green') except: pass
self.worker.shutdown() del self.worker class BlastWorker(threading.Thread): def __init__(self, command): self.com = command queue = Queue.Queue(0) self.queue = queue threading.Thread.__init__(self) self.finished = 0 print(dir(queue)) print(queue.queue) def shutdown(self): # GRRRR How do I explicitely kill a thread ??????? #self.queue.put(None) del self.queue def run(self): print('running %s' % self.com) os.system(self.com) self.finished = 1 if __name__ == '__main__': np = NotePad() com = "blastall -d nr -i test.fas -p blastx" test = BlastDisplayer(com, np.tid) test.RunCommand()
class BlastIt: def __init__(self, seq, parent=None): self.seq = seq self.parent = parent self.toplevel = Toplevel(parent) Pmw.initialise(parent) self.GetBlasts() self.Choices() def GetBlasts(self): pin, nin = [], [] try: pin.extend(glob.glob(os.environ['BLASTDB'] + '/*.pin')) except: pass pin.extend(glob.glob('*.pin')) try: nin.extend(glob.glob(os.environ['BLASTDB'] + '/*.nin')) except: pass nin.extend(glob.glob('*.nin')) self.pin = map(lambda x: os.path.splitext(x)[0], pin) self.nin = map(lambda x: os.path.splitext(x)[0], nin) def Choices(self): self.GetBlasts() self.cf = Frame(self.toplevel) self.cf.pack(side=TOP, expand=1, fill=X) self.dbs = Pmw.ComboBox(self.cf, label_text='Blast Databases:', labelpos='nw', scrolledlist_items=self.nin + self.pin, selectioncommand=self.Validate) self.blasts = Pmw.ComboBox(self.cf, label_text='Blast Programs:', labelpos='nw', scrolledlist_items=[ 'blastn', 'blastp', 'blastx', 'tblastn', 'tblastx' ], selectioncommand=self.Validate) self.dbs.pack(side=LEFT, expand=1, fill=X) self.blasts.pack(side=LEFT, expand=1, fill=X) self.alternative_f = Frame(self.cf) self.alternative = Entry(self.alternative_f) self.alternative_f.pack(side=TOP, fill=X, expand=1) self.alternative.pack(side=LEFT, fill=X, expand=1) self.ok = Button(self.alternative_f, text='Run', command=self._Run) self.ok.pack(side=RIGHT) self.dbs.selectitem(0) self.blasts.selectitem(0) self.Validate() def Validate(self, *args): db = self.dbs.get() prog = self.blasts.get() color = 'red' if (prog in ['blastn', 'tblastx', 'tblastn']) == (db in self.nin): color = 'green' elif (prog in ['blastp', 'blastx']) == (db in self.pin): color = 'green' self.dbs.component('entry').configure(bg=color) self.blasts.component('entry').configure(bg=color) def _Run(self): alternative_command = self.alternative.get() if len(alternative_command.strip()): self.command = alternative_command.strip() else: db = self.dbs.get() prog = self.blasts.get() self.command = 'echo %s | nice blastall -d %s -p %s' % (self.seq, db, prog) self.Run() def Update(self): self.notepad.update() #print '.', self.notepad.after(1, self.Update) def oldRun(self): self.notepad = NotePad() self.notepad.menubar.configure(bg='red') self.notepad.bind('<Destroy>', self.Exit) self.Update() print(self.command) self.pipe = posix.popen(self.command) while 1: try: char = self.pipe.read(1) self.notepad.insert(END, char) self.notepad.update() except: break if not char: break try: self.notepad.menubar.configure(bg='green') except: pass def Run(self): self.notepad = NotePad() tid = self.notepad.tid self.notepad.menubar.configure(bg='red') self.toplevel.destroy() blastbg = xbb_blastbg.BlastDisplayer(self.command, tid) blastbg.RunCommand() # indicate the finished run by changing color try: self.notepad.menubar.configure(bg='green4') except: pass def Exit(self, *args): try: self.pipe.close() del (pipe) except: pass self.notepad.destroy() sys.exit(0)
class BlastIt: def __init__(self, seq, parent=None): self.seq = seq self.parent = parent self.toplevel = Toplevel(parent) Pmw.initialise(parent) self.GetBlasts() self.Choices() def GetBlasts(self): pin, nin = [], [] try: pin.extend(glob.glob(os.environ['BLASTDB'] + '/*.pin')) except: pass pin.extend(glob.glob('*.pin')) try: nin.extend(glob.glob(os.environ['BLASTDB'] + '/*.nin')) except: pass nin.extend(glob.glob('*.nin')) self.pin = [os.path.splitext(x)[0] for x in pin] self.nin = [os.path.splitext(x)[0] for x in nin] def Choices(self): self.GetBlasts() self.cf = Frame(self.toplevel) self.cf.pack(side=TOP, expand=1, fill=X) self.dbs = Pmw.ComboBox(self.cf, label_text='Blast Databases:', labelpos='nw', scrolledlist_items=self.nin + self.pin, selectioncommand=self.Validate ) self.blasts = Pmw.ComboBox(self.cf, label_text='Blast Programs:', labelpos='nw', scrolledlist_items=['blastn', 'blastp', 'blastx', 'tblastn', 'tblastx'], selectioncommand=self.Validate ) self.dbs.pack(side=LEFT, expand=1, fill=X) self.blasts.pack(side=LEFT, expand=1, fill=X) self.alternative_f = Frame(self.cf) self.alternative = Entry(self.alternative_f) self.alternative_f.pack(side=TOP, fill=X, expand=1) self.alternative.pack(side=LEFT, fill=X, expand=1) self.ok = Button(self.alternative_f, text='Run', command=self._Run) self.ok.pack(side=RIGHT) self.dbs.selectitem(0) self.blasts.selectitem(0) self.Validate() def Validate(self, *args): db = self.dbs.get() prog = self.blasts.get() color = 'red' if (prog in ['blastn', 'tblastx', 'tblastn']) == (db in self.nin): color = 'green' elif (prog in ['blastp', 'blastx']) == (db in self.pin): color = 'green' self.dbs.component('entry').configure(bg=color) self.blasts.component('entry').configure(bg=color) def _Run(self): alternative_command = self.alternative.get() if len(alternative_command.strip()): self.command = alternative_command.strip() else: db = self.dbs.get() prog = self.blasts.get() self.command = 'echo %s | nice blastall -d %s -p %s' % (self.seq, db, prog) self.Run() def Update(self): self.notepad.update() self.notepad.after(1, self.Update) def oldRun(self): self.notepad = NotePad() self.notepad.menubar.configure(bg='red') self.notepad.bind('<Destroy>', self.Exit) self.Update() print(self.command) self.pipe = os.popen(self.command) while True: try: char = self.pipe.read(1) self.notepad.insert(END, char) self.notepad.update() except: break if not char: break try: self.notepad.menubar.configure(bg='green') except: pass def Run(self): self.notepad = NotePad() tid = self.notepad.tid self.notepad.menubar.configure(bg='red') self.toplevel.destroy() blastbg = xbb_blastbg.BlastDisplayer(self.command, tid) blastbg.RunCommand() # indicate the finished run by changing color try: self.notepad.menubar.configure(bg='green4') except: pass def Exit(self, *args): try: self.pipe.close() del(self.pipe) except: pass self.notepad.destroy() sys.exit(0)