これは、私が尋ねた以前の質問のフォローアップです: Processing a sub-list of variable size within a large list .
itertools を使用して DNA フラグメントのグループを取り出すことができましたが、別の問題に直面しています。
これらの DNA 断片のグループに基づいてプライマーを設計する必要があります。プライマーは、異なる DNA フラグメントからのオーバーラップを含めることによって設計されます。リストにフラグメント A、B、C の 3 つの DNA フラグメントがあるとします。抽出する必要があるのは次のとおりです。
- A の最初の 40 nt と (順番に) 連結する C の最後の 20 ヌクレオチド (nt)、
- A の最後の nt の RC と順番に連結する B の最初の 20 nt の逆補数 (RC)、
- A の最後の 20 nt を B の最初の 40 nt と連結し、
- B の最後の 40 nt の RC と連結する C の最初の 20 nt の RC、
- A の最初の 40 nt と連結する C の最後の 20 nt、
- C の最後の 40 nt の RC と連結する A の最初の 20 nt の RC。
この問題を解決できないようです。どこから始めるのが最適なのかわかりません...
これまでに作成したコードは、「グループ 1」のみを出力します (意図的に、処理している視覚的な出力の量を最小限に抑えることができます)。ここにあります:
#import BioPython Tools
from Bio.Seq import Seq
from Bio.Alphabet import IUPAC
#import csv tools
import csv
import sys
import os
import itertools
with open('constructs-to-make.csv', 'rU') as constructs:
construct_list = csv.DictReader(constructs)
def get_construct_number(row):
return row["Construct"]
def get_strategy(row):
return row["Strategy"]
## construct_list.next()
## construct_number = 1
primer_list = []
## temp_list = []
## counter = 2
groups = []
## for row in construct_list:
## print(row)
##
for key, items in itertools.groupby(construct_list, key=get_construct_number):
for subitems in items:
#here, I am trying to get the annealing portion of the Gibson sequence out
if subitems['Strategy'] == 'Gibson' and subitems['Construct'] == '1':
print(subitems['Construct'])
fw_anneal = Seq(subitems['Sequence'][0:40], IUPAC.unambiguous_dna)
print(fw_anneal)
re_anneal = Seq(subitems['Sequence'][-40:], IUPAC.unambiguous_dna).reverse_complement()
print(re_anneal)
fw_overhang = Seq(subitems['Sequence'][0:20], IUPAC.unambiguous_dna).reverse_complement()
print(fw_overhang)
re_overhang = Seq(subitems['Sequence'][-20:], IUPAC.unambiguous_dna)
print(re_overhang)
どんな助けでも大歓迎です!