本文整理匯總了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)