def open_file(self, evt): '''Function for opening file''' self.dir_to_open = default_filepath self.dir_to_open = os.path.dirname( os.path.abspath(inspect.getfile( inspect.currentframe()))) #current script directory dlg = wx.FileDialog(self, style=wx.OPEN | wx.FILE_MUST_EXIST, defaultDir=self.dir_to_open, wildcard='GenBank files (*.gb)|*|Any file (*)|*') if dlg.ShowModal() == wx.ID_CANCEL: return # the user does not want to open that file! genbank.gb.fileName = dlg.GetFilename() all_path = dlg.GetPath() dire = dlg.GetDirectory() dlg.Destroy() if (genbank.gb.fileName == None or genbank.gb.fileName == ""): return 1 name, extension = genbank.gb.fileName.split('.') if extension.lower() == 'gb': genbank.gb = genbank.gbobject( all_path) #make a genbank object and read file self.SetTitle(genbank.gb.fileName + ' - DNApy') if genbank.gb.clutter == True: #if tags from ApE or Vector NTI is found in file dlg = wx.MessageDialog( self, style=wx.YES_NO | wx.CANCEL, message= 'This file contains tags from the Vector NTI or ApE programs. Keeping these tags may break compatibility with other software. Removing them will clean up the file, but may result in the loss of some personalized styling options when this file is viewed in Vector NTI or ApE. Do you wish to REMOVE these tags?' ) result = dlg.ShowModal() dlg.Destroy() if result == wx.ID_YES: #if yes, remove clutter genbank.gb.clean_clutter() #enable the tools self.frame_1_toolbar.EnableTool(502, True) self.frame_1_toolbar.EnableTool(503, True) self.frame_1_toolbar.EnableTool(504, True) self.frame_1_toolbar.EnableTool(505, True) self.frame_1_toolbar.EnableTool(506, True) self.frame_1_toolbar.EnableTool(511, True) self.frame_1_toolbar.EnableTool(512, True) self.fileopen = True #self.DNApy.update_ownUI() else: print("error, not a gb file") self.Bind(wx.EVT_UPDATE_UI, self.update_statusbar) # update gui to find eestriction sites etc self.update_globalUI()
def NCBIfetchGB(id): ''' Same as NCBIfetch, but instead of returning a text string it returns a genbank object. ''' file = NCBIfetch(id).split('\n') #get file and split it file = [x+'\n' for x in file] #add back the linebreaks x = genbank.gbobject() x.readgb(file) return x
def open_file(self, evt): '''Function for opening file''' self.dir_to_open = default_filepath self.dir_to_open = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) #current script directory dlg = wx.FileDialog( self, style=wx.OPEN|wx.FILE_MUST_EXIST, defaultDir=self.dir_to_open ,wildcard='GenBank files (*.gb)|*|Any file (*)|*') if dlg.ShowModal() == wx.ID_CANCEL: return # the user does not want to open that file! genbank.gb.fileName = dlg.GetFilename() all_path=dlg.GetPath() dire=dlg.GetDirectory() dlg.Destroy() if(genbank.gb.fileName == None or genbank.gb.fileName == "" ): return 1 name, extension = genbank.gb.fileName.split('.') if extension.lower() == 'gb': genbank.gb = genbank.gbobject(all_path) #make a genbank object and read file self.SetTitle(genbank.gb.fileName+' - DNApy') if genbank.gb.clutter == True: #if tags from ApE or Vector NTI is found in file dlg = wx.MessageDialog(self, style=wx.YES_NO|wx.CANCEL, message='This file contains tags from the Vector NTI or ApE programs. Keeping these tags may break compatibility with other software. Removing them will clean up the file, but may result in the loss of some personalized styling options when this file is viewed in Vector NTI or ApE. Do you wish to REMOVE these tags?') result = dlg.ShowModal() dlg.Destroy() if result == wx.ID_YES: #if yes, remove clutter genbank.gb.clean_clutter() #enable the tools self.frame_1_toolbar.EnableTool(502, True) self.frame_1_toolbar.EnableTool(503, True) self.frame_1_toolbar.EnableTool(504, True) self.frame_1_toolbar.EnableTool(505, True) self.frame_1_toolbar.EnableTool(506, True) self.frame_1_toolbar.EnableTool(511, True) self.frame_1_toolbar.EnableTool(512, True) self.fileopen = True #self.DNApy.update_ownUI() else: print("error, not a gb file") self.Bind(wx.EVT_UPDATE_UI, self.update_statusbar) # update gui to find eestriction sites etc self.update_globalUI()
def new_file(self, evt): '''Create new gb file''' if self.fileopen == False: #if no file is open, make blank gb file genbank.gb = genbank.gbobject() #make new gb in panel self.SetTitle('NewFile - DNApy') # self.page_change("") self.frame_1_toolbar.EnableTool(502, 1) self.frame_1_toolbar.EnableTool(503, 1) self.frame_1_toolbar.EnableTool(504, 1) self.frame_1_toolbar.EnableTool(505, 1) self.frame_1_toolbar.EnableTool(506, 1) self.frame_1_toolbar.EnableTool(511, 1) self.frame_1_toolbar.EnableTool(512, 1) self.Bind(wx.EVT_UPDATE_UI, self.update_statusbar) self.fileopen = True elif self.fileopen == True: #if a file IS open, make a new window subprocess.Popen("python ~/Python_files/DNApy/main.py 1", shell=True) #this needs a fix for windows
def new_file(self, evt): '''Create new gb file''' if self.fileopen == False: #if no file is open, make blank gb file genbank.gb = genbank.gbobject() #make new gb in panel self.SetTitle('NewFile - DNApy') # self.page_change("") self.frame_1_toolbar.EnableTool(502, 1) self.frame_1_toolbar.EnableTool(503, 1) self.frame_1_toolbar.EnableTool(504, 1) self.frame_1_toolbar.EnableTool(505, 1) self.frame_1_toolbar.EnableTool(506, 1) self.frame_1_toolbar.EnableTool(511, 1) self.frame_1_toolbar.EnableTool(512, 1) self.Bind(wx.EVT_UPDATE_UI, self.update_statusbar) self.fileopen = True # TODO fix the weird paths elif self.fileopen == True: #if a file IS open, make a new window subprocess.Popen("python ~/Python_files/DNApy/main.py 1", shell=True) #this needs a fix for windows
frame = wx.Frame(None, -1, title="Feature Edit", size=(700,300)) panel = FeatureEdit(frame, -1) frame.Centre() frame.Show(True) self.SetTopWindow(frame) return True if __name__ == '__main__': #if script is run by itself and not loaded files={} #list with all configuration files files['default_dir'] = os.path.abspath(os.path.dirname(sys.argv[0]))+"/" files['default_dir']=string.replace(files['default_dir'], "\\", "/") files['default_dir']=string.replace(files['default_dir'], "library.zip", "") settings=files['default_dir']+"settings" ##path to the file of the global settings execfile(settings) #gets all the pre-assigned settings genbank.dna_selection = (0, 0) #variable for storing current DNA selection genbank.feature_selection = False #variable for storing current feature selection import sys assert len(sys.argv) == 3, 'Error, this script requires a path to a genbank file and a feature index (integer) as an argument.' print('Opening %s' % str(sys.argv[1])) genbank.gb = genbank.gbobject(str(sys.argv[1])) #make a genbank object and read file genbank.feature_selection = sys.argv[2] app = MyApp(0) app.MainLoop()
panel = DNAedit(frame, -1) frame.Centre() frame.Show(True) self.SetTopWindow(frame) return True if __name__ == '__main__': #if script is run by itself and not loaded files={} #list with all configuration files files['default_dir'] = os.path.abspath(os.path.dirname(sys.argv[0]))+"/" files['default_dir']=string.replace(files['default_dir'], "\\", "/") files['default_dir']=string.replace(files['default_dir'], "library.zip", "") settings=files['default_dir']+"settings" ##path to the file of the global settings exec(compile(open(settings).read(), settings, 'exec')) #gets all the pre-assigned settings genbank.dna_selection = (0, 0, -1) #variable for storing current DNA selection genbank.feature_selection = False #variable for storing current feature selection genbank.search_hits = [] import sys assert len(sys.argv) == 2, 'Error, this script requires a path to a genbank file as an argument.' print(('Opening %s' % str(sys.argv[1]))) genbank.gb = genbank.gbobject(str(sys.argv[1])) #make a genbank object and read file app = MyApp(0) app.MainLoop()