python-3.x - 如何使用已经在 tsv 文件中的位置从序列中提取子字符串
问题描述
我正在尝试编写一个自动从tsv
包含开始和结束位置的文件中提取的代码。我想使用这些位置从fasta
序列中提取子字符串。我试图这样做:
import csv
import re
species_pos = '(\d* \d*)\D'
c_species_pos = re.compile(species_pos)
with open('/home/elissar/Documents/Fasta_sequences/start.tsv') as tsvfile:
tsvreader = csv.reader(tsvfile, delimiter="\t")
for line in tsvreader:
pos_found = re.findall(c_species_pos, re.Pattern)
print(species_pos)
tsvfile.close()
但它返回:
type error: expected string or bytes-like object
解决方案
推荐阅读
- java - 在sql查询中使用变量作为列
- android - 快捷方式创建不起作用
- asterisk - 在 pjsip max_calls 上调用限制为 32 次调用
- mysql - nodejs中的一些代码让我感到困惑
- html - 阻止动画在 CSS 中自动播放
- c - 使用带有文件扩展名 .r 的自动工具作为标题,而不是 ratfor 而是 C 编程
- python - NLTK 错误:OSError:没有这样的文件或目录
- jquery - 如何使用 jQuery 对动态数组进行排序?
- r - 将 auto.arima() 映射到子集时间序列列表
- python - 查找元素值是唯一的,并且列表中的所有元素都相同