python locale模块_Python locale.atoi方法代码示例

博客展示了Python代码,导入locale模块并使用其atoi函数。定义了unpickleVars函数,将PDB2PQR的实例pickle转换为APBS的字典,根据不同条件设置apbsOptions字典的各项参数,多处使用locale.atoi进行数据处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

# 需要导入模块: import locale [as 别名]

# 或者: from locale import atoi [as 别名]

def unpickleVars(pdb2pqrID):

""" Converts instance pickle from PDB2PQR into a dictionary for APBS """

apbsOptions = {}

#pfile = open("/home/samir/public_html/pdb2pqr/tmp/%s-input.p" % pdb2pqrID, 'r')

pfile = open("%s%s%s/%s-input.p" % (INSTALLDIR, TMPDIR, pdb2pqrID, pdb2pqrID), 'r')

inputObj = pickle.load(pfile)

pfile.close()

myElec = inputObj.elecs[0]

apbsOptions['pqrname'] = pdb2pqrID+'.pqr'

apbsOptions['pdbID'] = inputObj.pqrname[:-4]

if myElec.cgcent[0:3] == "mol":

apbsOptions['coarseGridCenterMethod'] = "molecule"

apbsOptions['coarseGridCenterMoleculeID'] = locale.atoi(myElec.cgcent[4:])

else:

apbsOptions['coarseGridCenterMethod'] = "coordinate"

apbsOptions['coarseGridCenter'] = myElec.cgcent

if myElec.fgcent[0:3] == "mol":

apbsOptions['fineGridCenterMethod'] = "molecule"

apbsOptions['fineGridCenterMoleculeID'] = locale.atoi(myElec.fgcent[4:])

else:

apbsOptions['fineGridCenterMethod'] = "coordinate"

apbsOptions['fineGridCenter'] = myElec.fgcent

if myElec.gcent[0:3] == "mol":

apbsOptions['gridCenterMethod'] = "molecule"

apbsOptions['gridCenterMoleculeID'] = locale.atoi(myElec.gcent[4:])

else:

apbsOptions['gridCenterMethod'] = "coordinate"

apbsOptions['gridCenter'] = myElec.gcent

if myElec.lpbe == 1:

apbsOptions['solveType'] = 'linearized'

elif myElec.npbe == 1:

apbsOptions['solveType'] = 'nonlinearized'

if len(myElec.ion) == 0:

apbsOptions['mobileIonSpecies[0]'] = None

else:

apbsOptions['mobileIonSpecies[1]'] = myElec.ion

if len(myElec.write) <= 1:

apbsOptions['format'] = 'dx'

else:

apbsOptions['format'] = myElec.write[1]

apbsOptions['calculationType'] = myElec.method

apbsOptions['dime'] = myElec.dime

apbsOptions['pdime'] = myElec.pdime

apbsOptions['async'] = myElec.async

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值