当前位置: 首页>>代码示例>>Python>>正文


Python DbUtils.executeNoResult方法代码示例

本文整理汇总了Python中Utils.DbUtils.DbUtils.executeNoResult方法的典型用法代码示例。如果您正苦于以下问题:Python DbUtils.executeNoResult方法的具体用法?Python DbUtils.executeNoResult怎么用?Python DbUtils.executeNoResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Utils.DbUtils.DbUtils的用法示例。


在下文中一共展示了DbUtils.executeNoResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from Utils.DbUtils import DbUtils [as 别名]
# 或者: from Utils.DbUtils.DbUtils import executeNoResult [as 别名]
class Processing:
    def __init__(self):
        self.DBClient = DbUtils()
        self.sqlBuilder = SQLBuilder()

    def getObjectFromTuple(self, tuple):
        valuesDict = dict(record_id=tuple[0], study=tuple[1], rid=tuple[2], modality=tuple[3],
                          scan_date=tuple[4].strftime("%Y-%m-%d"), scan_time=str(tuple[5]),
                          s_identifier=tuple[6], i_identifier=tuple[7], root_folder=tuple[8], converted_folder=tuple[9], version=tuple[10],
                          processed=tuple[12])
        return ProcessingObject(valuesDict)

    def insertToTable(self, objList):
        for obj in objList:
            self.DBClient.executeNoResult(
                self.sqlBuilder.getSQL_AddNewEntryToProcessingTable(obj.sqlInsert()))

    def insertFromConvertionObj(self, convertionObj):
        convertionValues = convertionObj.getValuesDict()
        convertionValues['modality'] = sc.ProcessingModalityAndPipelineTypePerStudy[convertionObj.study][convertionObj.scan_type]
        convertionValues['root_folder'] = '/'.join(convertionObj.converted_folder.split('/')[0:-2])  # Keeping only the three last elements
        self.insertToTable([ProcessingObject(convertionValues)])

    def getToProcessListPerStudy(self, study):
        toProcessList = self.DBClient.executeAllResults(
            self.sqlBuilder.getSQL_getToBeProcessedFromProcessingTable(study))
        return [self.getObjectFromTuple(t) for t in toProcessList]
开发者ID:sulantha2006,项目名称:Processing_Pipeline,代码行数:29,代码来源:Processing.py

示例2: __init__

# 需要导入模块: from Utils.DbUtils import DbUtils [as 别名]
# 或者: from Utils.DbUtils.DbUtils import executeNoResult [as 别名]
class Sorting:
    def __init__(self):
        self.tableName = 'Sorting'
        self.DBClient = DbUtils()
        self.sqlBuilder = SQLBuilder()

    def getObjectFromTuple(self, tuple):
        valuesDict = dict(record_id=tuple[0], study=tuple[1], rid=tuple[2], scan_type=tuple[3],
                          scan_date=tuple[4].strftime("%Y-%m-%d"), scan_time=str(tuple[5]),
                          s_identifier=tuple[6], i_identifier=tuple[7], file_type=tuple[8], download_folder=tuple[9],
                          raw_folder=tuple[10], moved=tuple[11])
        return SortingObject(valuesDict)

    def insertToTable(self, objList):
        for obj in objList:
            self.DBClient.executeNoResult(
                self.sqlBuilder.getSQL_AddNewEntryToSortingTable(obj.sqlInsert()))

    def getUnmovedFilesPerStudy(self, study):
        unmovedList = self.DBClient.executeAllResults(
            self.sqlBuilder.getSQL_getUnmovedFilesFromSortingTable(study, tuple(sc.ProcessingModalityAndPipelineTypePerStudy[study].keys())))
        return [self.getObjectFromTuple(t) for t in unmovedList]

    def setMovedTrue(self, sortingObj):
        sortingObj.moved = 1
        self.saveObj(sortingObj)

    def saveObj(self, sortingObj):
        self.DBClient.executeNoResult(self.sqlBuilder.getSQL_saveObjSortingTable(sortingObj))
开发者ID:sulantha2006,项目名称:Processing_Pipeline,代码行数:31,代码来源:Sorting.py

示例3: __init__

# 需要导入模块: from Utils.DbUtils import DbUtils [as 别名]
# 或者: from Utils.DbUtils.DbUtils import executeNoResult [as 别名]
class Conversion:
    def __init__(self):
        self.tableName = 'Conversion'
        self.DBClient = DbUtils()
        self.sqlBuilder = SQLBuilder()

    def getObjectFromTuple(self, tuple):
        valuesDict = dict(record_id=tuple[0], study=tuple[1], rid=tuple[2], scan_type=tuple[3],
                          scan_date=tuple[4].strftime("%Y-%m-%d"), scan_time=str(tuple[5]),
                          s_identifier=tuple[6], i_identifier=tuple[7], file_type=tuple[8], raw_folder=tuple[9],
                          converted_folder=tuple[10], version=tuple[11], converted=tuple[12])
        return ConversionObject(valuesDict)

    def insertToTable(self, objList):
        for obj in objList:
            self.DBClient.executeNoResult(
                self.sqlBuilder.getSQL_AddNewEntryToConversionTable(obj.sqlInsert()))

    def get_version(self, sortingObj, versionDict):
        if  sortingObj.study == 'ADNI':
            dl_path = sortingObj.download_folder
            if 'Uniform' in dl_path:
                return 'V2'
            else:
                return versionDict[sc.ProcessingModalityAndPipelineTypePerStudy[sortingObj.study][sortingObj.scan_type]] if sc.ProcessingModalityAndPipelineTypePerStudy[sortingObj.study][sortingObj.scan_type] in versionDict else 'V1'
        else:
            return versionDict[sc.ProcessingModalityAndPipelineTypePerStudy[sortingObj.study][sortingObj.scan_type]] if sc.ProcessingModalityAndPipelineTypePerStudy[sortingObj.study][sortingObj.scan_type] in versionDict else 'V1'


    def insertFromSortingObj(self, sortingObj, versionDict):
        sortingValues = sortingObj.getValuesDict()
        version = self.get_version(sortingObj, versionDict)
        sortingValues['converted_folder'] = '{0}/{1}/{2}/{3}/{4}_{5}_{6}/{7}/converted/final'.format(sc.studyDatabaseRootDict[sortingObj.study],
                                                                        sortingObj.study, sortingObj.scan_type, sortingObj.rid,
                                                                        sortingObj.scan_date, sortingObj.s_identifier, sortingObj.i_identifier, version)
        sortingValues['version'] = version
        sortingValues['converted'] = 0
        self.insertToTable([ConversionObject(sortingValues)])

    def gettoBeConvertedPerStudy(self, study):
        toConvertList = self.DBClient.executeAllResults(
            self.sqlBuilder.getSQL_getToBeConvertedFileFromConversionTable(study))
        return [self.getObjectFromTuple(t) for t in toConvertList]

    def setConvertedTrue(self, convertionObj):
        convertionObj.converted = 1
        self.saveObj(convertionObj)

    def setConvertedFailed(self, convertionObj):
        convertionObj.skip = 1
        self.saveObj(convertionObj)

    def saveObj(self, convertionObj):
        self.DBClient.executeNoResult(self.sqlBuilder.getSQL_saveObjConversionTable(convertionObj))

    def getConvertedListPerStudy(self, study):
        convertedList = self.DBClient.executeAllResults(self.sqlBuilder.getSQL_getAllConvertedFromConvertionTable(study))
        return [self.getObjectFromTuple(t) for t in convertedList]
开发者ID:sulantha2006,项目名称:Processing_Pipeline,代码行数:60,代码来源:Conversion.py

示例4: __init__

# 需要导入模块: from Utils.DbUtils import DbUtils [as 别名]
# 或者: from Utils.DbUtils.DbUtils import executeNoResult [as 别名]
class CoregHandler:
    def __init__(self):
        self.DBClient = DbUtils()

    def requestCoreg(self, study, rid, type, pet_folder, t1_folder, petScanType, t1ScanType, xfm_name):
        regsql = "INSERT IGNORE INTO Coregistration VALUES (Null, '{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', 0, 0, 0, Null)".format(study.upper(), rid,
                                                                                                                         type.upper(),
                                                                                                                         pet_folder,
                                                                                                                         t1_folder, petScanType, t1ScanType, xfm_name)

        self.DBClient.executeNoResult(regsql)
开发者ID:sulantha2006,项目名称:Processing_Pipeline,代码行数:13,代码来源:CoregHandler.py

示例5: __init__

# 需要导入模块: from Utils.DbUtils import DbUtils [as 别名]
# 或者: from Utils.DbUtils.DbUtils import executeNoResult [as 别名]
class QCHandler:
    def __init__(self):
        self.DBClient = DbUtils()

    def requestQC(self, study, modal_table, modal_tableId, qcField, qctype, qcFolder):
        qcsql = "INSERT IGNORE INTO QC VALUES (Null, '{0}', '{1}', '{2}', '{3}', '{4}','{5}' , 0, 0, 0, 0, Null)".format(study.upper(), modal_table,
                                                                                                                         modal_tableId,
                                                                                                                         qcField,
                                                                                                                         qctype, qcFolder)

        self.DBClient.executeNoResult(qcsql)

    def checkQCJobs(self, study, modality):
        sql = "SELECT * FROM {0}_{1}_Pipeline WHERE QC = 1 AND FINISHED = 1".format(study, modality)
        res = self.DBClient.executeAllResults(sql)
        if len(res) < 1:
            return 0
        else:
            for result in res:
                proc_id = result[1]
                setProcessedSQL = "UPDATE Processing SET PROCESSED = 1, QCPASSED = 1 WHERE RECORD_ID = {0}".format(proc_id)
                self.DBClient.executeNoResult(setProcessedSQL)
开发者ID:sulantha2006,项目名称:Processing_Pipeline,代码行数:24,代码来源:QCHandler.py

示例6: __init__

# 需要导入模块: from Utils.DbUtils import DbUtils [as 别名]
# 或者: from Utils.DbUtils.DbUtils import executeNoResult [as 别名]
class QSubJobStatusReporter:
    def __init__(self):
        self.DBClient = DbUtils()
        self.QCHandler = QCHandler()

    def setStatus(self, job, status):
        if job.jobType == 'beast':
            nestedJob = job.job
            table = '{0}_{1}_Pipeline'.format(nestedJob.study, nestedJob.modality)
            table_id = nestedJob.table_id
            if status == 'Success':
                setSql = 'UPDATE {0} SET BEAST_MASK = 1 WHERE RECORD_ID = {1}'.format(table, table_id)
            elif status == 'Fail':
                setSql = 'UPDATE {0} SET BEAST_MASK = -1, BEAST_SKIP = 1 WHERE RECORD_ID = {1}'.format(table, table_id)
            self.DBClient.executeNoResult(setSql)
            if status == 'Fail':
                PipelineLogger.log('manager', 'error','QSUB job Status Failed: - {0} - Processing Table ID : {1} - Modality Table ID : {2}'.format(job.jobType, nestedJob.processing_rid, nestedJob.table_id))

        if job.jobType == 'av45':
            nestedJob = job.job
            table = '{0}_{1}_Pipeline'.format(nestedJob.study, nestedJob.modality)
            table_id = nestedJob.table_id
            if status == 'Success':
                setSql = "UPDATE {0} SET FINISHED = 1, PROC_Failed = Null WHERE RECORD_ID = {1}".format(table, table_id)
                self.requestQC(nestedJob, 'av45')
            elif status == 'Fail':
                setSql = "UPDATE {0} SET PROC_Failed = 'Failed' , SKIP = 1 WHERE RECORD_ID = {1}".format(table, table_id)
            self.DBClient.executeNoResult(setSql)
            if status == 'Fail':
                PipelineLogger.log('manager', 'error','QSUB job Status Failed: - {0} - Processing Table ID : {1} - Modality Table ID : {2}'.format(job.jobType, nestedJob.processing_rid, nestedJob.table_id))

        if job.jobType == 'fdg':
            nestedJob = job.job
            table = '{0}_{1}_Pipeline'.format(nestedJob.study, nestedJob.modality)
            table_id = nestedJob.table_id
            if status == 'Success':
                setSql = "UPDATE {0} SET FINISHED = 1, PROC_Failed = Null WHERE RECORD_ID = {1}".format(table, table_id)
                self.requestQC(nestedJob, 'fdg')
            elif status == 'Fail':
                setSql = "UPDATE {0} SET PROC_Failed = 'Failed' , SKIP = 1 WHERE RECORD_ID = {1}".format(table, table_id)
            self.DBClient.executeNoResult(setSql)
            if status == 'Fail':
                PipelineLogger.log('manager', 'error','QSUB job Status Failed: - {0} - Processing Table ID : {1} - Modality Table ID : {2}'.format(job.jobType, nestedJob.processing_rid, nestedJob.table_id))


    def requestQC(self, processingItemObj, qctype):
        qcFieldDict = dict(civet='QC', beast='BEAST_QC', av45='QC', fdg='QC')
        qcFolderDict = { 'civet' : '{0}/civet'.format(processingItemObj.root_folder),
                         'beast' : '{0}/beast'.format(processingItemObj.root_folder),
                         'av45' : '{0}/processed'.format(processingItemObj.root_folder),
                         'fdg' : '{0}/processed'.format(processingItemObj.root_folder)}
        self.QCHandler.requestQC(processingItemObj.study, '{0}_{1}_Pipeline'.format(processingItemObj.study,
                                                                                    processingItemObj.modality),
                                 processingItemObj.table_id, qcFieldDict[qctype], qctype, qcFolderDict[qctype])
开发者ID:seqian,项目名称:Processing_Pipeline,代码行数:56,代码来源:QSubJobStatusReporter.py

示例7: len

# 需要导入模块: from Utils.DbUtils import DbUtils [as 别名]
# 或者: from Utils.DbUtils.DbUtils import executeNoResult [as 别名]
            res = DBClient.executeAllResults(sql)

            if len(res) > 0:

                if len(DBClient.executeAllResults("SELECT * FROM Auth WHERE USER = '{0}'".format(args.createUser))) > 0:
                    print('User already exists. ')
                    sys.exit(0)

                newpass1 =  getpass.getpass('Enter password for {0} : '.format(args.createUser))
                newpass2 =  getpass.getpass('Re-enter password : '.format(args.createUser))
                if newpass1 == newpass2 :
                    hash_object = hashlib.sha256(newpass1.encode('utf-8'))
                    passHex = hash_object.hexdigest()

                    sqlInsert = "INSERT INTO Auth VALUES (Null, '{0}', 1, '{1}')".format(args.createUser, passHex)
                    DBClient.executeNoResult(sqlInsert)
                else:
                    print('Password mismatch. ')
                    sys.exit(0)

            else:
                print('Not authorized')
                sys.exit(0)

            sys.exit(0)



        elif args.study is not None and args.type is not None and args.user is not None and args.createUser is None:

            passwd = getpass.getpass('Password : ')
开发者ID:sulantha2006,项目名称:Processing_Pipeline,代码行数:33,代码来源:runQC.py

示例8: DbUtils

# 需要导入模块: from Utils.DbUtils import DbUtils [as 别名]
# 或者: from Utils.DbUtils.DbUtils import executeNoResult [as 别名]
from Utils.DbUtils import DbUtils
import shutil


Dbclient = DbUtils()
with open(xfmList, 'r') as inf:
    for line in inf:
        row = line.split(',')
        if row[0].strip() == 'None' or row[2].strip() == 'None' or row[4].strip() == 'None':
            pass
        else:
            study = row[0].split('/')[-1].split('_')[0].upper()
            rid = row[0].split('/')[-1].split('_')[1][2:-2]
            petsid = row[2].split('.')[0].split('_')[-2]
            petiid = row[2].split('.')[0].split('_')[-1]
            t1sid = row[4].split('.')[0].split('_')[-2]
            t1iid = row[4].split('.')[0].split('_')[-1]
            uid = 'PET_{0}_{1}_T1_{2}_{3}'.format(petsid, petiid, t1sid, t1iid)
            path = '{0}/{1}_{2}_{3}.xfm'.format(outputpath, study, rid, uid)
            if petiid.startswith('I') and petsid.startswith('S'):
                print(study, rid, uid, sep=', ')
            else:
                print('PET - {0}'.format(row[2]))

            try:
                shutil.copyfile(row[0], path)
            except Exception as e:
                print('Error copy. {0}'.format(e))

            Dbclient.executeNoResult("INSERT IGNORE INTO MANUAL_XFM VALUES (Null, '{0}', '{1}', '{2}', '{3}')".format(study, rid, uid, path))
开发者ID:sulantha2006,项目名称:Processing_Pipeline,代码行数:32,代码来源:sortManualXFMs.py

示例9: DbUtils

# 需要导入模块: from Utils.DbUtils import DbUtils [as 别名]
# 或者: from Utils.DbUtils.DbUtils import executeNoResult [as 别名]
__author__ = 'sulantha'
from Utils.DbUtils import DbUtils
DBClient = DbUtils()
RIDList = ['4225','4746','4799','4136','4142','4192','4713','4960','4387','0021','4827','4579','4580','4616','4668','4696','4809','4549','4680','5012','5019','4674','4757','4385','4721','4947','4714','4715','4736','4706','4720','4661','4728','4767','4739','4089','4379','0382','4732','0230','4586','4653','4671','4742','4369','4589','4730','4676','4689','4722','4723','4587','4631','4632','4672','4678','4756','4711','4764']

for rid in RIDList:
    sql1 = "DELETE FROM Sorting WHERE RID = {0} AND SCAN_TYPE NOT IN ('AV45', 'FDG')".format(rid)
    DBClient.executeNoResult(sql1)
    sql2 = "DELETE FROM Conversion WHERE RID = {0} AND SCAN_TYPE NOT IN ('AV45', 'FDG')".format(rid)
    DBClient.executeNoResult(sql2)
    sql3 = "SELECT RECORD_ID FROM Processing WHERE RID = {0} AND MODALITY NOT IN ('AV45', 'FDG')".format(rid)
    recs = DBClient.executeAllResults(sql3)
    for rec in recs:
        sql4 = "DELETE FROM ADNI_T1_Pipeline WHERE PROCESSING_TID = {0}".format(rec[0])
        DBClient.executeNoResult(sql4)
    sql5 = "DELETE FROM Processing WHERE RID = {0} AND MODALITY NOT IN ('AV45', 'FDG')".format(rid)
    DBClient.executeNoResult(sql5)
开发者ID:sulantha2006,项目名称:Processing_Pipeline,代码行数:19,代码来源:RemoveEntriesFromDBTables.py

示例10: __init__

# 需要导入模块: from Utils.DbUtils import DbUtils [as 别名]
# 或者: from Utils.DbUtils.DbUtils import executeNoResult [as 别名]
class PipelineHandler:
    def __init__(self):
        self.processingPPDict = {'ADNI':{'V1':{'T1':ADNI_V1_T1(), 'FMRI':ADNI_V1_FMRI(), 'AV45':ADNI_V1_AV45(), 'FDG':ADNI_V1_FDG(), 'AV1451': ADNI_V1_AV1451()},
                                         'V2':{'T1':ADNI_V1_T1(), 'FMRI':ADNI_V1_FMRI(), 'AV45':ADNI_V2_AV45(), 'FDG':ADNI_V2_FDG(), 'AV1451': ADNI_V2_AV1451()}}}
        self.DBClient = DbUtils()
        self.QCH = QCHandler()

    def checkExternalJobs(self, study, modality):
        getExtJobSql = "SELECT * FROM externalWaitingJobs WHERE JOB_ID LIKE '{0}_{1}_%'".format(study, modality)
        extJobs = self.DBClient.executeAllResults(getExtJobSql)
        for job in extJobs:
            jobType = job[0].split('_')[-1]
            reportTable = job[1]
            tableID = job[0].split('_')[2]
            reportField = job[2]
            subjectScanID = job[0].split('_')[3]
            success = 0
            if jobType == 'CIVETRUN':
                if glob.glob('{0}/{1}_{2}_*'.format(PipelineConfig.T1TempDirForCIVETDownload, study, subjectScanID)):
                    getProccessRecSql = "SELECT * FROM Processing WHERE RECORD_ID IN (SELECT PROCESSING_TID FROM {0}_T1_Pipeline WHERE RECORD_ID = {1})".format(study, tableID)
                    processingEntry = self.DBClient.executeAllResults(getProccessRecSql)[0]

                    civetFolder = '{0}/civet'.format(processingEntry[8])

                    if os.path.exists(civetFolder):
                        shutil.rmtree(civetFolder)
                    try:
                        PipelineLogger.log('manager', 'info', 'Copying - {0} -> {1}'.format(glob.glob('{0}/{1}_{2}_*'.format(PipelineConfig.T1TempDirForCIVETDownload, study, subjectScanID))[0], civetFolder))
                        dir_util.copy_tree(glob.glob('{0}/{1}_{2}_*'.format(PipelineConfig.T1TempDirForCIVETDownload, study, subjectScanID))[0], civetFolder)
                        success = 1
                    except:
                        success = 0
                else:
                    continue
            else:
                PipelineLogger.log('manager', 'error', 'Unknown external job type - {}'.format(jobType))

            if success:
                updateSQL = "UPDATE {0} SET {1} = 1 WHERE RECORD_ID = {2}".format(reportTable, reportField, tableID)
                self.DBClient.executeNoResult(updateSQL)

                if jobType == 'CIVETRUN':
                    finishSQL = "UPDATE {0} SET FINISHED = 1 WHERE RECORD_ID = {1}".format(reportTable, tableID)
                    self.DBClient.executeNoResult(finishSQL)
                    modal_table = reportTable
                    modal_tableId = tableID
                    qcField = 'QC'
                    qctype = 'civet'
                    qcFolder = civetFolder
                    self.QCH.requestQC(study, modal_table, modal_tableId, qcField, qctype, qcFolder)


                rmSql = "DELETE FROM externalWaitingJobs WHERE JOB_ID LIKE '{0}_{1}_{2}_{3}_%'".format(study, modality, tableID, subjectScanID)
                self.DBClient.executeNoResult(rmSql)


    def process(self, study, modality):
        os.environ['PATH'] = ':'.join(libpath.PATH)
        os.environ['LD_LIBRARY_PATH'] = ':'.join(libpath.LD_LIBRARY_PATH)
        os.environ['LD_LIBRARYN32_PATH'] = ':'.join(libpath.LD_LIBRARYN32_PATH)
        os.environ['PERL5LIB'] = ':'.join(libpath.PERL5LIB)
        os.environ['MNI_DATAPATH'] = ':'.join(libpath.MNI_DATAPATH)
        os.environ['ROOT'] = ';'.join(libpath.ROOT)
        os.environ['MINC_TOOLKIT_VERSION'] = libpath.MINC_TOOLKIT_VERSION
        os.environ['MINC_COMPRESS'] = libpath.MINC_COMPRESS
        os.environ['MINC_FORCE_V2'] = libpath.MINC_FORCE_V2

        toProcessinModalityPerStudy = self.DBClient.executeAllResults("SELECT * FROM Processing INNER JOIN (SELECT * FROM {0}_{1}_Pipeline WHERE NOT (FINISHED OR SKIP)) as TMP ON Processing.RECORD_ID=TMP.PROCESSING_TID".format(study, modality))
        for processingItem in toProcessinModalityPerStudy:
            version = processingItem[10]
            # Calling on the process .section of given studies and modalities
            self.processingPPDict[study][version][modality].process(processingItem)

        return 0


    def addToPipelineTable(self, processingObj):
        study = processingObj.study
        version = processingObj.version
        modality = processingObj.modality
        r_id = processingObj.record_id

        addToTableDict = dict(T1="INSERT IGNORE INTO {0}_T1_Pipeline VALUES (NULL, {1}, \"{2}\", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL)".format(study, r_id, PipelineConfig.defaultT1config),
                              AV45="INSERT IGNORE INTO {0}_AV45_Pipeline VALUES (NULL, {1}, \"{2}\", '{3}', 0, 0, 0, NULL, NULL)".format(study, r_id, PipelineConfig.defaultAV45config, ''),
                              AV1451="INSERT IGNORE INTO {0}_AV1451_Pipeline VALUES (NULL, {1}, \"{2}\", '{3}', 0, 0, 0, NULL, NULL)".format(study, r_id, PipelineConfig.defaultAV1451config, ''),
                              FDG="INSERT IGNORE INTO {0}_FDG_Pipeline VALUES (NULL, {1}, \"{2}\", '{3}', 0, 0, 0, NULL, NULL)".format(study, r_id, PipelineConfig.defaultFDGconfig, ''),
                              FMRI="INSERT IGNORE INTO {0}_FMRI_Pipeline VALUES (NULL, {1}, \"{2}\", '{3}', 0, 0, 0, NULL, NULL)".format(study, r_id, PipelineConfig.defaultFMRIconfig, 'NIAK_STH_COMESHERE'))

        self.DBClient.executeNoResult(addToTableDict[modality])
开发者ID:sulantha2006,项目名称:Processing_Pipeline,代码行数:91,代码来源:PipelineHandler.py

示例11: __init__

# 需要导入模块: from Utils.DbUtils import DbUtils [as 别名]
# 或者: from Utils.DbUtils.DbUtils import executeNoResult [as 别名]
class ADNI_V1_T1:
    def __init__(self):
        self.DBClient = DbUtils()
        self.QCHandler = QCHandler()

    def process(self, processingItem):
        processingItemObj = ProcessingItemObj(processingItem)

        if processingItemObj.beast_skip and processingItemObj.manual_skip and not processingItemObj.civet:
            self.runCivet(processingItemObj, 'N')
        elif processingItemObj.manual_mask and not processingItemObj.manual_skip and not processingItemObj.civet:
            self.runCivet(processingItemObj, 'M')
        elif processingItemObj.beast_mask == 0 and not processingItemObj.beast_skip and processingItemObj.beast_qc == 0 and not processingItemObj.manual_mask:
            self.runBeast(processingItemObj)
        elif processingItemObj.beast_skip and not processingItemObj.manual_mask and not processingItemObj.manual_skip:
            PipelineLogger.log('manager', 'error', '$$$$$$$$$$$$$$$$$ Manual Mask Requested $$$$$$$$$$$$$$$$$$ - {0}'.format(processingItem))
            pass
        elif processingItemObj.beast_mask == 1 and not processingItemObj.beast_skip and processingItemObj.beast_qc == 1 and not processingItemObj.manual_mask and not processingItemObj.civet:
            self.runCivet(processingItemObj, 'B')
        elif processingItemObj.beast_mask == 1 and not processingItemObj.beast_skip and processingItemObj.beast_qc == 0 and not processingItemObj.manual_mask and not processingItemObj.manual_skip:
            self.requestQC(processingItemObj, 'beast')
        elif processingItemObj.civet == 1 and processingItemObj.civet_qc == 0:
            self.requestQC(processingItemObj, 'civet')
        else:
            if processingItemObj.civet_qc == -1:
                PipelineLogger.log('manager', 'error', 'Civet QC failed. Skipping. - {0}'.format(processingItem))
            PipelineLogger.log('manager', 'error', 'Error handling obj for processing - {0}'.format(processingItem))
            return 0

    def getScanType(self, processingItemObj):
        r = self.DBClient.executeAllResults("SELECT SCAN_TYPE FROM Conversion WHERE STUDY = '{0}' AND RID = '{1}' "
                                        "AND SCAN_DATE = '{2}' AND S_IDENTIFIER = '{3}' "
                                        "AND I_IDENTIFIER = '{4}'".format(processingItemObj.study,
                                                                          processingItemObj.subject_rid,
                                                                          processingItemObj.scan_date,
                                                                          processingItemObj.s_identifier,
                                                                          processingItemObj.i_identifier))
        return r[0][0]

    def checkNative(self, processingItemObj):
        orig_ScanType = self.getScanType(processingItemObj)
        converted_file = '{0}/{1}_{2}{3}{4}{5}_{6}.mnc'.format(processingItemObj.converted_folder, processingItemObj.study,
                                                        processingItemObj.subject_rid, processingItemObj.scan_date.replace('-', ''),
                                                        processingItemObj.s_identifier, processingItemObj.i_identifier,
                                                        orig_ScanType)
        nativeFolder = '{0}/native'.format(processingItemObj.root_folder)
        nativeFileName = '{0}/{1}_{2}{3}{4}{5}_{6}.mnc'.format(nativeFolder, processingItemObj.study,
                                                        processingItemObj.subject_rid, processingItemObj.scan_date.replace('-', ''),
                                                        processingItemObj.s_identifier, processingItemObj.i_identifier,
                                                        processingItemObj.modality.lower())
        if not os.path.exists(nativeFileName):
            try:
                distutils.dir_util.mkpath(nativeFolder)
                shutil.copyfile(converted_file, nativeFileName)
            except Exception as e:
                PipelineLogger.log('manager', 'error', 'Error in creating folders or copying native file. \n {0}'.format(e))
                PipelineLogger.log('manager', 'error', 'Setting to restart conversion. \n {0}'.format(e))
                sql = "UPDATE Conversion SET CONVERTED = 0, SKIP = 0 WHERE S_IDENTIFIER = '{0}' AND I_IDENTIFIER = '{1}'".format(processingItemObj.s_identifier, processingItemObj.i_identifier)
                self.DBClient.executeNoResult(sql)
                return None
        return nativeFileName

    def runBeast(self, processingItemObj):
        nativeFileName = self.checkNative(processingItemObj)
        if not nativeFileName:
            return 0
        beastFolder = '{0}/beast'.format(processingItemObj.root_folder)
        logDir = '{0}/logs'.format(processingItemObj.root_folder)
        PipelineLogger.log('manager', 'info', 'BeAST starting for {0}'.format(nativeFileName))
        PipelineLogger.log('manager', 'info', 'Current working folder : {0}'.format(os.getcwd()))
        try:
            distutils.dir_util.mkpath(logDir)
        except Exception as e:
            PipelineLogger.log('manager', 'error', 'Error in creating log folder \n {0}'.format(e))
            return 0

        id = '{0}{1}{2}{3}'.format(processingItemObj.subject_rid, processingItemObj.scan_date.replace('-', ''), processingItemObj.s_identifier, processingItemObj.i_identifier)
        beastCMD = 'source /opt/minc-toolkit/minc-toolkit-config.sh; Pipelines/ADNI_T1/ADNI_V1_T1_BeAST {0} {1} {2} {3} {4} {5}'.format(id, nativeFileName, beastFolder, logDir, socket.gethostname(), 50500)
        try:
            shutil.rmtree(beastFolder)
        except:
            pass
        try:
            distutils.dir_util.mkpath(beastFolder)
        except Exception as e:
            PipelineLogger.log('manager', 'error', 'Error in creating BeAST folder. \n {0}'.format(e))
            return 0

        PipelineLogger.log('manager', 'debug', 'Command : {0}'.format(beastCMD))
        os.chdir(pc.SourcePath)
        p = subprocess.Popen(beastCMD, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, executable='/bin/bash')
        out, err = p.communicate()
        PipelineLogger.log('manager', 'debug', 'Beast Log Output : \n{0}'.format(out.decode("utf-8")))
        PipelineLogger.log('manager', 'debug', 'Beast Log Err : \n{0}'.format(err.decode("utf-8")))

        QSubJobHandler.submittedJobs[id] = QSubJob(id, '02:00:00', processingItemObj, 'beast')
        return 1

    def runCivet(self, processingItemObj, maskStatus):
        nativeFileName = self.checkNative(processingItemObj)
#.........这里部分代码省略.........
开发者ID:sulantha2006,项目名称:Processing_Pipeline,代码行数:103,代码来源:ADNI_V1_T1.py

示例12: DbUtils

# 需要导入模块: from Utils.DbUtils import DbUtils [as 别名]
# 或者: from Utils.DbUtils.DbUtils import executeNoResult [as 别名]
__author__ = 'Sulantha'

from Utils.DbUtils import DbUtils
import glob, os, sys, fileinput

if __name__ == '__main__':
    DBClient = DbUtils()
    sql1 = "SELECT * FROM Processing WHERE PROCESSED = 1 AND MODALITY ='T1'"
    res = DBClient.executeAllResults(sql1)
    for result in res:
        proc_id = result[0]
        #sql2 = "SELECT * FROM Processing WHERE RECORD_ID = {0}".format(proc_id)
        #process_rec = DBClient.executeAllResults(sql2)[0]

        T1Path = result[8]
        try:
            civet_nl_xfm_name = '{0}/civet/transforms/nonlinear/*nlfit_It.xfm'.format(T1Path)
            civet_nl_xfm_file = glob.glob(civet_nl_xfm_name)[0]

            civet_nl_mnc_name = '{0}/civet/transforms/nonlinear/*nlfit_It_grid_0.mnc'.format(T1Path)
            civet_nl_mnc_file = glob.glob(civet_nl_mnc_name)[0]
            civet_nl_mnc_name_base = os.path.basename(civet_nl_mnc_file)

            for line in fileinput.input(civet_nl_xfm_file, inplace=True):
                if 'Displacement_Volume' in line:
                    line = 'Displacement_Volume = {0};'.format(civet_nl_mnc_name_base)
                sys.stdout.write(line)
        except:
            s = "UPDATE Processing SET QCPASSED = 0 WHERE RECORD_ID = {0}".format(proc_id)
            DBClient.executeNoResult(s)
            print('Files not found - {0} - {1}'.format(proc_id, T1Path))
开发者ID:sulantha2006,项目名称:Processing_Pipeline,代码行数:33,代码来源:fixOldProcNonLinearDisplacementFile.py

示例13: DbUtils

# 需要导入模块: from Utils.DbUtils import DbUtils [as 别名]
# 或者: from Utils.DbUtils.DbUtils import executeNoResult [as 别名]
__author__ = 'sulantha'
from Utils.DbUtils import DbUtils
CSVFile = '/data/data03/sulantha/Downloads/missing_list_preprocessed.csv'
dbc = DbUtils()
with open(CSVFile, 'rU') as csv_file:
    for line in csv_file:
        lin = line.strip()

        rid = lin.split('/')[6]
        print(rid)
        s_id = lin.split('/')[7].split('_')[-2]
        i_id = lin.split('/')[7].split('_')[-1]
        sql = "UPDATE ADNI_AV45_Pipeline SET SKIP = 0, QC = 0, FINISHED = 0, PROC_Failed = NULL, MANUAL_XFM = 'Req_man_reg' WHERE PROCESSING_TID IN (SELECT RECORD_ID FROM Processing WHERE RID = '{0}' AND MODALITY = 'AV45' AND VERSION = 'V2' AND S_IDENTIFIER = '{1}' )".format(rid, s_id)
        dbc.executeNoResult(sql)
开发者ID:sulantha2006,项目名称:Processing_Pipeline,代码行数:16,代码来源:reRunV2ForaListManCoreg.py

示例14: DbUtils

# 需要导入模块: from Utils.DbUtils import DbUtils [as 别名]
# 或者: from Utils.DbUtils.DbUtils import executeNoResult [as 别名]
__author__ = 'sulantha'
import datetime
from Utils.DbUtils import DbUtils
DBClient = DbUtils()
with open('/data/data03/sulantha/Downloads/av45_list.csv', 'r') as file:
    next(file)
    for line in file:
        row = line.split(',')
        rid = row[0]
        date = row[1].strip()
        dateT = datetime.datetime.strptime(date, '%m/%d/%Y')
        dateS = dateT.strftime('%Y-%m-%d')
        findSQL = "SELECT * FROM Processing WHERE RID = {0} AND MODALITY = 'AV45' AND SCAN_DATE = '{1}'".format(rid, dateS)
        res = DBClient.executeAllResults(findSQL)
        print('{0}-{1} {2}'.format(rid, len(res), '############' if len(res) is 0 else '')) if len(res) is 0 else None
        processingSQL = "UPDATE Processing SET SKIP = 0 WHERE RID = {0} AND MODALITY = 'AV45' AND SCAN_DATE = '{1}'".format(rid, dateS)
        DBClient.executeNoResult(processingSQL)



开发者ID:sulantha2006,项目名称:Processing_Pipeline,代码行数:19,代码来源:setProcessForAV45.py

示例15: DbUtils

# 需要导入模块: from Utils.DbUtils import DbUtils [as 别名]
# 或者: from Utils.DbUtils.DbUtils import executeNoResult [as 别名]
import shutil

DBClient = DbUtils()
IID_list = ['I546612', 'I620366', 'I535767', 'I560359', 'I581738']
for iid in IID_list:
    getDataFolderSQL = "SELECT RAW_FOLDER FROM Sorting WHERE I_IDENTIFIER = '{0}'".format(iid)
    res = DBClient.executeAllResults(getDataFolderSQL)
    if len(res) == 0:
        pass
    else:
        rawFolder = res[0][0]
        dataFolder = os.path.abspath(os.path.join(rawFolder, '../'))
        shutil.rmtree(dataFolder)
        print(dataFolder)
    delsql = "DELETE FROM Sorting WHERE I_IDENTIFIER = '{0}'".format(iid)
    DBClient.executeNoResult(delsql)

    delsql = "DELETE FROM Conversion WHERE I_IDENTIFIER = '{0}'".format(iid)
    DBClient.executeNoResult(delsql)

    getProSQL = "SELECT RECORD_ID, STUDY, MODALITY FROM Processing WHERE I_IDENTIFIER = '{0}'".format(iid)
    res2 = DBClient.executeAllResults(getProSQL)
    if len(res2) == 0:
       pass
    else:
        P_ID = res2[0][0]
        study = res2[0][1]
        mod = res2[0][2]
        print(P_ID)
        getPPSQL = "SELECT RECORD_ID FROM {1}_{2}_Pipeline WHERE PROCESSING_TID = '{0}'".format(P_ID, study, mod)
        res3 = DBClient.executeAllResults(getPPSQL)
开发者ID:sulantha2006,项目名称:Processing_Pipeline,代码行数:33,代码来源:PurgeDataByIID.py


注:本文中的Utils.DbUtils.DbUtils.executeNoResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。