当前位置: 首页>>代码示例>>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;未经允许,请勿转载。