Example #1
0
  def importFastaSeq(self):

    if not self.project:
      showWarning('Failure','Please create a new CCPN project.', parent=self)
      return

    fileTypes = [ FileType('Fasta', ['*.fsa']),
                  FileType('All', ['*']) ]

    fileSelectPopup = FileSelectPopup(self, file_types=fileTypes,
                        title='Import Fasta sequence file', dismiss_text='Cancel',
                        selected_file_must_exist=True, multiSelect=False,)

    fileName = fileSelectPopup.getFile()

    if not os.path.exists(fileName):
      showWarning('Failure','No such file.', parent=self)
      return

    if fileName:
      name = os.path.split(fileName)[1]
      if '.' in name:
        name = name.split('.')[0]

      fastaObj = FastaFormat(self.project, self, verbose=True)
      fastaObj.readSequence(fileName, minimalPrompts=True)

      self.eciFrame.updateAll()

      return fastaObj
Example #2
0
  def importPdb(self):

    if not self.project:
      showWarning('Failure','Please create a new CCPN project.', parent=self)
      return

    fileTypes = [ FileType('PDB', ['*.pdb']),
                  FileType('PDB Entry', ['*.ent']),
                  FileType('All', ['*']) ]

    fileSelectPopup = FileSelectPopup(self, file_types=fileTypes,
                        title='Import PDB 3.20 file', dismiss_text='Cancel',
                        selected_file_must_exist=True, multiSelect=False,)

    fileName = fileSelectPopup.getFile()

    if not os.path.exists(fileName):
      showWarning('Failure','No such file.', parent=self)
      return

    if fileName:
      name = os.path.split(fileName)[1]
      if '.' in name:
        name = name.split('.')[0]

      pdbObj = ReadPdb(fileName, self.project, 'PDB_'+ name, self)

      self.eciFrame.updateAll()

      return pdbObj
Example #3
0
    def chooseOldProjectFile(self):

        fileTypes = [  FileType('CING', ['project.xml']),
                       FileType('All',  ['*'])
                    ]
        popup = FileSelectPopup(self, file_types = fileTypes,
                                title = 'Select CING project file', dismiss_text = 'Cancel',
                                selected_file_must_exist = True)

        fileName = popup.getFile()
#    dirName  = popup.getDirectory()

        if len(fileName) > 0:
                # Put text into entry,name widgets
            dummy,name = cing.Project.rootPath(fileName)
            self.projEntry.configure(state='normal')
            self.projEntry.set(fileName)

            self.nameEntry.configure(state='normal')
            self.nameEntry.set(name)
            self.nameEntry.configure(state='disabled')
            # choose the correct radiobutton
            self.projOptionsSelect.setIndex(0)
            self.updateGui()
        # end if
        #nd if

        popup.destroy()
Example #4
0
  def importPdbCoords(self):

    if not self.project:
      showWarning('Failure','Please create a new CCPN project.', parent=self)
      return

    fileTypes = [ FileType('PDB', ['*.pdb']),
                  FileType('PDB Entry', ['*.ent']),
                  FileType('All', ['*']) ]

    fileSelectPopup = FileSelectPopup(self, file_types=fileTypes,
                        title='Import PDB coordinates file', dismiss_text='Cancel',
                        selected_file_must_exist=True, multiSelect=False,)

    fileName = fileSelectPopup.getFile()

    if not os.path.exists(fileName):
      showWarning('Failure','No such file.', parent=self)
      return

    if fileName:
      name = os.path.split(fileName)[1]
      if '.' in name:
        name = name.split('.')[0]

      pdbObj = PseudoPdbFormat(self.project, self, verbose=True)
      pdbObj.readCoordinates(fileName, minimalPrompts=True)

      self.eciFrame.updateAll()

      return pdbObj
Example #5
0
  def importNmrStar31(self):

    if not self.project:
      showWarning('Failure','Please create a new CCPN project.', parent=self)
      return

    fileTypes = [ FileType('STAR', ['*.str']),
                  FileType('All', ['*'])]

    fileSelectPopup = FileSelectPopup(self, file_types=fileTypes,
                        title='Import NMR-STAR 3.1 file', dismiss_text='Cancel',
                        selected_file_must_exist=True, multiSelect=False,)

    fileName = fileSelectPopup.getFile()

    if not os.path.exists(fileName):
      showWarning('Failure','No such file.', parent=self)
      return

    if fileName:
      nmrStarObj = NmrStarFormat(self.project, self, verbose=True)
      nmrStarObj.readProject(fileName, minimalPrompts=True, version='3.1')

      self.eciFrame.updateAll()

      return nmrStarObj
Example #6
0
    def import_project(self):

        # FIXME JMCI

        # need to preserve the current status. Take default from the
        # Wms layer
        rootDir = self.basePopup.repList.current_import_dir

        fileSelectPopup = FileSelectPopup(self, None, rootDir)

        new_project_dir = fileSelectPopup.getDirectory()
        self.basePopup.repList.current_import_dir = new_project_dir

        print 'in import project with directory', new_project_dir

        idx = new_project_dir.rfind('/')
        new_project_name = new_project_dir[idx + 1:]

        print 'in import project with project', new_project_name

        # FIXME

        # need to set the project version number somewhere. For now set to none
        # and this gets picked up and set to a default 1.1 later

        self.repository.import_project(new_project_name, None, new_project_dir)

        self.drawFrame()
Example #7
0
    def chooseOldProjectFile(self):

        fileTypes = [FileType('CING', ['project.xml']), FileType('All', ['*'])]
        popup = FileSelectPopup(self,
                                file_types=fileTypes,
                                title='Select CING project file',
                                dismiss_text='Cancel',
                                selected_file_must_exist=True)

        fileName = popup.getFile()
        #    dirName  = popup.getDirectory()

        if len(fileName) > 0:
            # Put text into entry,name widgets
            dummy, name = cing.Project.rootPath(fileName)
            self.projEntry.configure(state='normal')
            self.projEntry.set(fileName)

            self.nameEntry.configure(state='normal')
            self.nameEntry.set(name)
            self.nameEntry.configure(state='disabled')
            # choose the correct radiobutton
            self.projOptionsSelect.setIndex(0)
            self.updateGui()
        # end if
        #nd if

        popup.destroy()
Example #8
0
    def exportText(self, *event):

        from memops.gui.FileSelect import FileType
        from memops.gui.FileSelectPopup import FileSelectPopup

        if self.textOut:
            fileTypes = [
                FileType('Text', ['*.txt']),
                FileType('CSV', ['*.csv']),
                FileType('All', ['*'])
            ]
            fileSelectPopup = FileSelectPopup(self,
                                              file_types=fileTypes,
                                              title='Save table as text',
                                              dismiss_text='Cancel',
                                              selected_file_must_exist=False)

            fileName = fileSelectPopup.getFile()

            if fileName:
                file = open(fileName, 'w')
                if fileName.endswith('.csv'):
                    for textRow in self.textMatrix:
                        file.write(','.join(textRow) + '\n')
                else:
                    file.write(self.textOut)
Example #9
0
  def selectFile(self):

    fileSelectPopup = FileSelectPopup(self, title = 'Choose file', dismiss_text = 'Cancel',
                                      selected_file_must_exist = True)

    fileName = fileSelectPopup.getFile()

    self.textWindow.setText('File Selected: %s\n' % fileName)
Example #10
0
    def selectDir(self):

        popup = FileSelectPopup(self, show_file=False)
        dir = popup.getDirectory()
        popup.destroy()

        if (dir):
            self.dir_entry.set(dir)
            self.setDir()
Example #11
0
  def chooseExecutable(self):
  
    fileTypes = [FileType('Table', ['*.exe']), FileType('All', ['*'])]
    fileSelectPopup = FileSelectPopup(self, file_types = fileTypes,
                                      title = 'Choose 2d BACUS executable', dismiss_text = 'Cancel',
                                      selected_file_must_exist = False)

    fileName = fileSelectPopup.getFile() 
    if fileName:
      self.executableEntry.set(fileName)
Example #12
0
    def getDirectory(self, widget, obj, attrName):
        """Is called by updateGeneral. No widget because table placement is irrelevent and setting process not interruptable"""

        value = getattr(obj, attrName)
        if not os.path.exists(value): value = None

        popup = FileSelectPopup(self, directory=value, show_file=False)
        value = popup.getDirectory()
        if value:
            setattr(obj, attrName, value)
Example #13
0
    def selectWorkingDir(self):

        popup = FileSelectPopup(self, show_file=False)

        directory = popup.getDirectory()
        if directory:
            self.workingDirEntry.set(directory)

        popup.destroy()
        self.updateAfter()
Example #14
0
  def selectTempDir(self):
    
    popup = FileSelectPopup(self, show_file=False)

    directory = popup.getDirectory()
    if directory:
      self.tempDirEntry.set( directory )
    
    popup.destroy()
    self.updateEntryParams()
Example #15
0
    def selectExecutable(self):
        """ Choose the MODULE executable appropriate for your system. """

        popup = FileSelectPopup(self, show_file=True)

        executable = popup.getFile()
        if executable:
            self.moduleExeEntry.set(executable)

        popup.destroy()
Example #16
0
    def chooseMiscScript(self):

        # Prepend default Cyana file extension below
        fileTypes = [  FileType('All', ['*']), ]
        popup = FileSelectPopup(self, file_types = fileTypes,
                                title = 'Script file', dismiss_text = 'Cancel',
                                selected_file_must_exist = True)

        fileName = popup.getFile()
        self.miscScriptEntry.set(fileName)
        popup.destroy()
Example #17
0
    def chooseDirectory(self):

        directory = os.path.dirname(self.fileName)
        if not directory:
            directory = os.getcwd()
        popup = FileSelectPopup(self, directory=directory, show_file=False)
        directory = popup.getDirectory()
        popup.destroy()

        if directory:
            self.directoryEntry.set(directory)
Example #18
0
  def chooseValidScript(self):

    # Prepend default Cyana file extension below
    fileTypes = [  FileType('Python', ['*.py']), ]
    popup = FileSelectPopup(self, file_types = fileTypes,
                            title='Python file', dismiss_text='Cancel',
                            selected_file_must_exist = True)

    fileName = popup.getFile()
    self.validScriptEntry.set(fileName)
    popup.destroy()
Example #19
0
  def chooseZipFile(self):

    fileTypes = [  FileType('Zip', ['*.zip']), ]
    popup = FileSelectPopup(self, file_types=fileTypes, file=self.resultFileEntry.get(),
                            title='Results zip file location', dismiss_text='Cancel',
                            selected_file_must_exist=False)

    fileName = popup.getFile()

    if fileName:
      self.resultFileEntry.set(fileName)
    popup.destroy()
Example #20
0
    def selectFile(self):

        spectrum = self.spectrum
        if spectrum:
            directory = spectrum.analysisSpectrum.contourDir.dataLocation
        else:
            directory = os.getcwd()
        popup = FileSelectPopup(self, directory=directory)
        fileName = popup.getFile()
        popup.destroy()
        if fileName:
            self.file_entry.set(fileName)
Example #21
0
    def chooseFile(self):

        directory = self.directoryEntry.get()
        if not directory:
            directory = os.getcwd()
        popup = FileSelectPopup(self, directory=directory)
        file = popup.getFile()
        popup.destroy()

        if file:
            template = os.path.basename(file)
            self.templateEntry.set(template)
Example #22
0
    def chooseCyanaFile(self):

        # Prepend default Cyana file extension below
        fileTypes = [  FileType('All', ['*']), ]
        popup = FileSelectPopup(self, file_types = fileTypes,
                                title = 'CYANA fproject file', dismiss_text = 'Cancel',
                                selected_file_must_exist = True)

        fileName = popup.getFile()
        self.cyanaEntry.set(fileName)
        self.projOptionsSelect.setIndex(3)

        popup.destroy()
Example #23
0
  def findFile(self):

    if self.file_select_popup:
      self.file_select_popup.open()
    else:
      file_types = [ FileType('All', ['*']),
                     FileType('PostScript', ['*.ps', '*.eps']),
                     FileType('PDF', ['*.pdf', '*.ai']) ]
      self.file_select_popup = FileSelectPopup(self, file_types=file_types)

    file = self.file_select_popup.getFile()
    if file:
      self.file_entry.set(file)
Example #24
0
  def selectCnsExe(self):
    
    fileTypes = [ FileType("All", ["*"]), FileType("EXE", ["*.exe"]) ]

    popup = FileSelectPopup(self, fileTypes)

    file = popup.getFile()

    if file:
      self.cnsExeEntry.set( file )
    
    popup.destroy()
    self.updateEntryParams()
Example #25
0
def askFile(title, prompt, initial_value = '', parent = None,
            dismiss_text='Cancel', extra_dismiss_text = ''):

  if (parent):
    popup = FileSelectPopup(parent, title=title, prompt=prompt, show_file=True,
                            dismiss_text=dismiss_text,
                            extra_dismiss_text=extra_dismiss_text,
                            file=initial_value)
      
    file = popup.getFile()
    popup.destroy()
    return file
  else:
    return askString(title, prompt, initial_value)
Example #26
0
def askDir(title, prompt, initial_value = '', parent = None,
           dismiss_text='Cancel', extra_dismiss_text = '', default_dir = None):

  if (parent):
    popup = FileSelectPopup(parent, title=title, prompt=prompt, show_file=False,
                            dismiss_text=dismiss_text,
                            extra_dismiss_text=extra_dismiss_text,
                            file=initial_value, default_dir = default_dir)

    dir = popup.getDirectory()
    popup.destroy()
    return dir
  else:
    return askString(title, prompt, initial_value)
Example #27
0
    def readPCSFileChange(self):
        fileTypes = [FileType('PCS', ['*.npc']), FileType('All', ['*'])]
        fileSelectPopup = FileSelectPopup(
            self,
            file=os.path.basename(self.calPCSEntry.get()),
            directory=os.path.dirname(self.calPCSEntry.get()),
            file_types=fileTypes,
            title='Save PCS values to file',
            dismiss_text='Cancel',
            selected_file_must_exist=False,
            multiSelect=False,
        )

        self.calPCSEntry.set(fileSelectPopup.getFile())
Example #28
0
    def writeScriptFileChange(self):
        fileTypes = [FileType('python', ['*.py']), FileType('All', ['*'])]
        fileSelectPopup = FileSelectPopup(
            self,
            file=os.path.basename(self.scriptEntry.get()),
            directory=os.path.dirname(self.scriptEntry.get()),
            file_types=fileTypes,
            title='Paramagpy script',
            dismiss_text='Cancel',
            selected_file_must_exist=False,
            multiSelect=False,
        )

        self.scriptEntry.set(fileSelectPopup.getFile())
Example #29
0
  def printCanvas(self, *event):
  
    fileTypes = [  FileType('PostScript', ['*.ps']), FileType('All', ['*'])]
    fileSelectPopup = FileSelectPopup(self, file_types = fileTypes,
               title = 'Print canvas to file', dismiss_text = 'Cancel',
               selected_file_must_exist = False)

    fileName = fileSelectPopup.getFile()
    
    self.bbox = bbox = self.canvas.bbox('all')
    w = bbox[2] - bbox[0]
    h = bbox[3] - bbox[1]
    self.canvas.postscript(colormode='color',file=fileName,
                           x=bbox[0], y=bbox[1], width=w+2,
                           pagewidth='21.c', height=h+2, fontmap='fontmap')
Example #30
0
    def printCanvas(self, *event):

        from memops.gui.FileSelect import FileType
        from memops.gui.FileSelectPopup import FileSelectPopup

        fileTypes = [FileType('PostScript', ['*.ps']), FileType('All', ['*'])]
        fileSelectPopup = FileSelectPopup(self,
                                          file_types=fileTypes,
                                          title='Print canvas to file',
                                          dismiss_text='Cancel',
                                          selected_file_must_exist=False)

        fileName = fileSelectPopup.getFile()

        self.postscript(colormode='color', file=fileName)
Example #31
0
    def getDataUrl(self, *extra):

        if self.dataStore:
            dataStore = self.dataStore
            oldPath = dataStore.dataUrl.url.dataLocation
            if os.path.exists(oldPath):
                directory = oldPath
            elif os.path.exists(os.path.dirname(oldPath)):
                directory = os.path.dirname(oldPath)
            else:
                directory = None
            popup = FileSelectPopup(self, directory=directory, show_file=False)
            newPath = popup.getDirectory()
            popup.destroy()
            if newPath and oldPath != newPath:
                changeDataStoreUrl(dataStore, newPath)
Example #32
0
    def findFile(self):

        format = self.format_menu.getSelected()

        if (format == tabFormat):
            file_types = [FileType('All', ['*']), FileType('Text', ['*.txt'])]
        else:
            file_types = [FileType('All', ['*']), FileType('CSV', ['*.csv'])]

        popup = FileSelectPopup(self, file_types=file_types)

        file = popup.getFile()
        if (file):
            self.file_entry.set(file)

        popup.destroy()
Example #33
0
    def loadValues(self):

        directory = self.parent.fileSelect.getDirectory()
        fileSelectPopup = FileSelectPopup(self,
                                          title='Select Sampled Data File',
                                          dismiss_text='Cancel',
                                          selected_file_must_exist=True,
                                          multiSelect=False,
                                          directory=directory)

        fileName = fileSelectPopup.file_select.getFile()

        if not fileName:
            return

        fileObj = open(fileName, 'rU')

        data = ''
        line = fileObj.readline()
        while line:
            data += line
            line = fileObj.readline()

        fileObj.close()

        data = re.sub(',\s+', ',', data)
        data = re.sub('\s+', ',', data)
        data = re.sub(',,', ',', data)
        data = re.sub('[^0-9,.\-+eE]', '', data)

        self.valueEntry.set(data)
Example #34
0
    def chooseCcpnFile(self):

        fileTypes = [  FileType('XML', ['*.xml']), FileType('All', ['*'])]
        popup = FileSelectPopup(self, file_types = fileTypes,
                                title = 'CCPN project XML file', dismiss_text = 'Cancel',
                                selected_file_must_exist = True)

        fileName = popup.getFile()
        if len(fileName)>0:
            self.pdbEntry.configure(state='normal')
            self.pdbEntry.set(fileName)
            self.projOptionsSelect.setIndex(1)

            _dir,name,dummy = nTpath( fileName )
            self.nameEntry.set(name)
        #end if
        self.ccpnEntry.set(fileName)
        self.projOptionsSelect.setIndex(2)

        popup.destroy()
Example #35
0
    def choosePdbFile(self):

        fileTypes = [ FileType('PDB', ['*.pdb']),  FileType('All', ['*'])]
        popup = FileSelectPopup(self, file_types = fileTypes,
                                title = 'PDB file', dismiss_text = 'Cancel',
                                selected_file_must_exist = True)

        fileName = popup.getFile()
        if len(fileName)>0:
            # Put text into entry widget
            self.pdbEntry.configure(state='normal')
            self.pdbEntry.set(fileName)
            # Put text into name widget
            _dir,name,dummy = nTpath( fileName )
            self.nameEntry.configure(state='normal')
            self.nameEntry.set(name)
            # choose the correct radiobutton
            self.projOptionsSelect.setIndex(1)
            self.updateGui()
        #end if

        popup.destroy()