def DNA_no():
mappings = {"A":"1","T":"2","C":"3","G":"4"}
result = []
DNAseq = open("mytype.txt","r")
DNA_seq = DNAseq.read()
print(DNA_seq)
print(len(DNA_seq))
for current in DNA_seq:
result += mappings[current]
return result
我想将数据文件映射为数字。它使用小输入序列,但不处理读取文本文件。我遇到的错误是它可能是txt文件中的空格。我不知道如何阅读并转换它。
答案 0 :(得分:0)
首先读取(DNAseq
)数组(文本行)中的所有行。
fname ="mytype.txt"
with open(fname) as f:
DNAseq = f.readlines()
for seq in DNAseq:
# remap code here