为什么 Biopython 中 Seq 对象的 'join' 方法对列表的最后一个元素不起作用?

Why does the 'join' method for Seq object in Biopython not work on the last element of a list?

以下代码来自Biopython教程。我打算在每个重叠群后添加 'N5'。为什么尾随 N10 在第三个重叠群“TTGCA”之后不存在?

from Bio.Seq import Seq 
contigs = [Seq("ATG"), Seq("ATCCCG"), Seq("TTGCA")] 
spacer = Seq("N"*10) 
spacer.join(contigs) 
output
Seq('ATGNNNNNNNNNNATCCCGNNNNNNNNNNTTGCA')

expected output
Seq('ATGNNNNNNNNNNATCCCGNNNNNNNNNNTTGCANNNNNNNNNN')

Python和Biopython中的索引不都是0开头的吗?

谢谢

这与biopython无关。

这就是 string.join 的工作原理:

configs = ["ATG", "ATCCCG", "TTGCA"] 
spacer = "N"*10 
spacer.join(configs) 

结果: ATGNNNNNNNNNNATCCCGNNNNNNNNNNTGCA

因为它应该 - 根据 help(str.join):

join(self, iterable, /) Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: '.'.join(['ab', 'pq', 'rs']) -> 'ab.pq.rs'