本文整理汇总了Python中ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria类的典型用法代码示例。如果您正苦于以下问题:Python SearchCriteria类的具体用法?Python SearchCriteria怎么用?Python SearchCriteria使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SearchCriteria类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process
def process(transaction):
context = transaction.getRegistrationContext().getPersistentMap()
# Get the incoming path of the transaction
incomingPath = transaction.getIncoming().getAbsolutePath()
name = transaction.getIncoming().getName()
key = context.get("RETRY_COUNT")
if (key == None):
key = 1
# Get the name of the incoming file
#name = transaction.getIncoming().getName()
parents = []
identifier = pattern.findall(name)[0]
if isExpected(identifier):
experiment = identifier[1:5]
project = identifier[:5]
parentCode = identifier[:10]
else:
print "The identifier "+identifier+" did not match the pattern Q[A-Z]{4}\d{3}\w{2} or checksum"
search_service = transaction.getSearchService()
sc = SearchCriteria()
sc.addMatchClause(SearchCriteria.MatchClause.createAttributeMatch(SearchCriteria.MatchClauseAttribute.CODE, parentCode))
foundSamples = search_service.searchForSamples(sc)
parentSampleIdentifier = foundSamples[0].getSampleIdentifier()
space = foundSamples[0].getSpace()
sa = transaction.getSampleForUpdate(parentSampleIdentifier)
# register new experiment and sample
existingExperimentIDs = []
existingExperiments = search_service.listExperiments("/" + space + "/" + project)
numberOfExperiments = len(search_service.listExperiments("/" + space + "/" + project)) + 1
for eexp in existingExperiments:
existingExperimentIDs.append(eexp.getExperimentIdentifier())
newExpID = '/' + space + '/' + project + '/' + project + 'E' +str(numberOfExperiments)
while newExpID in existingExperimentIDs:
numberOfExperiments += 1
newExpID = '/' + space + '/' + project + '/' + project + 'E' +str(numberOfExperiments)
newHLATypingExperiment = transaction.createNewExperiment(newExpID, "Q_NGS_HLATYPING")
newHLATypingExperiment.setPropertyValue('Q_CURRENT_STATUS', 'FINISHED')
newHLATypingSample = transaction.createNewSample('/' + space + '/' + 'HLA'+ parentCode, "Q_NGS_HLATYPING")
newHLATypingSample.setParentSampleIdentifiers([sa.getSampleIdentifier()])
newHLATypingSample.setExperiment(newHLATypingExperiment)
# create new dataset
dataSet = transaction.createNewDataSet("Q_NGS_HLATYPING_DATA")
dataSet.setMeasuredData(False)
dataSet.setSample(newHLATypingSample)
transaction.moveFile(incomingPath, dataSet)
示例2: _getChildSamples
def _getChildSamples(parentSampleType, parentSamplePermId, sampleType):
"""Return the samples of given type for specified parent sample."""
# The samples are of type 'sampleType'
searchCriteria = SearchCriteria()
searchCriteria.addMatchClause(
MatchClause.createAttributeMatch(
MatchClauseAttribute.TYPE,
sampleType)
)
# The samples have given parent
expSampleCriteria = SearchCriteria()
expSampleCriteria.addMatchClause(
MatchClause.createAttributeMatch(
MatchClauseAttribute.TYPE,
parentSampleType)
)
expSampleCriteria.addMatchClause(
MatchClause.createAttributeMatch(
MatchClauseAttribute.PERM_ID,
parentSamplePermId)
)
searchCriteria.addSubCriteria(
SearchSubCriteria.createSampleParentCriteria(expSampleCriteria)
)
# Now search
samples = searchService.searchForSamples(searchCriteria)
# Return the samples
return samples
示例3: process
def process(transaction):
context = transaction.getRegistrationContext().getPersistentMap()
# Get the incoming path of the transaction
incomingPath = transaction.getIncoming().getAbsolutePath()
key = context.get("RETRY_COUNT")
if key == None:
key = 1
# Get the name of the incoming file
name = transaction.getIncoming().getName()
nameSplit = name.split("-")
space = nameSplit[0]
project = pPattern.findall(nameSplit[1])[0]
experiment_id = ePattern.findall(nameSplit[2])[0]
sampleCode = nameSplit[-1]
if not experiment_id:
print "The identifier matching the pattern Q\w{4}E\[0-9]+ was not found in the fileName " + name
ss = transaction.getSearchService()
sc = SearchCriteria()
sc.addMatchClause(
SearchCriteria.MatchClause.createAttributeMatch(SearchCriteria.MatchClauseAttribute.CODE, sampleCode)
)
foundSamples = ss.searchForSamples(sc)
samplehit = foundSamples[0]
sample = transaction.getSampleForUpdate(samplehit.getSampleIdentifier())
parents = samplehit.getParentSampleIdentifiers()
parentcodes = []
for parent in parents:
parentcodes.append(parent.split("/")[-1])
parentInfos = "_".join(parentcodes)
experiment = transaction.getExperimentForUpdate("/" + space + "/" + project + "/" + experiment_id)
experiment.setPropertyValue("Q_WF_STATUS", "FINISHED")
endpoint = datetime.datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d %H:%M:%S")
experiment.setPropertyValue("Q_WF_FINISHED_AT", endpoint)
sample.setExperiment(experiment)
# Register files
dataSetRes = transaction.createNewDataSet("Q_WF_NGS_RNAEXPRESSIONANALYSIS_RESULTS")
dataSetRes.setMeasuredData(False)
dataSetLogs = transaction.createNewDataSet("Q_WF_NGS_RNAEXPRESSIONANALYSIS_LOGS")
dataSetLogs.setMeasuredData(False)
dataSetRes.setSample(sample)
dataSetLogs.setSample(sample)
resultsname = incomingPath + "/" + parentInfos + "_workflow_results"
logname = incomingPath + "/" + parentInfos + "_workflow_logs"
os.rename(incomingPath + "/logs", logname)
os.rename(incomingPath + "/result", resultsname)
transaction.moveFile(resultsname, dataSetRes)
transaction.moveFile(logname, dataSetLogs)
示例4: process
def process(transaction):
context = transaction.getRegistrationContext().getPersistentMap()
# Get the incoming path of the transaction
incomingPath = transaction.getIncoming().getAbsolutePath()
search_service = transaction.getSearchService()
key = context.get("RETRY_COUNT")
if (key == None):
key = 1
for name in os.listdir(incomingPath):
identifier = None
searchID = pattern.findall(name)
if isExpected(searchID[0]):
identifier = searchID[0]
project = identifier[:5]
else:
print "The identifier "+identifier+" did not match the pattern Q[A-Z]{4}\d{3}\w{2} or checksum"
sc = SearchCriteria()
sc.addMatchClause(SearchCriteria.MatchClause.createAttributeMatch(SearchCriteria.MatchClauseAttribute.CODE, "MA"+identifier))
foundSamples = search_service.searchForSamples(sc)
sampleIdentifier = foundSamples[0].getSampleIdentifier()
space = foundSamples[0].getSpace()
sa = transaction.getSampleForUpdate(sampleIdentifier)
# create new dataset
dataSet = transaction.createNewDataSet("Q_MA_CHIP_IMAGE")
dataSet.setMeasuredData(False)
dataSet.setSample(sa)
image = os.path.realpath(os.path.join(incomingPath,name))
transaction.moveFile(image, dataSet)
示例5: process
def process(transaction):
context = transaction.getRegistrationContext().getPersistentMap()
# Get the incoming path of the transaction
incomingPath = transaction.getIncoming().getAbsolutePath()
# Get the name of the incoming file
name = transaction.getIncoming().getName()
key = context.get("RETRY_COUNT")
if (key == None):
key = 1
identifier = pattern.findall(name)[0]
code = None
code = identifier[:10]
# Find the test sample
search_service = transaction.getSearchService()
sc = SearchCriteria()
sc.addMatchClause(SearchCriteria.MatchClause.createAttributeMatch(SearchCriteria.MatchClauseAttribute.CODE, code))
foundSamples = search_service.searchForSamples(sc)
sampleIdentifier = foundSamples[0].getSampleIdentifier()
space = foundSamples[0].getSpace()
sa = transaction.getSampleForUpdate(sampleIdentifier)
# create new dataset
dataSet = transaction.createNewDataSet("EXPRESSION_MATRIX")
dataSet.setMeasuredData(False)
dataSet.setSample(sa)
transaction.moveFile(incomingPath, dataSet)
示例6: process
def process(tr, params, tableBuilder):
if "user" in params:
tr.setUserId(params.get("user"))
for sample in params.keySet():
parameters = params.get(sample)
sampleCode = parameters.get("code")
search_service = tr.getSearchService()
sc = SearchCriteria()
sc.addMatchClause(SearchCriteria.MatchClause.createAttributeMatch(SearchCriteria.MatchClauseAttribute.CODE, sampleCode))
foundSamples = search_service.searchForSamples(sc)
if(foundSamples.size() < 1):
proj = parameters.get("project")
space = parameters.get("space")
sampleType = parameters.get("type")
species = parameters.get("species")
sampleId = "/" + space + "/" + sampleCode
sample = tr.createNewSample(sampleId, sampleType)
exp = "/"+space+"/"+proj+"/"+parameters.get("experiment")
exp = tr.getExperiment(exp)
sample.setExperiment(exp)
if parameters.get("Q_SECONDARY_NAME"):
sample.setPropertyValue("Q_SECONDARY_NAME",parameters.get("Q_SECONDARY_NAME"))
if parameters.get("parents"):
sample.setParentSampleIdentifiers(parameters.get("parents"))
if parameters.get("metadata"):
properties = parameters.get("metadata")
for prop in properties.keySet():
sample.setPropertyValue(prop, properties.get(prop))
示例7: process
def process(transaction):
context = transaction.getRegistrationContext().getPersistentMap()
# Get the incoming path of the transaction
incomingPath = transaction.getIncoming().getAbsolutePath()
key = context.get("RETRY_COUNT")
if key == None:
key = 1
# Get the name of the incoming file
name = transaction.getIncoming().getName()
identifier = pattern.findall(name)[0]
if isExpected(identifier):
project = identifier[:5]
# parentCode = identifier[:10]
else:
print "The identifier " + identifier + " did not match the pattern Q[A-Z]{4}\d{3}\w{2} or checksum"
search_service = transaction.getSearchService()
sc = SearchCriteria()
sc.addMatchClause(
SearchCriteria.MatchClause.createAttributeMatch(SearchCriteria.MatchClauseAttribute.CODE, identifier)
)
foundSamples = search_service.searchForSamples(sc)
sampleIdentifier = foundSamples[0].getSampleIdentifier()
space = foundSamples[0].getSpace()
sa = transaction.getSampleForUpdate(sampleIdentifier)
# numberOfExperiments = len(search_service.listExperiments("/" + space + "/" + project)) + 1
# newVariantCallingExperiment = transaction.createNewExperiment('/' + space + '/' + project + '/' + project + 'E' + str(numberOfExperiments), "Q_NGS_VARIANT_CALLING")
# newVariantCallingSample = transaction.createNewSample('/' + space + '/' + 'VC'+ parentCode, "Q_NGS_VARIANT_CALLING")
# newVariantCallingSample.setParentSampleIdentifiers([sa.getSampleIdentifier()])
# newVariantCallingSample.setExperiment(newVariantCallingExperiment)
# create new dataset
dataSet = transaction.createNewDataSet("FEATUREXML")
dataSet.setMeasuredData(False)
dataSet.setSample(sa)
# cegat = False
f = "source_dropbox.txt"
sourceLabFile = open(os.path.join(incomingPath, f))
sourceLab = sourceLabFile.readline().strip()
sourceLabFile.close()
# if sourceLab == 'dmcegat':
# cegat = True
os.remove(os.path.realpath(os.path.join(incomingPath, f)))
for f in os.listdir(incomingPath):
if ".testorig" in f:
os.remove(os.path.realpath(os.path.join(incomingPath, f)))
# elif f.endswith('vcf') and cegat:
# secondaryName = f.split('_')[0]
# entitySample = transaction.getSampleForUpdate('/%s/%s' % (space,parentCode))
# sa.setPropertyValue('Q_SECONDARY_NAME', secondaryName)
transaction.moveFile(incomingPath, dataSet)
示例8: process
def process(transaction):
context = transaction.getRegistrationContext().getPersistentMap()
# Get the incoming path of the transaction
incomingPath = transaction.getIncoming().getAbsolutePath()
key = context.get("RETRY_COUNT")
if (key == None):
key = 1
# Get the name of the incoming file
name = transaction.getIncoming().getName()
identifier = pattern.findall(name)[0]
if isExpected(identifier):
project = identifier[:5]
parentCode = identifier[:10]
else:
print "The identifier "+identifier+" did not match the pattern Q[A-Z]{4}\d{3}\w{2} or checksum"
search_service = transaction.getSearchService()
sc = SearchCriteria()
sc.addMatchClause(SearchCriteria.MatchClause.createAttributeMatch(SearchCriteria.MatchClauseAttribute.CODE, identifier))
foundSamples = search_service.searchForSamples(sc)
parentSampleIdentifier = foundSamples[0].getSampleIdentifier()
space = foundSamples[0].getSpace()
sa = transaction.getSampleForUpdate(parentSampleIdentifier)
# find or register new experiment
expType = "Q_MS_MEASUREMENT"
msExperiment = None
experiments = search_service.listExperiments("/" + space + "/" + project)
experimentIDs = []
for exp in experiments:
experimentIDs.append(exp.getExperimentIdentifier())
if exp.getExperimentType() == expType:
msExperiment = exp
# no existing experiment for samples of this sample preparation found
if not msExperiment:
expID = experimentIDs[0]
i = 0
while expID in experimentIDs:
i += 1
expNum = len(experiments) + i
expID = '/' + space + '/' + project + '/' + project + 'E' + str(expNum)
msExperiment = transaction.createNewExperiment(expID, expType)
newMSSample = transaction.createNewSample('/' + space + '/' + 'MS'+ parentCode, "Q_MS_RUN")
newMSSample.setParentSampleIdentifiers([sa.getSampleIdentifier()])
newMSSample.setExperiment(msExperiment)
# create new dataset
dataSet = transaction.createNewDataSet("Q_MS_MZML_DATA")
dataSet.setMeasuredData(False)
dataSet.setSample(newMSSample)
transaction.moveFile(incomingPath, dataSet)
示例9: createNewBarcode
def createNewBarcode(project, tr):
search_service = tr.getSearchService()
sc = SearchCriteria()
pc = SearchCriteria()
pc.addMatchClause(SearchCriteria.MatchClause.createAttributeMatch(SearchCriteria.MatchClauseAttribute.PROJECT, project));
sc.addSubCriteria(SearchSubCriteria.createExperimentCriteria(pc))
foundSamples = search_service.searchForSamples(sc)
foundSamplesFilter = [s for s in foundSamples if 'ENTITY' not in s.getCode()]
offset = 0
exists = True
while exists:
# create new barcode
newBarcode = getNextFreeBarcode(project, len(foundSamplesFilter) + len(newTestSamples) + offset)
# check if barcode already exists in database
pc = SearchCriteria()
pc.addMatchClause(SearchCriteria.MatchClause.createAttributeMatch(SearchCriteria.MatchClauseAttribute.CODE, newBarcode))
found = search_service.searchForSamples(pc)
if len(found) == 0:
exists = False
else:
offset += 1
return newBarcode
示例10: aggregate
def aggregate(parameters, tableBuilder):
codes = parameters.get("codes")
tableBuilder.addHeader(CODE)
tableBuilder.addHeader(PARENT)
for code in codes:
sc = SearchCriteria()
sc.addMatchClause(
SearchCriteria.MatchClause.createAttributeMatch(SearchCriteria.MatchClauseAttribute.CODE, code)
)
sample = searchService.searchForSamples(sc)[0]
handleSample(sample, tableBuilder)
示例11: _getDataSetsForSample
def _getDataSetsForSample(sampleIdentifier, dataSetType):
"""Return the dataSet of given type for specified sample."""
# Set search criteria to retrieve the dataSet associated with the sample
searchCriteria = SearchCriteria()
searchCriteria.addMatchClause(
MatchClause.createAttributeMatch(
MatchClauseAttribute.TYPE,
dataSetType)
)
sampleCriteria = SearchCriteria()
sampleCriteria.addMatchClause(
MatchClause.createAttributeMatch(
MatchClauseAttribute.CODE,
sampleIdentifier)
)
searchCriteria.addSubCriteria(
SearchSubCriteria.createSampleCriteria(
sampleCriteria)
)
dataSetList = searchService.searchForDataSets(searchCriteria)
if len(dataSetList) != 1:
[]
# Return the dataSet
return dataSetList
示例12: _getExperimentSample
def _getExperimentSample(collectionPermId, expSamplePermId):
"""Retrieve the experiment sample."""
# Get the experiment sample
sampleCriteria = SearchCriteria()
sampleCriteria.addMatchClause(
MatchClause.createAttributeMatch(
MatchClauseAttribute.PERM_ID,
expSamplePermId)
)
expCriteria = SearchCriteria()
expCriteria.addMatchClause(
MatchClause.createAttributeMatch(
MatchClauseAttribute.PERM_ID,
collectionPermId)
)
# Add the experiment subcriteria
sampleCriteria.addSubCriteria(
SearchSubCriteria.createExperimentCriteria(
expCriteria)
)
# Search
expSampleList = searchService.searchForSamples(sampleCriteria)
if len(expSampleList) != 1:
return None
# Return the experiment sample
return expSampleList[0]
示例13: _getAllTubes
def _getAllTubes(self):
"""
Get all tubes in the experiment. If the specimen is set (self._specimen),
then return only those tubes that belong to it.
Returns [] if none are found.
"""
# Set search criteria to retrieve all tubes in the experiment
# All tubes belong to a virtual tubeset - so the set of tubes in the
# experiment is exactly the same as the set of tubes in the virtual
# tubeset
searchCriteria = SearchCriteria()
searchCriteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.TYPE, self._experimentPrefix + "_TUBE"))
expCriteria = SearchCriteria()
expCriteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.PERM_ID, self._experiment.permId))
searchCriteria.addSubCriteria(SearchSubCriteria.createExperimentCriteria(expCriteria))
tubes = searchService.searchForSamples(searchCriteria)
if len(tubes) == 0:
self._message = "The experiment with code " + \
self._experimentCode + "does not contain tubes."
self._logger.error(self._message)
return tubes
# Check that the specimen matches (if needed)
if self._specimen != "":
tubes = [tube for tube in tubes if \
tube.getPropertyValue(self._experimentPrefix + "_SPECIMEN") == self._specimen]
# Return the (filtered) tubes
return tubes
示例14: isCurrentMSRun
def isCurrentMSRun(tr, parentExpID, msExpID):
search_service = tr.getSearchService()
sc = SearchCriteria()
sc.addMatchClause(
SearchCriteria.MatchClause.createAttributeMatch(SearchCriteria.MatchClauseAttribute.TYPE, "Q_MS_RUN")
)
foundSamples = search_service.searchForSamples(sc)
for samp in foundSamples:
currentMSExp = samp.getExperiment()
if currentMSExp.getExperimentIdentifier() == msExpID:
for parID in samp.getParentSampleIdentifiers():
parExp = tr.getSampleForUpdate(parID).getExperiment().getExperimentIdentifier()
if parExp == parentExpID:
return True
return False
示例15: runs
def runs(self):
"""Return *all* runs in the db.
TODO this is madness!! At least, this should only return
runs in this project.
"""
search = self.transaction.getSearchService()
criteria = SearchCriteria()
criteria.addMatchClause(
SearchCriteria.MatchClause.createAttributeMatch(
SearchCriteria.MatchClauseAttribute.TYPE,
'Q_MS_RUN'
)
)
return search.searchForSamples(criteria)