[英]Regular Expression Error During Sequence Search
在此先感謝,我正在嘗試從 NCBI 中提取作為分類群 ID 的代碼的最后幾位數字。 我想要這個標簽中的粗體數字,但是這些數字的長度和值是可變的:
標簽: URS0000D94775_60169
代碼:
import re
taxID = ()
#strip accession numbers into string
mount = open ('mount.txrt', 'r')
accessions = (re.findall ("URS\S{6}", mount))
for i in accessions:
taxID.append (i)
#parse taxa id's from string
taxas = ()
taxas.append (re.findall ('\_?\d+', taxID))
print ( mount)
將re.findall
與下面的正則表達式一起使用:
import re
tag = 'URS0000D94775_60169'
tax_id = re.findall(r'\d+$', tag)[0]
print(tax_id)
# 60169
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.