예제 #1
0
def search(init_param):
    try:
        Path.Check(init_param['output.path'])
        
        if platform.system() == 'Linux':
            bat_file = os.path.join(init_param['output.path'], 'normal.bash')
            bat_fp = open(bat_file, 'w')
            bat_fp.write('export PATH=%s:$PATH\n' % ClusterSetting.MPIPath) #modified 2012.6.11
            bat_fp.write('export LD_LIBRARY_PATH=%s:$LD_LIBRARY_PATH\n' % ClusterSetting.pLinkBinPath)
        elif platform.system() == 'Windows':
            bat_file = os.path.join(init_param['output.path'], 'normal.bat')
            bat_fp = open(bat_file, 'w')
            bat_fp.write('@echo off\n')
            bat_fp.write('%s\n' % init_param['bin.path'][0:2])
        else:
            raise Exception('search_and_filter', 'unknown platform, only support Windows and Linux')
        
        bat_fp.write('cd "%s"\n' % init_param['bin.path'])
        
        search_mode = string.atoi(init_param['search_mode'])
        pfind_param = Search._ConstructpFindParam(init_param, search_mode, init_param['output.path'])
        print 'Step : Search by Searcher'
        spectra_list = init_param['spectra_list']
        spectra_title = init_param['spectra.title']
        bin_path = init_param['bin.path']
        
        for i in range(0, len(init_param['spectra_list'])):
            pfind_file = os.path.join(init_param['output.path'], '%s%d.pfind' % (init_param['spectra.title'], i+1))
            pfind_result_file = os.path.join(init_param['output.path'], '%s%d_qry.proteins.txt' % (init_param['spectra.title'], i+1))
    
            if os.path.isfile(pfind_result_file):
                print os.path.split(pfind_result_file)[-1] + ' did exist, skip the step';
            else:
                print 'Searcher of '+ spectra_list[i];
                spectrum = []
                spectrum.append(('spec_title', spectra_title+'%d' %(i+1)))
                spectrum.append(('spec_type', '%s' % init_param['spectra.format'].upper()))
                spectrum.append(('spec_path', spectra_list[i]))
                pfind_param['spectrum'] = spectrum
                
                Search._WritepFind(pfind_param, pfind_file, search_mode)
                if platform.system() == 'Windows':
                    bat_fp.write('"%s" "%s"\n' % (os.path.join(bin_path,'Searcher'), pfind_file))
                else:
                    bat_fp.write('"%s" "%s"\n' % (os.path.join(bin_path,'Importer'), pfind_file))
                    if 'mpicores' in init_param:
                        mpicores = init_param['mpicores']
                    else:
                        mpicores = ClusterSetting.DefaultCores
                    if 'mpihosts' in init_param:
                        mpihosts = init_param['mpihosts']
                    else:
                        mpihosts = ClusterSetting.DefaultHosts
                    bat_fp.write('mpirun -np %s -host %s "%s" "%s"\n' %(mpicores, mpihosts, os.path.join(bin_path,'MPISearcher'), pfind_file))
        bat_fp.close()

    except Exception, e:
        print Exception + ": " + e
예제 #2
0
파일: Normal.py 프로젝트: pLinkSS/pLink-SS
def Run(initparam, spectra_list, search_mode, normal_dir_path):
    Path.Check(normal_dir_path)
    bin_path = initparam['bin.path']
    spectra_title = initparam['spectra.title']
    
    if platform.system() == 'Linux':
        bat_file=os.path.join(normal_dir_path,'normal.bash')
        bfile=open(bat_file, 'w')
        bfile.write('export PATH=%s:$PATH\n' % ClusterSetting.MPIPath)#modified 2012.6.11
        bfile.write('export LD_LIBRARY_PATH=%s:$LD_LIBRARY_PATH\n' % ClusterSetting.pLinkBinPath)

    if platform.system() == 'Windows':
        bat_file=os.path.join(normal_dir_path,'normal.bat')
        bfile=open(bat_file, 'w')
        bfile.write('%s\n' % bin_path[0:2])
    
    bfile.write('cd "%s"\n' % bin_path)
    
    pFind_Param = Search._ConstructpFindParam(initparam, search_mode, normal_dir_path)
    print 'Step : Search by Searcher'
    for i in range(0, len(spectra_list)):
        pfind_file = os.path.join(normal_dir_path, spectra_title+'%d.pfind' %(i+1))
        pfind_result_file = os.path.join(normal_dir_path, spectra_title+'%d_qry.proteins.txt' %(i+1));

        if os.path.isfile(pfind_result_file):
            print pfind_result_file + ' is existed , skip the step';
        else:
            print 'Searcher of '+ spectra_list[i];
            spectrum = []
            spectrum.append(('spec_title', spectra_title+'%d' %(i+1)))
            spectrum.append(('spec_type', '%s' %initparam['spectra.format'].upper()))
            spectrum.append(('spec_path', spectra_list[i]))
            pFind_Param['spectrum'] = spectrum
            
            Search._WritepFind(pFind_Param, pfind_file, search_mode)
            if platform.system() == 'Windows':
                bfile.write('"%s" "%s"\n' % (os.path.join(bin_path,'Searcher'), pfind_file))
            else:
                bfile.write('"%s" "%s"\n' % (os.path.join(bin_path,'Importer'), pfind_file))
                if 'mpicores' in initparam:
                    mpicores = initparam['mpicores']
                else:
                    mpicores = ClusterSetting.DefaultCores
                if 'mpihosts' in initparam:
                    mpihosts = initparam['mpihosts']
                else:
                    mpihosts = ClusterSetting.DefaultHosts
                bfile.write('mpirun -np %s -host %s "%s" "%s"\n' %(mpicores, mpihosts, os.path.join(bin_path,'MPISearcher'), pfind_file))
    
    if not "index_content" in initparam:
        initparam["index_content"] = "PEPTIDE_PAIR"
        
    if not 'noninterexport' in initparam:
        initparam['noninterexport'] = 'false'
        
    if 'evalue_max' in initparam and float(initparam['evalue_max']) < 1:#added at 2013.10.22, evalue cut, fan
        bEvalueMax = True
    else:
        bEvalueMax = False        
    
    if initparam['index_content'] != "PEPTIDE_TRI_ALL":
        Filter.RunForType(bfile, 'inter', initparam, spectra_list, normal_dir_path, bEvalueMax)
        
        if initparam['noninterexport'] == 'true':
            Filter.RunForType(bfile, 'loop', initparam, spectra_list, normal_dir_path, bEvalueMax)
            Filter.RunForType(bfile, 'mono', initparam, spectra_list, normal_dir_path, bEvalueMax)
            Filter.RunForType(bfile, 'common', initparam, spectra_list, normal_dir_path, bEvalueMax)
            
    else:
        Filter.RunForTri(bfile, initparam, spectra_list, normal_dir_path, bEvalueMax);

    bfile.close()
    if platform.system() == 'Linux':
        os.system('chmod 766 %s' % bat_file)
        
    os.system('"%s"' % bat_file)
    search_time = os.stat(pfind_result_file).st_mtime

    return search_time