特定の座標から DNA シーケンスを引き出すことができるように、Biopython を使用して大きな単一エントリの fasta ファイル (514 メガ ベース) を開きます。シーケンスを返すのはかなり遅いので、私が理解していないこのタスクを実行するより高速な方法があるかどうか疑問に思っています。1 回か 2 回のヒットであれば速度は問題になりませんが、145,000 の座標のリストを反復処理しているので、数日かかります :/
import sys
from Bio import SeqIO
from Bio.Seq import Seq
def get_seq(fasta, cont_start, cont_end, strand):
f = fasta
start_pos = cont_start
end_pos = cont_end
for seq_record in SeqIO.parse(f, "fasta"):
if strand == '-' :
return seq_record.seq[int(start_pos):int(end_pos)].reverse_complement()
elif strand == '+':
return seq_record.seq[int(start_pos):int(end_pos)]
else :
print ' Invalid syntax!
sys.exit(1)