Python string.atof() Examples
The following are 20
code examples of string.atof().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
string
, or try the search function
.
Example #1
Source File: rna_hmm3.py From CAMISIM with Apache License 2.0 | 6 votes |
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
Example #2
Source File: rna_hmm2.py From CAMISIM with Apache License 2.0 | 6 votes |
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
Example #3
Source File: WhatIf.py From biskit with GNU General Public License v3.0 | 6 votes |
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
Example #4
Source File: persistence.py From ARK with MIT License | 6 votes |
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()
Example #5
Source File: collect_system_info.py From You-are-Pythonista with GNU General Public License v3.0 | 6 votes |
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
Example #6
Source File: test_string.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_atof(self): self.assertAlmostEqual(string.atof(" 1 "), 1.0) self.assertRaises(ValueError, string.atof, " 1x ") self.assertRaises(ValueError, string.atof, " x1 ")
Example #7
Source File: utils.py From lpts with GNU General Public License v2.0 | 5 votes |
def string_to_float(string_list): '''字符数字转换成浮点型 @return: list ''' return map(lambda x:string.atof(x), string_list)
Example #8
Source File: test_string.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_atof(self): self.assertAlmostEqual(string.atof(" 1 "), 1.0) self.assertRaises(ValueError, string.atof, " 1x ") self.assertRaises(ValueError, string.atof, " x1 ")
Example #9
Source File: test_string.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_atof(self): self.assertAlmostEqual(string.atof(" 1 "), 1.0) self.assertRaises(ValueError, string.atof, " 1x ") self.assertRaises(ValueError, string.atof, " x1 ")
Example #10
Source File: agilent33250a.py From basil with BSD 3-Clause "New" or "Revised" License | 5 votes |
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.")
Example #11
Source File: test_string.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_atof(self): self.assertAlmostEqual(string.atof(" 1 "), 1.0) self.assertRaises(ValueError, string.atof, " 1x ") self.assertRaises(ValueError, string.atof, " x1 ")
Example #12
Source File: stock_basics.py From OdooQuant with GNU General Public License v3.0 | 5 votes |
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)
Example #13
Source File: stock_basics.py From OdooQuant with GNU General Public License v3.0 | 5 votes |
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)
Example #14
Source File: WaterPanel.py From Pirates-Online-Rewritten with BSD 3-Clause "New" or "Revised" License | 5 votes |
def read_float(self, input_file): s = string.strip(input_file.readline()) print s return string.atof(s)
Example #15
Source File: GameOptions.py From Pirates-Online-Rewritten with BSD 3-Clause "New" or "Revised" License | 5 votes |
def read_float(self, input_file): s = string.strip(input_file.readline()) if self.debug: print s return string.atof(s)
Example #16
Source File: test_string.py From oss-ftp with MIT License | 5 votes |
def test_atof(self): self.assertAlmostEqual(string.atof(" 1 "), 1.0) self.assertRaises(ValueError, string.atof, " 1x ") self.assertRaises(ValueError, string.atof, " x1 ")
Example #17
Source File: test_string.py From BinderFilter with MIT License | 5 votes |
def test_atof(self): self.assertAlmostEqual(string.atof(" 1 "), 1.0) self.assertRaises(ValueError, string.atof, " 1x ") self.assertRaises(ValueError, string.atof, " x1 ")
Example #18
Source File: test_string.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_atof(self): self.assertAlmostEqual(string.atof(" 1 "), 1.0) self.assertRaises(ValueError, string.atof, " 1x ") self.assertRaises(ValueError, string.atof, " x1 ")
Example #19
Source File: handlejson.py From vulscan with MIT License | 5 votes |
def resSelect(res): return res['regex'] or atof(res['time'])
Example #20
Source File: PerformanceCtrl.py From AppiumTestProject with Apache License 2.0 | 4 votes |
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())))