Exemple #1
0
    def setupProject(self, dirPath, projectName):

        self.projectDirPath = dirPath

        try:
            self.ccpnProject = loadProject(dirPath)
            print "Read existing CCPN project..."

        except:
            print "Creating new CCPN project..."

            projectName = returnMemopsWord(projectName)
            self.ccpnProject = Implementation.MemopsRoot(name=projectName)
            self.nmrProject = self.ccpnProject.newNmrProject(
                name=self.ccpnProject.name)

            if not os.path.exists(dirPath):
                os.mkdir(dirPath)

            repository = self.ccpnProject.findFirstRepository(name='userData')

            if not repository.url.path == dirPath:
                url = Implementation.Url(path=dirPath)
                repository.url = url

        # TODO: check name of project: if not same CRASH OUT!

        return self.ccpnProject
    def setupProject(self):

        # Create a CCPN project (defined locally in script!)
        self.ccpnProject = Implementation.MemopsRoot(name = self.idCode)
        self.nmrProject = self.ccpnProject.newNmrProject(name = self.ccpnProject.name)

        # Tag with the data (new as of 17/11/2008)
        appDataCreationDate = Implementation.AppDataString(application = "DataHandler", keyword = 'creationDate', value = self.timeFlag)
        self.nmrProject.addApplicationData(appDataCreationDate)
Exemple #3
0
def modifyPackageLocators(project,
                          repositoryName,
                          repositoryPath,
                          packageNames,
                          resetPackageLocator=True,
                          resetRepository=False):
    """
  Resets package locators for specified packages to specified repository.
  
  Use as, for example:
  
  modifyPackageLocators(project,'newChemComps','/mydir/data/chemComps/',('ccp.molecule.ChemComp','ccp.molecule.ChemCompCoord'))
  
  Additional args:
  
  - resetPackageLocator:  True   will reset the package locator completely, removing old info
                          False  will add the repository to the package locator.
  
  - resetRepository:      True   will reset url for the repository, even if it already exists
                          False  will not reset the url for the repository if it already exists
  
  Returns the relevant repository.
  
  """

    repository = project.findFirstRepository(name=repositoryName)
    ss = normalisePath(repositoryPath)

    if not repository:
        repository = project.newRepository(name=repositoryName,
                                           url=Implementation.Url(path=ss))
    elif resetRepository and repository.url.path != repositoryPath:
        repository.url = Implementation.Url(path=ss)

    for packageName in packageNames:
        packageLocator = project.findFirstPackageLocator(
            targetName=packageName)

        if not packageLocator:
            raise ApiError("Cannot modify repository 'any' for package %s" %
                           packageName)

        if resetPackageLocator:
            packageLocator.repositories = (repository, )
        elif not repository in packageLocator.repositories:
            packageLocator.addRepository(repository)

    return repository
Exemple #4
0
    def setupContactOccurrenceInfo_nonCcpnBased(self,
                                                molTypes,
                                                confidence,
                                                hasDistanceInfo=True,
                                                useProteinFamilies=False):

        from ccp.general.Constants import standardResidueCcpCodes
        from memops.api import Implementation

        #
        # This is to doublecheck that top-level values don't get mixed with lower level ones..
        #

        self.hasDistanceInfo = hasDistanceInfo
        self.useProteinFamilies = useProteinFamilies

        #
        # Warning: this only sets info for standard residues. Should be good enough,
        # use CCPN if not.
        #

        self.molTypes = molTypes
        self.ccpCodes = {}

        for molType in self.molTypes:
            self.ccpCodes[molType] = standardResidueCcpCodes[molType]

        self.importContactShortDicts()
        self.setInvConfidence(confidence)

        project = Implementation.MemopsRoot(name='test')
        self.createAtomSetInfo(project)
Exemple #5
0
    def setPeak(self):
        """
    
    Cannot overwrite for Sparky: have to delete all old peaks and create
    all new ones.
    
    """

        if self.rawPeak.num != None:
            details = "Original number %d" % self.rawPeak.num
        else:
            details = "No original number"

        self.peak = Nmr.Peak(self.peakList, details=details)

        #
        # Also set original number in applicationdata so can be reused for writing
        #

        if self.rawPeak.num != None:

            self.peak.addApplicationData(
                Implementation.AppDataInt(application=self.format,
                                          keyword=peakNum_kw,
                                          value=self.rawPeak.num))

        # Sparky specific - has to be reset for every peak
        self.resLabelCodes = []
Exemple #6
0
def convert(projectName, rootDir):
    datasetDir = os.path.join(rootDir, projectName)
    nijmegenDir = os.path.join(datasetDir, "Nijmegen")
    authorDir = os.path.join(datasetDir, "Authors")
    os.chdir(nijmegenDir)

    projectPath = os.path.join(nijmegenDir, projectName)
    if os.path.exists(projectPath):
        shutil.rmtree(projectPath)

    project = Implementation.MemopsRoot(name=projectName)

    nmrProject = project.newNmrProject(name=project.name)
    structureGeneration = nmrProject.newStructureGeneration()
    guiRoot = Tkinter.Tk()
    format = PseudoPdbFormat(project, guiRoot, verbose=1)

    globPattern = authorDir + '/*.pdb'
    fileList = glob(globPattern)
    nTdebug("From %s will read files: %s" % (globPattern, fileList))
    format.readCoordinates(fileList,
                           strucGen=structureGeneration,
                           minimalPrompts=1,
                           linkAtoms=0)

    project.saveModified()
    tgzFileName = "../" + projectName + ".tgz"
    cmd = "tar -czf %s %s" % (tgzFileName, projectName)
    do_cmd(cmd)
Exemple #7
0
def createPpmFreqDataSource(exp,dsName,dsType,numDim):

  ds = Nmr.DataSource(exp,name = dsName, numDim = numDim, dataType = dsType)

  for dim in range(0,numDim):
    expDim = exp.findFirstExpDim(dim = (dim + 1))
    expDimRefs = expDim.sortedExpDimRefs()
    refIsotopeCode = expDimRefs[0].isotopeCodes[0]
    
    # User first expDimRef to set number of points
    # Set numPoints, numPointsOrig to 20 for H, 250 for C,N!
    if refIsotopeCode == '1H':
      numPoints = 1024
      valuePerPoint = 6.5
    else:
      numPoints = 256
      if refIsotopeCode == '13C':
        valuePerPoint = 100.0
      elif refIsotopeCode== '15N':
        valuePerPoint = 40.0
      else:
        valuePerPoint = 1.0

    # Setting up empty freqdatadim and associated datadimref...
    # Assuming that imaginary data will be deleted!
    freqDataDim = Nmr.FreqDataDim(ds, expDim = expDim, dim = (dim + 1), isComplex = True,valuePerPoint = valuePerPoint, numPoints = numPoints, numPointsOrig = numPoints)
      
    # Tag to mark that this is a 'default' freqDataDim
    freqDataDim.addApplicationData(Implementation.AppDataBoolean(application = ccpNmr_kw, keyword = 'default', value = True))
  
  # Set sensible dataDimRef info.
  setDataDimRefs(ds)

  return ds
Exemple #8
0
 def tagProject(self):
     """
     Return True on error
     """
     for atomKey in vascoAtomIdLoL:
         atomType = atomKey[0]
         (rerefValue, rerefError) = self.rerefInfo[atomKey]
         if rerefValue != None:
             appData1 = Implementation.AppDataFloat(
                 value=rerefValue,
                 application='VASCO',
                 keyword='correction_%s' % atomType)
             appData2 = Implementation.AppDataFloat(
                 value=rerefError,
                 application='VASCO',
                 keyword='correctionError_%s' % atomType)
             self.shiftList.addApplicationData(appData1)
             self.shiftList.addApplicationData(appData2)
Exemple #9
0
def tagAsFresh(ccpnObject):

  appData = ccpnObject.findFirstApplicationData(keyword = freshTag)
  
  if not appData:
    appData = Implementation.AppDataBoolean(application = 'pdbeCcGeneration', keyword = freshTag, value = True)
    ccpnObject.addApplicationData(appData)
  
  appData.value = True
Exemple #10
0
 def addDynamicTensor(self):
 
   if self.alignMedium:
     tensor = Implementation.SymmTracelessMatrix(aAxial=0.0,aRhombic=0.0,
                                                 alpha=0.0,beta=0.0,
                                                 gamma=0.0)
     self.alignMedium.dynamicAlignment = tensor
     
     self.updateAlignMediaAfter(self.alignMedium)
Exemple #11
0
    def setPeakExtras(self):

        #
        # chiProb is 1 for pure noise in nmrDraw
        #

        self.peak.figOfMerit = 1 - self.rawPeak.chiProb

        clustIdAppData = Implementation.AppDataInt(application=self.format,
                                                   keyword='clustId',
                                                   value=self.rawPeak.clustId)
        self.peak.addApplicationData(clustIdAppData)

        numPeaksClustAppData = Implementation.AppDataInt(
            application=self.format,
            keyword='numPeaksClust',
            value=self.rawPeak.numPeaksClust)
        self.peak.addApplicationData(numPeaksClustAppData)
Exemple #12
0
def setCcpNmrResonanceName(resonance,refAtom,atomName = None, forceChange = 0):
  
  #
  # Set the CCP names
  #
  # Full 'resonance' name on application data level
  # Just atom (group) name on resonance level!
  #
  
  residue = refAtom.residue
    
  seqCode = residue.seqCode
  chainCode = residue.chain.code

  if atomName == None:
    atomName = refAtom.name
  
  resName = chainCode + tagSep + str(seqCode) + tagSep + atomName
  
  # Set resonance name
  if resonance.name == None or forceChange == 1:
    resonance.name = atomName
    
    # Here only look for ONE match - don't want multiple matches for ccp names...

    assignData = resonance.findFirstApplicationData(application = ccpNmr_kw, keyword = assign_kw)
    
    if assignData:
      if assignData.value != resName:
        if forceChange == 0:
          print "  Warning: couldn't set ccpNmr resonance name %s (name already set to %s)" % (resName,assignData.value)
        else:
          assignData.delete()
          resonance.addApplicationData(Implementation.AppDataString( application = ccpNmr_kw, keyword = assign_kw, value = resName))
          
    else:
      resonance.addApplicationData(Implementation.AppDataString( application = ccpNmr_kw, keyword = assign_kw, value = resName))

  else:
    if resonance.name != atomName:
      print "  Warning: couldn't set ccpNmr name %s for resonance %s (name already set)" % (atomName,resonance.name)
      resName = resonance.name
      
  return resName
Exemple #13
0
    def tagAriaInput(self, object):

        appData = object.findFirstApplicationData(application=ccpNmr_kw,
                                                  keyword=isAriaInput_kw)

        if not appData:
            object.addApplicationData(
                Implementation.AppDataBoolean(application=ccpNmr_kw,
                                              keyword=isAriaInput_kw,
                                              value=True))
Exemple #14
0
def setDataSourceDataStore(dataSource,
                           dataUrlPath,
                           localPath,
                           dataLocationStore=None,
                           dataUrl=None):

    #
    # Get DataLocationStore
    #

    if not dataLocationStore:

        setCurrentStore(dataSource.root, 'DataLocationStore')
        dataLocationStore = dataSource.root.currentDataLocationStore

    #
    # Get (or create) DataUrl
    #

    # TODO should this search function go elsewhere?
    if not dataUrl:
        for tmpDataUrl in dataLocationStore.dataUrls:
            if tmpDataUrl.url.dataLocation == dataUrlPath:
                dataUrl = tmpDataUrl

        if not dataUrl:
            dataUrlPath = uniIo.normalisePath(dataUrlPath)
            dataUrl = dataLocationStore.newDataUrl(url=Implementation.Url(
                path=dataUrlPath))

    #
    # Create a BlockedBinaryMatrix. TODO: could be other classes that are set up this way - rename func and make general,, pass in class?
    #
    localPath = uniIo.normalisePath(localPath)
    blockedBinaryMatrix = dataLocationStore.newBlockedBinaryMatrix(
        path=localPath, dataUrl=dataUrl)
    """
  TODO Set here as well, or do this later after returning object:

blockSizes      Int      0..*     Block sizes in dimension order  
complexStoredBy   ComplexStorage   1..1   The ordering of real and imaginary parts of hypercomplex numbers in the data matrix. See ComplexStorage type for details  
hasBlockPadding   Boolean   1..1   Are data padded to fill all blocks completely? Alternatively incomplete blocks store only the actual data.  
headerSize   Int   1..1   Header size in bytes  
isBigEndian   Boolean   1..1   Are data big-endian (alternative little-endian).  
isComplex   Boolean   0..*   Are numbers complex (if True) or real/integer (if False).  
nByte   Int   1..1   Number of bytes per number  
numPoints   Int   0..*   number of points for each matrix dimension - also defines dimensionality of matrix. The number of points is the same for real or complex data, in the sense that n complex points require 2n real numbers for storage.  
numRecords   Int   1..1   Number of matrix records in file. All other information in the object describes a single record.  
numberType   NumberType   1..1   Type of numbers held in matrix  
  
  """

    dataSource.dataStore = blockedBinaryMatrix

    return blockedBinaryMatrix
    def setCcpnProjectRepository(self,ccpnDir = 'ccpn'):

        # Replaces setCcpnProjectPaths
        outputPath = os.path.join(self.entryDir,ccpnDir)

        # In new API have to make sure that old files are removed first!
        if os.path.exists(outputPath):
          shutil.rmtree(outputPath)

        repository = self.ccpnProject.findFirstRepository(name = 'userData')
        repository.url = Implementation.Url(path = outputPath)
Exemple #16
0
def saveTemporaryChemCompOrCoord(chemCompOrCoord,testMode = True, isFresh = False):

  """
  Saves the XML for a chemComp(Coord) object to a temporary directory.
  
  testMode          If False, will use archive/, otherwise will use test/ for existingFilePath.  
  isFresh           If False, will remove tag that indicates chemComp(Coord) generated from scratch
                    If True, will set the tag.
  """
  
  #
  # Set/remove tag that indicates whether chemComp is newly generated or not
  #

  if isFresh:
    tagAsFresh(chemCompOrCoord)
  else:
    removeFreshTag(chemCompOrCoord)


  if chemCompOrCoord.className == 'ChemCompCoord':
    className = 'ChemCompCoord'
  else:
    className = 'ChemComp'
  
  tempRepositoryName = 'temporaryChemComp'
  tempRepository = chemCompOrCoord.root.findFirstRepository(name = tempRepositoryName)
  
  if not tempRepository:
    tempRepository = chemCompOrCoord.root.newRepository(name= tempRepositoryName, 
                                                        url=Implementation.Url(path=tempChemCompDir))

  curStdOut = sys.stdout
  textPipe = TextPipe([])
  sys.stdout = textPipe
  chemCompOrCoord.saveTo(tempRepository)
  sys.stdout = curStdOut
  #sys.stdout = sys.__stdout__
  
  print
  print "  *** CCPN save output ***"
  for text in textPipe.textArea:
    if text.strip():
      print "    %s" % text.strip()
  print
  
  # This was failing horribly in large runs, now fixed (Wim 2010/03/08)
  filePath = glob.glob(os.path.join(tempRepository.url.path,'ccp','molecule',className,"*%s*%s*.xml" % (chemCompOrCoord.molType,getCcpFileString(chemCompOrCoord.ccpCode))))[0]
  
  (localPath,localFileName) = os.path.split(filePath)
    
  existingFilePath = findChemCompOrCoordFilePath(chemCompOrCoord, testMode = testMode)
  
  return (filePath,existingFilePath)
Exemple #17
0
def convertStar2Ccpn(projectName, rootDir, inputDir="XPLOR", outputDir="CCPN"):
    """The structure when done will be:

    rootDir -> -> inputDir -> xxxx.pdb etc.
               -> outputDir -> xxxx -> ccp etc.
               -> xxxx.tgz (the resulting CCPN data)

    E.g.
    taf3Piscataway -> Authors ->  all.pdb etc.
                   -> Nijmegen -> taf3Piscataway -> ccp etc.
                   -> taf3Piscataway.tgz

    Or in iCingSetup the rootDir is eg: /Library/WebServer/Documents/tmp/cing/ano/WjtXOz
    with project name gb1

    WjtXOz -> XPLOR  -> gb1.pdb etc.
           -> CCPN   -> gb1 -> ccpn etc.
           -> gb1.tgz


    The in and out paths are relative to the rootDir.
            """

    nTerror("This routine is untested and shouldn't be used without.")
    inputDir = os.path.join(rootDir, inputDir)
    outputDir = os.path.join(rootDir, outputDir)

    if not os.path.exists(inputDir):
        nTerror("Failed to find")
    if os.path.exists(outputDir):
        shutil.rmtree(outputDir)

    os.mkdir(outputDir)
    os.chdir(outputDir)

    ccpnProjectPath = os.path.join(outputDir, projectName)
    if os.path.exists(ccpnProjectPath):
        shutil.rmtree(ccpnProjectPath)

    project = Implementation.MemopsRoot(name=projectName)

    guiRoot = Tkinter.Tk()  #  headless possible?
    importStarChemicalShifts(project,
                             inputDir,
                             guiRoot,
                             allowPopups=0,
                             minimalPrompts=1,
                             verbose=0)
    project.saveModified()
    tgzFileName = "../" + projectName + ".tgz"
    cmd = "tar -czf %s %s" % (tgzFileName, projectName)
    do_cmd(cmd)
    guiRoot.destroy()
Exemple #18
0
def newProject(projectName, path=None, removeExisting=False, showYesNo=None):
    """
  Create, and return, a new project using a specified path (directory).
  If path is not specified it takes the current working directory.
  The path can be either absolute or relative.
  The 'userData' repository is pointed to the path.
  The 'backup' repository is pointed to the path + '_backup'.
  If either of these paths already exist (either as files or as directories):
    If removeExisting:
      Delete the path
    Else if showYesNo:
      Ask the user if it is ok to delete the path
      If yes, delete.  If no return None.
    Else:
      Raise an IOError
  """

    # relies on knowing that repositories to move have these names, and these values for path suffix
    repositoryNameMap = {'userData': '', 'backup': '_backup'}

    if not path:
        path = os.getcwd()

    for name in repositoryNameMap.keys():
        fullPath = joinPath(path, projectName) + repositoryNameMap[name]
        answer = checkRemoveIfExists(fullPath, removeExisting, showYesNo)
        if answer is None:
            return None

    project = Implementation.MemopsRoot(name=projectName)

    for name in repositoryNameMap.keys():
        fullPath = normalisePath(joinPath(path, projectName) +
                                 repositoryNameMap[name],
                                 makeAbsolute=True)
        repository = project.findFirstRepository(name=name)
        repository.url = Implementation.Url(path=fullPath)

    return project
Exemple #19
0
def majorUpgradeToCurrent(oldRoot,
                          oldVersionStr,
                          newName=None,
                          newDir=None,
                          oldTags=None,
                          doSave=True):
    """
  Do major upgrade of oldRoot tree to current version.
  NB oldRoot tree must be all loaded in memory
  """

    if oldVersionStr == currentVersionStr:
        return oldRoot

    from memops.api import Implementation

    # make new project and move old directory if necessary
    oldName = oldRoot.name
    if newName is None:
        newName = oldName

    newRoot = Implementation.MemopsRoot(name=newName)

    if newDir is None:
        newPath = getDataDir(oldRoot, oldVersionStr)
    else:
        newPath = uniIo.normalisePath((os.path.join(newDir, newName)),
                                      makeAbsolute=True)
    newRoot.packageLocator.findFirstRepository().url = (Implementation.Url(
        path=newPath))
    newRoot.findFirstRepository(name='backup').url = (Implementation.Url(
        path=newPath + '_backup'))

    upgrader = DataUpgrader(oldVersionStr, newRoot, oldRoot, oldTags=oldTags)

    # make upgrade
    return upgrader.majorUpgrade(doSave=doSave)
Exemple #20
0
def resetPackageLocators(project):

    carbDataPath = uniIo.normalisePath(
        os.path.join(os.path.abspath('..'), 'data'))

    print 'Location of local carbohydrate ChemComps: [%s]' % carbDataPath

    carbDataUrl = Implementation.Url(path=carbDataPath)

    carbDataRepos = project.newRepository(name='carbData', url=carbDataUrl)

    chemPackLoc = project.findFirstPackageLocator(
        targetName='ccp.molecule.ChemComp')

    chemPackLoc.addRepository(carbDataRepos)
Exemple #21
0
  def newProject(self):

    if self.project:
      # Project already present
      if not self.closeProject():
        # If we don't close the current project do nothing
        return

    name = askString(title='Project name', prompt='Enter project name:',parent=self)

    if name:
      # Make the API Project object
      project = Implementation.MemopsRoot(name=name)
      nmrProject = project.newNmrProject(name = project.name)
      self.initProject(project)
Exemple #22
0
def changeDataStoreUrl(dataStore, newPath):
    """ Change the url for this dataStore, so at the end we have
  dataStore.dataUrl.url.path = newPath.  This changes all dataUrls
  with the same old path if the old path does not exist and the
  new one does.
  """

    newPath = uniIo.normalisePath(newPath, makeAbsolute=True)
    oldDataUrl = dataStore.dataUrl
    oldUrl = oldDataUrl.url
    oldPath = oldUrl.dataLocation
    oldExists = os.path.exists(oldPath)
    if newPath != oldPath:
        dataLocationStore = dataStore.dataLocationStore
        newUrl = Implementation.Url(
            path=newPath)  # TBD: should use oldUrl.clone(path=newPath)

        # first check if have a dataUrl with this path
        newDataUrl = dataLocationStore.findFirstDataUrl(url=newUrl)
        if not newDataUrl:
            # if old path exists and there is more than one dataStore with
            # this dataUrl then create new one
            dataUrlStores = dataLocationStore.findAllDataStores(
                dataUrl=oldDataUrl)
            if oldExists and len(dataUrlStores) > 1:
                newDataUrl = dataLocationStore.newDataUrl(name=oldDataUrl.name,
                                                          url=newUrl)

        # if have found or have created newDataUrl then set dataStore to point to it
        # else just change url of oldDataUrl (which could affect other dataStores)
        if newDataUrl:
            dataStore.dataUrl = newDataUrl
        else:
            oldDataUrl.url = newUrl

        # if old path does not exist and new path exists then change urls of
        # all data urls which have old path to new path (there might be none)
        if not oldExists:
            newExists = os.path.exists(newPath)
            if newExists:
                for dataUrl in dataLocationStore.dataUrls:
                    if dataUrl.url == oldUrl:
                        dataUrl.url = newUrl
Exemple #23
0
def convertCyana2Ccpn(projectName, rootDir):
    guiRoot = Tkinter.Tk()
    datasetDir = os.path.join(rootDir, projectName)
    nijmegenDir = os.path.join(datasetDir, "Nijmegen")
    authorDir = os.path.join(datasetDir, "Authors")
    os.chdir(nijmegenDir)

    projectPath = os.path.join(nijmegenDir, projectName)
    if os.path.exists(projectPath):
        shutil.rmtree(projectPath)

    project = Implementation.MemopsRoot(name=projectName)

    importCyanaCoorAndRes(project, authorDir, guiRoot)
    project.saveModified()
    tgzFileName = "../" + projectName + ".tgz"
    cmd = "tar -czf %s %s" % (tgzFileName, projectName)
    do_cmd(cmd)
    guiRoot.destroy()
Exemple #24
0
  def updateTensor(self, aAxial=None, aRhombic=None, alpha=None, beta=None, gamma=None):
  
    aAxial   = aAxial   or self.tensor.aAxial
    aRhombic = aRhombic or self.tensor.aRhombic
    alpha    = alpha    or self.tensor.alpha
    beta     = beta     or self.tensor.beta
    gamma    = gamma    or self.tensor.gamma
    
    tensor = Implementation.SymmTracelessMatrix(aAxial=aAxial,
                                                aRhombic=aRhombic,
                                                alpha=alpha,beta=beta,
                                                gamma=gamma)
 
    if self.alignMedium:
      if self.tensor is self.alignMedium.dynamicAlignment:
        self.alignMedium.dynamicAlignment = tensor
        
      elif self.tensor is self.alignMedium.staticAlignment:
        self.alignMedium.staticAlignment = tensor
 
    self.tensor = tensor
Exemple #25
0
  def createShift(self,resonance,chemShift):
    
    #
    # For xeasy also use chemShift to create atomSerial application data.
    #
    # Warning: if there is already an atomSerial available for this resonance
    # it will be overwritten!!
    #
    
    applData = resonance.findFirstApplicationData(application = self.format, keyword = self.atomSerialKeyword)

    if applData:
      resonance.removeApplicationData(applData)
    
    resonance.addApplicationData(Implementation.AppDataInt(application = self.format, keyword = self.atomSerialKeyword, value = chemShift.atomSerial))
    
    #
    # Create shift linked to resonance
    #

    return Nmr.Shift(self.measurementList, value = chemShift.value, error = chemShift.valueError, resonance = resonance)
Exemple #26
0
    def setupProject(self, fileName, projectName):

        self.projectFileName = fileName

        try:
            self.ccpnProject = XmlIO.loadProjectFile(fileName)
            print "Read existing CCPN project..."

        except:
            print "Creating new CCPN project..."

            projectName = returnMemopsWord(projectName)
            self.ccpnMemopsRoot = Implementation.MemopsRoot(name=projectName)
            self.nmrProject = Nmr.NmrProject(self.ccpnProject,
                                             name=self.ccpnProject.name)

            #
            # Set the location...
            #

            (path, file) = splitPath(fileName)
            self.ccpnProject.path = file
            self.ccpnProject.url.path = path

            outputPath = os.path.join(path, projectName)

            try:
                os.stat(outputPath)
            except:
                os.mkdir(outputPath)

            for url in self.ccpnProject.urls:
                if url != self.ccpnProject.url:
                    url.path = outputPath

        # TODO: check name of project: if not same CRASH OUT!

        return self.ccpnProject
Exemple #27
0
def getDataStoringFromFilepath(memopsRoot,
                               fullFilePath,
                               preferDataUrls=None,
                               dataLocationStore=None,
                               keepDirectories=1):

    # make absolute,, normalised path
    fullFilePath = uniIo.normalisePath(fullFilePath, makeAbsolute=True)

    dataUrl, filePath = findDataStoringFromFilepath(memopsRoot, fullFilePath,
                                                    preferDataUrls,
                                                    dataLocationStore,
                                                    keepDirectories)

    if dataUrl is None:

        urlPath = uniIo.normalisePath((fullFilePath[:-len(filePath)]))
        dataLocationStore = memopsRoot.currentDataLocationStore
        dataUrl = dataLocationStore.newDataUrl(url=Implementation.Url(
            path=urlPath))
        dataUrl.name = 'auto-%s' % dataUrl.serial
    #
    return (dataUrl, filePath)
    def setNmrStarExportInfo(self, importFormatName):

        resonances = self.formatConversion.getFormatClass(
            importFormatName).newResonances

        #
        # Copy over original assignment info for NMR-STAR export!
        #

        for resonance in resonances:
            for appData in resonance.findAllApplicationData(
                    application=importFormatName):
                newAppData = None
                if appData.keyword == 'assign':
                    newAppData = Implementation.AppDataString(
                        application='nmrStar',
                        keyword='origAssign',
                        value=appData.value)
                elif appData.keyword == 'origResLabel':
                    newAppData = appData

                if newAppData:
                    resonance.addApplicationData(newAppData)
Exemple #29
0
    def __init__(self, parent, project=None, *args, **kw):

        if not project:
            self.project = Implementation.MemopsRoot(
                name='defaultUtilityProject')
        else:
            self.project = project

        self.waiting = False
        self.waitingAtom = False
        self.molType = 'protein'
        self.scheme = None
        self.isotopomer = None
        self.isotopomerV = False  # Not None
        self.ccpCodeV = None
        self.element = 'C'
        self.atomLabelTuple = None
        self.isotopes = [x[0] for x in getSortedIsotopes(self.project, 'C')]
        self.defaultAbun = {}

        BasePopup.__init__(self,
                           parent=parent,
                           title='Molecule : Reference Isotope Schemes',
                           **kw)
Exemple #30
0
    def createShift(self, resonance, chemShift):

        #
        # For xeasy also use chemShift to create atomSerial application data.
        #
        # Warning: if there is already an atomSerial available for this resonance
        # it will be overwritten!!
        #

        applData = resonance.findFirstApplicationData(
            application=self.format, keyword=self.atomSerialKeyword)

        if applData:
            resonance.removeApplicationData(applData)

        resonance.addApplicationData(
            Implementation.AppDataInt(application=self.format,
                                      keyword=self.atomSerialKeyword,
                                      value=chemShift.atomSerial))

        #
        # Create shift linked to resonance - NOTE changed so can read in all atom serials, even if no shift value given!
        #

        if chemShift.value:

            self.convertCount[self.mainCode][1][self.valueCode] += 1
            shift = self.measurementList.newShift(value=chemShift.value,
                                                  error=chemShift.valueError,
                                                  resonance=resonance)

        else:

            shift = None

        return shift