Пример #1
0
def runProteinInference(fileList):

    fileListString = ','.join(fileList)
    timeString = time.strftime('%Y%m%d_%H%M', time.localtime(time.time()))
    suffix = 'results_%s.hdf5' % timeString
    if len(fileList) > 1:
        infoStr = 'Starting merged protein inference for %i files'
        resultFile = '%s_merged_%s' % (dataDir.name[:25], suffix)
        logger.log.log(logger.PROCESS, infoStr % len(fileList))
    else:
        infoStr = 'Starting protein inference for %s'
        resultFile = '%s_%s_%s' % (dataDir.name[:25],  Path(fileList[0]).stem, suffix)
        logger.log.log(logger.PROCESS, infoStr % fileListString)

    cwd = os.getcwd()
    os.chdir('proteinInference')

    general = cfg.parameters['general']
    cmdline = 'python proteinInference.py --datadir %s --filelist %s --resultfilename %s' + logFormat
    cmdline += ' --general.fdrthreshold %s '
    cmdline = cmdline % (str(dataDir), fileListString, resultFile, cfg.parameters['logging']['logdir'],
                         cfg.parameters['logging']['loglevel'], cfg.parameters['logging']['screenlevel'],
                         general['fdrthreshold'])

    if quantMeth:
        cmdline += ' --quantmethod_id %s' % quantMeth['meth_id']
    else:
        cmdline += ' --quantmethod_id none'

    logger.log.debug('cmd: %s' % cmdline)
    os.system(cmdline)

    resultPath = dataDir.joinpath(resultFile)
    ret = fetchError(dataDir.joinpath(resultPath.stem + '.error'))
    ret['resultfile'] = resultPath
    ret['suffix'] = suffix
    ret['cmdline'] = cmdline
    if ret['code'] == 0:

        # add in the parameters from pymssafe if successfully ran protein inference
        os.chdir(cwd)
        preCfg = ConfigManager(Path('./preMascot.cfg'))
        hdf = HDF5Results(resultPath)
        hdf.appendOpen()
        hdf.addConfigParameters(preCfg.parameters, 'preMascot', '1 pyMSsafe')
        hdf.close()

        ret = fetchError(dataDir.joinpath(resultPath.stem + '.error'))
        ret['resultfile'] = resultPath
        ret['suffix'] = suffix
        ret['cmdline'] = cmdline

    os.chdir(cwd)
    return ret
Пример #2
0
    def __init__(self):
        modulePath = Path(__file__).parent
        for pth in modulePath.parents:
            configPath = pth.joinpath('QuantMethod.cfg')
            if configPath.exists():
                break

        cfg = ConfigManager(str(configPath))
        self.methodsByName = {}
        self.methodsByID = {}
        for s in cfg.parameters:
            meth = cfg.parameters[s]
            method = {'quantmasses': {}}
            for key in meth:
                if key in ['__name__']:
                    continue
                elif key in ['meth_id', 'batch_id', 'num_isotopes']:
                    method[key] = int(meth[key])
                elif key in ['heavy_isotopes']:
                    method[key] = eval(meth[key])
                elif key in ['hyperplexed', 'xic_only']:
                    if meth[key].lower(
                    ) == 'yes' or meth[key] == '1' or meth[key] == 'True':
                        method[key] = True
                    else:
                        method[key] = False
                else:
                    try:
                        iso = int(key)
                        method['quantmasses'][iso] = eval(meth[key])
                    except ValueError:
                        method[key] = meth[key]

            self.methodsByID[method['meth_id']] = copy.deepcopy(method)
            self.methodsByName[method['meth_name'].upper()] = copy.deepcopy(
                method)
Пример #3
0
                    mys2icorrecteddata[spectrum_id][isotopelabel_id] = s2icorr
            else:
                self.cfg.log.debug('no spectrum_id (%s) for s2i correction ' % spectrum_id)
                for isotopelabel_id, val in data.iteritems():
                    if spectrum_id not in mys2icorrecteddata:
                        mys2icorrecteddata[spectrum_id] = {}
                    mys2icorrecteddata[spectrum_id][isotopelabel_id] = val
        pBar.finish()
        self.s2icorrecteddata = mys2icorrecteddata
        self.cfg.log.info('done performS2Icorrection')
        return mys2icorrecteddata


if __name__ == "__main__":
    logger = 0
    cfg = ConfigManager('./corrects2iquant.cfg')

    try:
        configErr = cfg.evaluateCommandLineArgs(sys.argv)
        dataDir = cfg.parameters['runtime']['datadir']
        # start the logging process
        logParam = cfg.parameters['logging']
        logPath = Path(dataDir.joinpath(logParam['logdir']))
        if not logPath.exists():
            logPath.mkdir(parents=True)
        logFile = logPath.joinpath(logParam['logfile'])
        logger = Logger(logFile, logParam['loglevel'], logParam['screenlevel'], False)
        logger.setLog('corrects2iquant')
        cfg.log = logger.log
        hdf5files = [Path(cfg.parameters['runtime']['datadir'], cfg.parameters['runtime']['filename'])]
        allpeptideratios = {}
Пример #4
0
    finally:
        hdfMascot.close()
        logs.setuplog.info('Closing HDF5')
        hdfMascot.close()
        watch.rec('processing')

        watch.stop()
        logs.setuplog.info('job took %s' % watch.format())
    return


# ########### MAIN ###############
if __name__ == '__main__':
    logs = 0
    # try:
    cfg = ConfigManager('./mascotparser.cfg')
    ret = cfg.evaluateCommandLineArgs(sys.argv)

    try:
        cfg.scalePpmMda()
        dataDir = cfg.parameters['runtime']['datadir']

        logParam = cfg.parameters['logging']
        logPath = Path(dataDir.joinpath(logParam['logdir']))
        if not logPath.exists():
            logPath.mkdir(parents=True)
        logFile = logPath.joinpath(logParam['logfile'])

        logger = Logger(logFile, logParam['loglevel'], logParam['screenlevel'],
                        False)
        logger.setMascotParserLogs()
Пример #5
0
    else:
        # provide command line for pyMSsafe scripts
        argStr = '--datadir %s --filefilter %s* --pid %i --quant %s --general.tolppm %s --general.tolmda %s '
        argStr += '--xic.beforepeak %s --xic.afterpeak %s' + logStr
        argStr = argStr % (direc, file, pID, cfg.parameters['runtime']['quant'], general['tolppm'], general['tolmda'],
                           general['beforepeak'], general['afterpeak'])
    return argStr


if __name__ == '__main__':
    sysPlatform = sys.platform
    if sysPlatform != 'win32':
        raise OSError('Invalid operating system (%s) for running analysis, "win32" needed.' % sysPlatform)

    configPath = './preMascot.cfg'
    cfg = ConfigManager(configPath)
    ret = cfg.evaluateCommandLineArgs(sys.argv)

    pID = os.getpid()
    # instrument = cfg.parameters['runtime']['instrument']

    dataDir = cfg.parameters['runtime']['datadir']
    pyMSsafeAppDir = str(Path('./pyMSsafe').resolve())

    logParam = cfg.parameters['logging']
    logPath = Path(dataDir.joinpath(logParam['logdir']))
    if logPath.exists():
        # clear existing logs for this part of the pipeline
        for log in logPath.glob('*.log'):
            if log.name in ['preMascot.log', 'pyMSsafe.log', 'mgfCreation.log']:
                log.unlink()
Пример #6
0
                                         in_quantification_of_protein=0,
                                         fdr_at_score=fdr_at_score)

                    quantList.append(specQuantDict.copy())
                deltas.append(q['mzdiff'])

        return quantList, deltas


if __name__ == '__main__':
    logger = None
    cfg = None

    installdir = Path(os.path.dirname(__file__))
    confile = installdir / Path('proteininference.cfg')
    cfg = ConfigManager(str(confile))
    ret = cfg.evaluateCommandLineArgs(sys.argv)
    searches = sorted(cfg.parameters['runtime']['filelist'])
    dataDir = cfg.parameters['runtime']['datadir']
    resultfile = dataDir.joinpath(cfg.parameters['runtime']['resultfilename'])

    try:
        # start the logging process
        logParam = cfg.parameters['logging']
        logPath = Path(dataDir.joinpath(logParam['logdir']))
        if not logPath.exists():
            logPath.mkdir(parents=True)
        logFile = logPath.joinpath(logParam['logfile'])

        logger = Logger(logFile, logParam['loglevel'], logParam['screenlevel'],
                        True)
Пример #7
0
                    dict(protein_group_no=protein_group_no,
                         isotopelabel_id=isotopelabel_id,
                         reference_label=str(reference),
                         protein_fold_change=protein_fold_change,
                         lower_confidence_level=lower_confidence_level,
                         upper_confidence_level=upper_confidence_level,
                         sum_quant_signal=sumdata,
                         qssm=qssm,
                         qupm=qupm))

        self.hdf5quantprot.writeProteinQuant(prepareddata)


if __name__ == "__main__":
    logger = 0
    cfg = ConfigManager('./proteinquantification.cfg')
    try:
        configErr = cfg.evaluateCommandLineArgs(sys.argv)
        dataDir = cfg.parameters['runtime']['datadir']
        # start the logging process
        logParam = cfg.parameters['logging']
        logPath = Path(dataDir.joinpath(logParam['logdir']))
        if not logPath.exists():
            logPath.mkdir(parents=True)
        logFile = logPath.joinpath(logParam['logfile'])

        logger = Logger(logFile, logParam['loglevel'], logParam['screenlevel'],
                        False)
        logger.setLog('proteinQuantification')

        cfg.log = logger.log