首页 > 解决方案 > 如何使用已经在 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

标签: python-3.xbiopython

解决方案


推荐阅读