當前位置: 首頁>>代碼示例>>Python>>正文


Python Fasta.random_split方法代碼示例

本文整理匯總了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'
開發者ID:xguse,項目名稱:gusPyProj,代碼行數:15,代碼來源:randomSplitFasta.py

示例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)
開發者ID:xguse,項目名稱:gusPyProj,代碼行數:29,代碼來源:getRandPromoters.py


注:本文中的TAMO.seq.Fasta.random_split方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。