def compute_primers(): # Get the part names. sequence_name = request.form['sequence_name'] sequence = request.form['sequence'].replace('\n','') backbone = request.form['backbone'] # Validation checks if not validate_sequence_characters(sequence): return error('Sequence contains non-ATGC letters') if not validate_sequence_length(sequence): return error('Sequence length has to be at least 100 n.t.') else: # Create a SeqRecord object. part = SeqRecord(Seq(sequence.upper(), alphabet=generic_dna), name=sequence_name, id=sequence_name) backbone_part = plasmids[backbone] p = PrimerDesigner() p.set_sequences([part, backbone_part]) p.construct_graph() nodes = p.nodes(data=True) edges = p.edges(data=True) protocol = p.pcr_protocol() return render_template('primers.html', nodes=nodes, edges=edges, protocol=protocol)
def compute_mutagenesis_primers(self): """ Using the sequence fragments to be assembled together, computes for each step the primers that are to be used to assemble the mutated fragments. """ for step, frags in self.fragments.items(): # Run the standard PrimerDesigner protocol. p = PrimerDesigner() p.set_sequences(frags) # Ensure to set the filename attribute. p.filename = 'step{step}'.format(step=step) p.construct_graph() p.compute_assembly_primers() p.compute_junction_sequencing_primers() p.compute_pcr_protocol() self.primer_designers[step] = p
if __name__ == '__main__': master_cloning_primers = list() for f in os.listdir(os.getcwd()): if '.fasta' in f: print(f) for k, v in segmaps.items(): if k in f: segment = v backbone = plasmids['pDZ-{0}-split2'.format(segment)] print(backbone) p = PrimerDesigner() p.read_sequences(f) p.add_sequences(backbone) p.construct_graph() protocol = p.pcr_protocol() f = f.replace('.fasta', '') pd.DataFrame(protocol).to_csv('{0}_pcr_protocol.csv'.format(f)) for n, d in p.nodes(data=True): """Grab out the cloning primers.""" primer_data = dict() for drxn in ['fw', 're']: primer_data['part'] = n primer_data['{0}_cloning_primer'.format(drxn)] =\ str(d['{0}_cloning_primer'.format(drxn)].seq) master_cloning_primers.append(primer_data) pd.DataFrame(master_cloning_primers).to_csv('all_primers.csv')