def main(root): # find or create NmrProject nmrProject = root.findFirstNmrProject() if not nmrProject: nmrProject = root.newNmrProject(name='testNmr') # create experiment, including expDimRefs dd = {} dd['sf'] = (800, 81) dd['isotopeCode'] = ('1H', '15N') experiment = createExperiment(nmrProject, name='testNmr', numDim=2, expDimRefDict=dd) # set refExperiment setRefExperiment(experiment, expPrototypeSynonym='15N HSQC/HMQC') # create dataSource, including freqDataDims and dataDimRefs dd = {} dd['isComplex'] = (False, False) dd['numPoints'] = (2048, 1024) dd['numPointsOrig'] = (2048, 1024) dd['valuePerPoint'] = (3.93, 0.99) dd['refPoint'] = (1024, 512) dd['refValue'] = (4.72, 117.4) dataSource = createDataSource(experiment, name='testSpec', numDim=2, dataDimDict=dd) # create peakList peakList = dataSource.newPeakList() # create dataLocationStore dataLocationStore = root.findFirstDataLocationStore() if not dataLocationStore: dataLocationStore = root.newDataLocationStore(name='testStore') # create dataStore from memops.api.Implementation import Url dd = {} dd['path'] = 'myHsqcData.spc' dd['dataUrl'] = dataLocationStore.newDataUrl(url=Url( path='/usr/myaccount/mydata')) dd['blockSizes'] = (256, 128) dd['headerSize'] = 0 dd['isBigEndian'] = True dd['isComplex'] = (False, False) dd['nByte'] = 4 dd['numPoints'] = [ dataDim.numPoints for dataDim in dataSource.sortedDataDims() ] dd['numberType'] = 'float' dataStore = dataLocationStore.newBlockedBinaryMatrix(**dd) dataSource.dataStore = dataStore root.saveModified()
def fixImplementation(topObj, delayDataDict): """ Add generalData repository, packageLocator for AnalysisProfile with repositories link, and set NB when this is called PAckageLocators and Repositories have already had their child links and crosslinks set. """ from memops.universal import Io as uniIo from memops.api.Implementation import Url import os.path emptyDict = {} emptyList = [] doGet = delayDataDict.get urlPath = uniIo.normalisePath(os.path.expanduser('~/.ccpn/data')) repositories = doGet(topObj).get('repositories') for refData in repositories: if refData.name == 'refData': break else: raise ApiError("refData repository not found") genData = topObj.newRepository(name='generalData', url=Url(path=urlPath)) topObj.__dict__['repositories']['generalData'] = genData profileLocator = topObj.newPackageLocator(targetName='ccpnmr.AnalysisProfile', repositories=(genData, refData)) topObj.__dict__['packageLocators']['ccpnmr.AnalysisProfile'] = profileLocator
def saveProject(project, name='test', subDir='data'): # Find the backup repository and set the right path for it. backupRepos = project.findFirstRepository(name='backup') backupPath = uniIo.joinPath(os.getcwd(), subDir, name + '_backup') # Create a URL for the backup repository. backupRepos.url = Url(path=backupPath) # Do the same for the repository containing the data in the project. projectRepos = project.findFirstRepository(name='userData') newPath = uniIo.joinPath(os.getcwd(), subDir, name) # And also for the URL of this data. projectRepos.url = Url(path=newPath) # This saves the project to the path specified by the URL for the # 'userData' repository. project.saveModified()
def setRepositoryPath(project, repositoryName, path): from memops.api.Implementation import Url repository = project.findFirstRepository(name=repositoryName) if repository: if path != repository.url.path: # TBD: should we copy anything over from old url? url = Url(path=normalisePath(path)) repository.url = url
def setDir(self): directory = self.dir_entry.get() if not directory: showWarning('No directory', 'No directory specified, not setting backup directory', parent=self) return if not os.path.abspath(directory): directory = joinPath(os.getcwd(), directory) if os.path.exists(directory): if not os.path.isdir(directory): showWarning('Path not directory', 'Path "%s" exists but is not a directory' % directory, parent=self) return else: if showYesNo( 'Directory does not exist', 'Directory "%s" does not exist, should it be created?' % directory, parent=self): os.mkdir(directory) else: showWarning( 'Directory not created', 'Directory "%s" not created so not setting backup directory' % directory, parent=self) return repository = self.project.findFirstRepository(name='backup') if not repository: showWarning( 'No backup repository', 'No backup repository found (something wrong somewhere)', parent=self) return url = repository.url if url.path != directory: repository.url = Url(path=normalisePath(directory))
fp.write('refpt %5.4f\n' % self.refpt[i]) fp.write('nuc %s\n' % self.nuc[i]) if self.pointValues[i]: fp.write('params') for value in self.pointValues[i]: fp.write(' %5.4f' % value) fp.write('\n') fp.close() if (__name__ == '__main__'): import sys if (len(sys.argv) != 2): print 'Error: required argument: <parFile>' sys.exit(1) parFile = sys.argv[1] params = AzaraParams(parFile) from memops.api.Implementation import MemopsRoot, Url from ccp.util.Spectrum import createExperiment r = MemopsRoot() l = r.newDataLocationStore(name='testDLS') d = l.newDataUrl(name='testDataUrl', url=Url(path='/Users/wb104/edl387')) n = r.newNmrProject(name='testNmrProject') e = createExperiment(n, name='testExpt', numDim=params.ndim, sf=params.sf, isotopeCodes=params.nuc) s = params.createDataSource(e, name='testSpectrum', dataUrl=d)
print 'Project: [%s]\n' % project # Find the right repository that contains the project data. projectRepos = project.findFirstRepository(name='userData') # Specify a new location to save the project in. newPath = uniIo.normalisePath( os.path.join(os.path.abspath('.'), 'newDir', 'newSubDir')) # Make a new Url pointing to the new location and link it to the # 'userData' repository. projectRepos.url = Url(path=newPath) # Print the location of all project repositories. print 'Repositories:\n%s' % ('\n'.join( repos.name + ': ' + repos.url.path for repos in project.sortedRepositories())) carbDataPath = uniIo.normalisePath( os.path.join(os.path.abspath('..'), 'data')) print '\nLocation of local carbohydrate ChemComps: [%s]' % carbDataPath carbDataUrl = Url(path=carbDataPath) carbDataRepos = project.newRepository(name='carbData', url=carbDataUrl)