Python: 如何在FASTA文件中查找短序列的坐标?

Python: How to find coordinates of short sequences in a FASTA file?

我有一个短序列列表,我想在与包含原始序列的 fasta 文件进行比较后获取其坐标或换句话说获取其 bed 文件。

法斯塔文件:

>PGH2
CGTAGCGGCTGAGTGCGCGGATAGCGCGTA

短序列fasta文件:

>PGH2
CGGCTGAGT

有什么方法可以得到它的坐标吗?床上工具帮不上什么忙。

期望的输出:

PGH2  6 14
str1 = "CGTAGCGGCTGAGTGCGCGGATAGCGCGTA"
str2 = "CGGCTGAGT"
index = str1.index(str2)
print index

输出:index = 5,要得到 6,14 使用 index+1, index+len(str2)

使用BioPyton

from Bio import SeqIO

for long_sequence_record in SeqIO.parse(open('long_sequences.fasta'), 'fasta'):
    long_sequence = str(long_sequence_record.seq)

    for short_sequence_record in SeqIO.parse(open('short_sequences.fasta'), 'fasta'):
        short_sequence = str(short_sequence_record.seq)

        if short_sequence in long_sequence:
            start = long_sequence.index(short_sequence) + 1
            stop = start + len(short_sequence) - 1
            print short_sequence_record.id, start, stop