【问题标题】:How do i convert a three-letter amino acids to single letter in an excel file如何在excel文件中将三个字母的氨基酸转换为单个字母
【发布时间】:2021-04-26 16:34:02
【问题描述】:

我想将 excel 中的一列三个字母的氨基酸转换为一个字母,并将一个字母的氨基酸打印到 excel 文件中的每个相应行。我知道我可以为此使用 biopython。,

我的尝试:

import Bio
from Bio.SeqUtils import seq1
seq1("MetAlaIleValMetGlyArgTrpLysGlyAlaArgTer")
'MAIVMGRWKGAR*'

但我希望大家理解,我不能放置一个字符串供 python 转换。我需要在 excel 中读取一整列并使用转换后的 1 字母序列打印一个新列。图片供参考:

示例: enter image description here

【问题讨论】:

  • 现在好点了吗?
  • 谢谢,我现在就这样做
  • 更新了更多细节

标签: python excel biopython


【解决方案1】:

也许你可以试试下面的脚本。您需要为所有可能的三个字母组合扩展它。希望这对你有用。

# open file 
import pandas as pd
df = pd.read_excel (r'file')
df.columns=['three letter code']

codes = []
for i in df['code']:
  if i == 'uuu':
    codes.append('U')
  if i == 'cuu':
    codes.append('C')    
  if i == 'uaa':
    codes.append('A')
print (codes)
df['new_code']= codes
df

输出是:

        code    new_code
0       uuu     U
1       cuu     C
2       uaa     A

【讨论】:

  • 我认为这会奏效。感谢您的提示。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-29
  • 1970-01-01
  • 1970-01-01
  • 2021-03-17
  • 2023-03-10
相关资源
最近更新 更多