我是一名业余程序员(我的实际专业是生物学),所以如果代码很糟糕,我深表歉意。
无论如何,我正在做一个 rosalind.info 练习(http://rosalind.info/problems/subs/),希望我找到一个特定 DNA 基序包含在更大 DNA 序列中的每个索引。基本上,我需要在字符串中找到子字符串的索引。应该很容易吧?好吧,也许你可以帮助我。
所以这是我的代码:
with open('rosalind_subs.txt') as f:
seq = f.readline()
seq.strip()
subs = f.readline()
subs.strip()
break
def finder(x, y):
index = x.find(y)
return index
print("sequence is: " + seq)
print("subs is: " + subs)
print(finder(seq, subs))
这是我的输出:
sequence is: ACCAGTCTCTTTTTTCTCTTTTCTCTTTTCTCTTTTGACCCTCTTTTCGTCACTCTTTTACCTCTTTTTCTCTTTTACTCTTTTCTCTTTTACTCTTTTACTCTTTTAGCGCAGATCTCTTTTCTCTTTTGGCTCTTTTGTCATCCTCTTTTAGACTCTTTTGGGAAGCGACGCCTCTTTTCTCTTTTCTCTTTTGCCTCTTTTTATAACCTAAAAGACTCTTTTCCCTCTTTTCCGATTTGCCAAGGGCTCTCTTTTCTCTTTTGCTCTTTTCTCTTTTCTCTTTTTACTCTTTTCTCTTTTCGCCCCAAGATTAACTCTTTTTCTCTTTTCTCTCTTTTTTCCTCTTTTCTCTTTTGAATTGACCTCTTTTTCTCTTTTTTTGGGCCGCTCTTTTCTCTTTTACTCTTTTCTCTCTTTTAACAGCTCTTTTCCTTCTCTTTTGTCTCTTTTAGTATACTCTTTTACTCTTTTCTCTTTTCTCTCTTTTACTCTTTTGCTCTTTTCTCTTTTTGTCTCTTTTGCCCTGTCTCTTTTCACGCTTCTCTTTTAGTGTACTCTTTTACTCTTTTTGGCTCTTTTCGAATTTGTTAGCTCTTTTGCTCTTTTCTCTTTTGCTCTTTTGTCTCTTTTGATCAGATTCTCTTTTTCTCTTTTCTCTTTTCCTTAAGCAGATTTCTCTTTTCTCTTTTTCTCTCTTTTGCTCTTTTACTCTTTTACTGCTTTCTCTTTTACAACCTCTTTTACTCTTTTAAGCTCTTTTCTCTTTTGCGCCTCTTTTCCTCCCCTCTTTTTAGCTCTTTTCTCTTTTTCGCTCTTTTCAGCTCTTTTCACTCTTTTGTTTTGAGCTCTTTTCAGACTCTTTTATCCTCTTTTTTCCTCTTTTAGCGCTCTTTTGTAGCCTCTTTT
motif is: CTCTTTTCT
-1
***Repl Closed***
我把它***Repl Closed***
留在那里,努力不遗余力。也许它与 Sublime REPL 有关?
无论如何,您可能无法仅通过查看来判断,但实际上在 DNA 序列中多次发现该基序,只是查找功能没有发现它。是什么赋予了?