【发布时间】:2021-06-03 14:06:27
【问题描述】:
我正在对人类蛋白质组进行计算机消化,这意味着我正在尝试在特定位置切割每种蛋白质的氨基酸序列。我在我创建的一个更大的函数中使用 Pyteomics 解析器函数 Pyteomics Parser。
我收到此错误: PyteomicsError:Pyteomics 错误,消息:“不是有效的 modX 序列:{'sequence': 'AKDEVQKN'}”
但是,我不确定 AKDEVQKN 如何与 modX_reqquence 编译器不匹配:
_modX_sequence = re.compile(r'^([^-]+-)?((?:[^A-Z-]*[A-Z])+)(-[^-]+)?$')
根据我对这个正则表达式的理解,它应该找到任何不以 (-) 开头且后跟一系列字母字符的字符串。
这是我尝试使用的功能。
import re
import pyteomics
from pyteomics import fasta, parser
def ButcherShop(df, target, rule,min_length=7,exception=None,max_legnth=100, pH=2.0):
> raw = df[target]
> unique_peptides = set()
> for peptide in raw:
> new_peptides = parser.cleave(peptide, rule=rule,min_length=min_length,exception=exception)
> unique_peptides.update(new_peptides)
> print(f'Done,{len(unique_peptides)} sequences of >= 7 amino acids!')
> pep_dic = [{'sequence': i} for i in unique_peptides]
> for peptides in pep_dic:
> pep_dic['parsed_sequence'] = parser.parse(peptides,show_unmodified_termini=False)
> pep_dic['xlength'] = len(peptides)
> pep_dic['charge'] = int(round(electrochem.charge(peptides, pH=pH)))
> pep_dic['mass']=int(round(Peptide_mass(peptides)))
> pep_dic = [peptide for peptide in pep_dic if peptide['length'] <= int(max_length)]
> pep_df = pd.DataFrame.from_dict(pep_dic)
> return unique_peptides,pep_dic,pep_df
感谢您提供有关如何解决此问题的任何见解。
** 更新:如果我在不同的集合上运行,我会得到同样的错误,这可能表明它是库本身。
【问题讨论】:
-
([^-]+-)?-- 这是一系列非破折号后跟破折号,但最后一个 ?说“这整个序列是可选的。” -
谢谢。我希望它匹配,我只是不确定它为什么会抛出这个错误。
标签: python regex string dataframe match