Это продолжение предыдущего вопроса, который я задал: Обработка подсписка переменного размера в большом списке.
Мне удалось использовать itertools для извлечения групп фрагментов ДНК, но теперь я столкнулся с другой проблемой.
Мне нужно создать праймеры на основе этих групп фрагментов ДНК. Праймеры конструируются путем включения перекрытий из разных фрагментов ДНК. Допустим, у меня есть три фрагмента ДНК в списке, фрагменты A, B и C. Мне нужно извлечь:
- последние 20 нуклеотидов (n.t.) C для конкатенации (по порядку) с первыми 40 n.t. из А,
- обратное дополнение (RC) первых 20 н.т. элемента B для объединения по порядку с RC последнего n.t. из А,
- последние 20 н.т. A для объединения с первыми 40 н.т. из B,
- РЦ первые 20 н.т. из C для конкатенации с RC последних 40 n.t. из B,
- последние 20 н.т. из C для объединения с первыми 40 н.т. из А,
- РЦ первые 20 н.т. A для объединения с RC последних 40 n.t. из С.
Кажется, я не могу решить эту проблему, и я не уверен, с чего мне лучше всего начать ...
Код, который я уже написал до сих пор, выводит только «группу 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)
Любая помощь будет принята с благодарностью!