Note that there are some explanatory texts on larger screens.

plurals
  1. POIterating through a list where I have to grab data from the first item for use in the last item
    primarykey
    data
    text
    <p>This is a follow-up to a previous question I had asked: <a href="https://stackoverflow.com/questions/14063387/processing-a-sub-list-of-variable-size-within-a-larger-list">Processing a sub-list of variable size within a larger list</a>.</p> <p>I managed to use itertools to get groups of DNA fragments out, but now I'm faced with a different problem. </p> <p>I need to design primers based on these groups of DNA fragments. Primers are designed by including overlaps from different DNA fragments. Let's say I have three DNA fragments in a list, fragments A, B, and C. I need to extract:</p> <ul> <li>the last 20 nucleotides (n.t.) of C to concatenate (in order) with the first 40 n.t. of A,</li> <li>the reverse complement (RC) of the first 20 n.t. of B to concatenate in order with the RC of the last n.t. of A,</li> <li>the last 20 n.t. of A to concatenate with the first 40 n.t. of B,</li> <li>the RC of the first 20 n.t. of C to concatenate with the RC of the last 40 n.t. of B,</li> <li>the last 20 n.t. of C to concatenate with the first 40 n.t. of A,</li> <li>the RC of the first 20 n.t. of A to concatenate with the RC of the last 40 n.t. of C.</li> </ul> <p>I can't seem to solve this problem, and I'm not sure where's the best place for me to start on this... </p> <p>Code that I've already written so far outputs just "group 1" (on purpose, so I can minimize the amount of visual output I'm dealing with). Here it is:</p> <pre><code>#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) </code></pre> <p>Any help would be greatly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload