本文整理汇总了Python中TAMO.seq.Fasta.random_split方法的典型用法代码示例。如果您正苦于以下问题:Python Fasta.random_split方法的具体用法?Python Fasta.random_split怎么用?Python Fasta.random_split使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TAMO.seq.Fasta
的用法示例。
在下文中一共展示了Fasta.random_split方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: from TAMO.seq import Fasta [as 别名]
# 或者: from TAMO.seq.Fasta import random_split [as 别名]
from TAMO.seq import Fasta
fasFile = '/Users/biggus/Documents/James/Writings_Talks/Grants/09_Feb/PrelimData_Grant_Feb09/Clus2_247genes.fas'
oFile1= '/Users/biggus/Documents/James/Writings_Talks/Grants/09_Feb/PrelimData_Grant_Feb09/Clus2_247genes.sample2.fas'
oFile2= '/Users/biggus/Documents/James/Writings_Talks/Grants/09_Feb/PrelimData_Grant_Feb09/Clus2_247genes.test2.fas'
firstDic, secDic = Fasta.random_split(fasFile,0.25)
Fasta.write(firstDic,oFile1)
Fasta.write(secDic,oFile2)
print 'done'
示例2: len
# 需要导入模块: from TAMO.seq import Fasta [as 别名]
# 或者: from TAMO.seq.Fasta import random_split [as 别名]
import sys
import time
from TAMO.seq import Fasta
"""Takes a fastaFilePath and a fraction between 0 and 1. Returns two fasta
files containing random sequences from fastaFilePath split randomly into files
of size 'fraction' and 1-'fraction'. Files named as: fastaFilePath_fraction.Date_Time.fas"""
assert len(sys.argv[1:]) == 2, \
'usage = %s fastaFilePath fraction<0 to 1>' % (sys.argv[0].split('/')[-1])
assert float(sys.argv[2]) <= 1 and float(sys.argv[2]) >= 0, \
'usage = %s fastaFilePath fraction<0 to 1>' % (sys.argv[0].split('/')[-1])
filePath = sys.argv[1]
frac = float(sys.argv[2])
versionID = time.ctime().split(' ')
versionID = '%s%s_%s' % (versionID[1],versionID[2],versionID[3].replace(':','-'))
dict1,dict2 = Fasta.random_split(filePath,frac)
out1 = '%s_%s_%s.fas' % (filePath.split('/')[-1].rstrip('.fas'),frac,versionID)
out2 = '%s_%s_%s.fas' % (filePath.split('/')[-1].rstrip('.fas'),1-frac,versionID)
Fasta.write(dict1,out1,linelen=100)
Fasta.write(dict2,out2,linelen=100)