當前位置: 首頁>>代碼示例>>Python>>正文


Python string.atof方法代碼示例

本文整理匯總了Python中string.atof方法的典型用法代碼示例。如果您正苦於以下問題:Python string.atof方法的具體用法?Python string.atof怎麽用?Python string.atof使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在string的用法示例。


在下文中一共展示了string.atof方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: parse_hmmsearch

# 需要導入模塊: import string [as 別名]
# 或者: from string import atof [as 別名]
def parse_hmmsearch(kingdom, moltype, src):
	# function to parse hmmsearch output
	resu = []
	data = open(src).readlines()
	inds = [-1] + [i for (i, x) in enumerate(data[2]) if x == " "]
	inds = [(inds[j] + 1, inds[j + 1]) for j in range(len(inds) - 1)]
	data = [line for line in data if line[0] != "#"]
	for line in data:
		if not len(line.strip()):
			continue
		[read, acc, tlen, qname, qaccr, qlen, seq_evalue, seq_score, seq_bias,
			seq_num, seq_of, dom_cEvalue, dom_iEvalue, dom_score, dom_bias,
			hmm_start, hmm_end, dom_start, dom_end, env_start, env_end] = line.split()[:21]
		#            [line[x[0]:x[1]].strip() for x in inds[:21]]
		if string.atof(dom_iEvalue) < options.evalue:
			#            resu.append("\t".join([read, acc, tlen, qname, qaccr, \
			#                    qlen, seq_evalue, seq_score, seq_bias, seq_num, seq_of, \
			#                    dom_cEvalue, dom_iEvalue, dom_score, dom_bias, hmm_start, \
			#                    hmm_end, dom_start, dom_end, env_start, env_end]))
			resu.append("\t".join([qname, dom_start, dom_end, read, dom_iEvalue]))

	return resu 
開發者ID:CAMI-challenge,項目名稱:CAMISIM,代碼行數:24,代碼來源:rna_hmm2.py

示例2: parse_hmmsearch

# 需要導入模塊: import string [as 別名]
# 或者: from string import atof [as 別名]
def parse_hmmsearch(kingdom, moltype, src):
	# function to parse hmmsearch output
	resu = []
	data = open(src).readlines()
	# inds = [-1] + [i for (i, x) in enumerate(data[2]) if x == " "]
	# inds = [(inds[j] + 1, inds[j + 1]) for j in range(len(inds) - 1)]
	data = [line for line in data if line[0] != "#"]
	for line in data:
		if not len(line.strip()):
			continue
		[
			read, acc, tlen, qname, qaccr, qlen, seq_evalue, seq_score, seq_bias,
			seq_num, seq_of, dom_cEvalue, dom_iEvalue, dom_score, dom_bias,
			hmm_start, hmm_end, dom_start, dom_end, env_start, env_end] = line.split()[:21]
		# [line[x[0]:x[1]].strip() for x in inds[:21]]
		if string.atof(dom_iEvalue) < options.evalue:
			#            resu.append("\t".join([read, acc, tlen, qname, qaccr, \
			#                    qlen, seq_evalue, seq_score, seq_bias, seq_num, seq_of, \
			#                    dom_cEvalue, dom_iEvalue, dom_score, dom_bias, hmm_start, \
			#                    hmm_end, dom_start, dom_end, env_start, env_end]))
			resu.append("\t".join([qname, dom_start, dom_end, read, dom_iEvalue]))

#    print resu[0]
#    print resu[-1]
	return resu 
開發者ID:CAMI-challenge,項目名稱:CAMISIM,代碼行數:27,代碼來源:rna_hmm3.py

示例3: __init__

# 需要導入模塊: import string [as 別名]
# 或者: from string import atof [as 別名]
def __init__(self):
        """
        初始化方法
        """
        import string
        import threading
        if FilePersistence._init:
            return

        self._lock = threading.Lock()
        self._inspect_results = {}
        self._ob_paths = {}  # 需要觀察路徑下節點變化的路徑列表
        self._touch_paths = {}  # 針對臨時節點,需要不斷touch的路徑列表
        self._base = config.GuardianConfig.get(config.STATE_SERVICE_HOSTS_NAME)
        self._mode = string.atoi(config.GuardianConfig.get("PERSIST_FILE_MODE", FilePersistence._file_mode), 8)
        self._interval = string.atof(config.GuardianConfig.get("PERSIST_FILE_INTERVAL", "0.4"))
        self._timeout = string.atof(config.GuardianConfig.get("PERSIST_FILE_TIMEOUT", "3"))
        if not os.path.exists(self._base):
            os.makedirs(self._base, self._mode)

        self._session_thread = threading.Thread(target=self._thread_run)
        FilePersistence._init = True
        self._session_thread.daemon = True
        self._session_thread.start() 
開發者ID:baidu,項目名稱:ARK,代碼行數:26,代碼來源:persistence.py

示例4: collector_load

# 需要導入模塊: import string [as 別名]
# 或者: from string import atof [as 別名]
def collector_load():
    ''' 
    係統負載信息收集  
    '''
    # 讀取係統負載信息
    load_file = open("/proc/loadavg")
    content = load_file.read().split()
    # content :
    # ['3.69', '1.81', '1.10', '1/577', '20499']
    # 關閉文件
    load_file.close()
    # 生成1分鍾,5分鍾,15分鍾負載對應的字典
    load_avg = {
        "load1": string.atof(content[0]),
        "load5": string.atof(content[1]),
        "load15": string.atof(content[2])
    }
    return load_avg 
開發者ID:MiracleYoung,項目名稱:You-are-Pythonista,代碼行數:20,代碼來源:collect_system_info.py

示例5: __read_residueASA

# 需要導入模塊: import string [as 別名]
# 或者: from string import atof [as 別名]
def __read_residueASA( self ):
        """
        Read solvent accessibility calculated with WHATIF and return array
        of ASA-values. First column is the total ASA, second column the ASA
        of the backbone, the third column is the ASA of the side-chain.

        @return: array (3 x len(residues)) with ASA values
        @rtype: array
        """
        ## [14:-27] skip header and tail lines line

        lines = open(self.f_residueASA).readlines()[14:-27]
        ASA_values = map(lambda line: string.split(line)[-3:], lines)
        ASA_values = N0.array(map(lambda row: map(string.atof, row),
                                 ASA_values))

        return ASA_values 
開發者ID:graik,項目名稱:biskit,代碼行數:19,代碼來源:WhatIf.py

示例6: resSelect

# 需要導入模塊: import string [as 別名]
# 或者: from string import atof [as 別名]
def resSelect(res):
    return res['regex'] or atof(res['time']) 
開發者ID:vulscanteam,項目名稱:vulscan,代碼行數:4,代碼來源:handlejson.py

示例7: test_atof

# 需要導入模塊: import string [as 別名]
# 或者: from string import atof [as 別名]
def test_atof(self):
        self.assertAlmostEqual(string.atof("  1  "), 1.0)
        self.assertRaises(ValueError, string.atof, "  1x ")
        self.assertRaises(ValueError, string.atof, "  x1 ") 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:6,代碼來源:test_string.py

示例8: read_float

# 需要導入模塊: import string [as 別名]
# 或者: from string import atof [as 別名]
def read_float(self, input_file):
        s = string.strip(input_file.readline())
        if self.debug:
            print s
        return string.atof(s) 
開發者ID:PiratesOnlineRewritten,項目名稱:Pirates-Online-Rewritten,代碼行數:7,代碼來源:GameOptions.py

示例9: read_float

# 需要導入模塊: import string [as 別名]
# 或者: from string import atof [as 別名]
def read_float(self, input_file):
        s = string.strip(input_file.readline())
        print s
        return string.atof(s) 
開發者ID:PiratesOnlineRewritten,項目名稱:Pirates-Online-Rewritten,代碼行數:6,代碼來源:WaterPanel.py

示例10: get_stock_now_price

# 需要導入模塊: import string [as 別名]
# 或者: from string import atof [as 別名]
def get_stock_now_price(self, stock_code):
        """
        獲取股票的當前價格
        :param stock_id: 股票id
        :return:
        """
        code = self._code_to_symbol(stock_code)
        data = urllib.urlopen("http://hq.sinajs.cn/list=" + code).read().decode('gb2312')
        stockInfo = data.split(',')
        currentPrice = string.atof(stockInfo[3])
        return float(currentPrice) 
開發者ID:haogefeifei,項目名稱:OdooQuant,代碼行數:13,代碼來源:stock_basics.py

示例11: get_yesterday_price

# 需要導入模塊: import string [as 別名]
# 或者: from string import atof [as 別名]
def get_yesterday_price(self, stock_code):
        """
        獲取股票昨日收盤價格
        :param stock_code:
        :return:
        """
        code = self._code_to_symbol(stock_code)
        data = urllib.urlopen("http://hq.sinajs.cn/list=" + code).read().decode('gb2312')
        stockInfo = data.split(',')
        currentPrice = string.atof(stockInfo[2])
        return float(currentPrice) 
開發者ID:haogefeifei,項目名稱:OdooQuant,代碼行數:13,代碼來源:stock_basics.py

示例12: get_voltage

# 需要導入模塊: import string [as 別名]
# 或者: from string import atof [as 別名]
def get_voltage(self, channel, unit='mV'):
        raw_low, raw_high = string.atof(self.get_voltage_low()), string.atof(self.get_voltage_high())
        if unit == 'raw':
            return raw_low, raw_high
        elif unit == 'V':
            return raw_low, raw_high
        elif unit == 'mV':
            return raw_low * 1000, raw_high * 1000
        else:
            raise TypeError("Invalid unit type.") 
開發者ID:SiLab-Bonn,項目名稱:basil,代碼行數:12,代碼來源:agilent33250a.py

示例13: string_to_float

# 需要導入模塊: import string [as 別名]
# 或者: from string import atof [as 別名]
def string_to_float(string_list):
    '''字符數字轉換成浮點型
    @return: list 
    '''
    return map(lambda x:string.atof(x), string_list) 
開發者ID:Scemoon,項目名稱:lpts,代碼行數:7,代碼來源:utils.py

示例14: line_chart

# 需要導入模塊: import string [as 別名]
# 或者: from string import atof [as 別名]
def line_chart(self, data):
        PATH = lambda p: os.path.abspath(p)
        cpu_data = []
        mem_data = []
        # 去掉cpu占用率中的百分號,並轉換為int型
        for cpu in data[0]:
            cpu_data.append(string.atoi(cpu.split("%")[0]))
        # 去掉內存占用中的單位K,並轉換為int型,以M為單位
        for mem in data[1]:
            mem_data.append(string.atof(mem.split("K")[0])/1024)

        # 橫坐標
        labels = []
        for i in range(1, self.times + 1):
            labels.append(str(i))

        # 自動設置圖表區域寬度
        if self.times <= 50:
            xArea = self.times * 40
        elif 50 < self.times <= 90:
            xArea = self.times * 20
        else:
            xArea = 1800

        c = XYChart(xArea, 800, 0xCCEEFF, 0x000000, 1)
        c.setPlotArea(60, 100, xArea - 100, 650)
        c.addLegend(50, 30, 0, "arialbd.ttf", 15).setBackground(Transparent)

        c.addTitle("cpu and memery info(%s)" %self.pkg_name, "timesbi.ttf", 15).setBackground(0xCCEEFF, 0x000000, glassEffect())
        c.yAxis().setTitle("The numerical", "arialbd.ttf", 12)
        c.xAxis().setTitle("Times", "arialbd.ttf", 12)

        c.xAxis().setLabels(labels)

        # 自動設置X軸步長
        if self.times <= 50:
            step = 1
        else:
            step = self.times / 50 + 1

        c.xAxis().setLabelStep(step)

        layer = c.addLineLayer()
        layer.setLineWidth(2)
        layer.addDataSet(cpu_data, 0xff0000, "cpu(%)")
        layer.addDataSet(mem_data, 0x008800, "mem(M)")

        path = PATH("%s/chart" %os.getcwd())
        if not os.path.isdir(path):
            os.makedirs(path)

        # 圖片保存至腳本當前目錄的chart目錄下
        c.makeChart(PATH("%s/%s.png" %(path, self.utils.timestamp()))) 
開發者ID:gitjayzhen,項目名稱:AppiumTestProject,代碼行數:55,代碼來源:PerformanceCtrl.py


注:本文中的string.atof方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。