Example #1
0
 def reactions_to_assembly(self, reactions):
     seqs = []
     for r in reactions:
         sequence = r.outputs[0].sequence
         seqs.append(jdna.Sequence(sequence, cyclic=False))
     assemblies = jdna.Reaction.cyclic_assemblies(seqs)
     return assemblies
Example #2
0
def test_pick_qc_primers_for_interagration(session, test_plasmid):

    seq = jdna.Sequence(test_plasmid)
    integrations = Yeast.genomic_integration(seq)
    primer_list = cache_primers(session)
    for integration in integrations:
        r = Yeast.integration_qc_primers(integration, primer_list, size_range=(400, 2500), session=session, pick_left=True, pick_right=True)
        print(len(r[1]))
Example #3
0
    def validate_pcr(self, reaction: Reaction, length_only=False):
        primers = [m for m in reaction.inputs if m.type.name == "PRIMER"]
        template = [m for m in reaction.inputs if m.type.name == "TEMPLATE"][0]
        template_seq = jdna.Sequence(
            template.sequence,
            cyclic=template.alignment_group.subject_region.cyclic)
        if template.alignment_group.subject_region.direction == -1:
            template_seq = template_seq.reverse_complement()
        primer_seqs = [
            jdna.Sequence(p.sequence, cyclic=False) for p in primers
        ]

        product = jdna.Reaction.pcr(template_seq, primer_seqs)[0]

        if length_only:
            assert len(product) == len(reaction.outputs[0].query_region)
            return
        assert str(product).upper() == str(
            reaction.outputs[0].sequence.seq).upper()
Example #4
0
def parts_by_name_and_cat():
    parts_dict = {}
    by_category = {}
    df = parts_df()
    for _, row in df.iterrows():
        seq = row['Sequence']
        if seq != 'None':
            dna = jdna.Sequence(row['Sequence'])
            dna.annotate(None, None, row['Part'], color=ColorHash(row['Part'] + row['Annotation']).hex)
            parts_dict[row['Part']] = dna
            by_category.setdefault(row['Annotation'], {})
            by_category[row['Annotation']][row['Part']] = dna
    return parts_dict, by_category
Example #5
0
    def integration_sequence(integration_results: dict):
        """Parse an integration result into a :class:`jdna.Sequence` instance."""

        flank_left = jdna.Sequence(
            str(integration_results['sequence']['flank_left']))
        flank_left.annotate(None, None, integration_results['subject_name'])

        left = jdna.Sequence(
            str(integration_results['sequence']['left_homology']))
        left.annotate(None, None, integration_results['left_homology_pos'])

        flank_right = jdna.Sequence(
            str(integration_results['sequence']['flank_right']))
        flank_right.annotate(None, None, integration_results['subject_name'])

        right = jdna.Sequence(
            str(integration_results['sequence']['right_homology']))
        right.annotate(None, None, integration_results['right_homology_pos'])

        integration_seq = flank_left + left + integration_results['sequence'][
            'integrant'] + right + flank_right

        return integration_seq
Example #6
0
def concat_parts(parts):
    """Concatenates a list of Coral.DNA objects or looks for parts by name in the parts dictionary"""
    parts_dict, _ = parts_by_name_and_cat()
    s = jdna.Sequence()
    for p in parts:
        if p is None:
            continue
        if isinstance(p, str):
            p = p.strip()
            if p == '':
                continue
            s += parts_dict[p].copy()
        else:
            s += p
    return s
Example #7
0
def find_initial_bindings(primers: list, template: str, min_bases: int) -> list:
    """
    Quickly finds initial bindings to primers

    :param primers: list of loaded primers (with sequence in the 'seq' attribute) or a tuple of the (sequence, name)
    :type primers: list
    :param template: template sequence
    :type template: basestring
    :param min_bases: minimum number of bases to find matches
    :type min_bases: int
    :return: list of matches at namedtuples (matching_sequence, full primer sequence, primer model, 1 or -1 for direction)
    :rtype: list
    """

    jseq = jdna.Sequence(template)
    template = str(jseq)
    template_rc = str(jseq.copy().rc())
    assert isinstance(primers, list)
    matches = []

    for primer in primers:
        if isinstance(primer, tuple):
            primer = named_primer(*primer)
        try:
            test_seq = primer.seq[min_bases:]
            if len(test_seq) < min_bases:
                continue
            fwd_matches = re.findall(test_seq, template, re.IGNORECASE)
            rev_matches = re.findall(test_seq, template_rc, re.IGNORECASE)
            for _m in fwd_matches:
                matches.append(Binding(test_seq, primer.seq, primer, 1))
            for _m in rev_matches:
                matches.append(Binding(test_seq, primer.seq, primer, -1))
        except Exception as e:
            raise e
    return list(set(matches))
Example #8
0
def test_genomic_integration(test_plasmid):
    seq = jdna.Sequence(test_plasmid)
    integrations = Yeast.genomic_integration(seq)
    assert integrations