コード例 #1
0
ファイル: test_primer.py プロジェクト: ginkgobioworks/edge
    def test_computes_primer_distance_to_junction(self):
        upstream = "cagtacgatcgttggtatgctgactactagcgtagctagcacgtcgtgtccaggcttgagcgacgt"
        product = "cagctggtaatcgtactcgtactagcatcgtacgtgtctgatcatctgacgtatcatctga"
        downstream = (
            "agtgacgtcgtgtgtagcgtactgtatcgtgtgtcgcgcgtagtcatctgatcgtacgtactgaat"
        )
        template = "".join([upstream, product, downstream])

        WIN = 10
        junctions = [len(upstream) + 1, len(upstream) + len(product) - 1]
        res = design_primers_from_template(template,
                                           len(upstream) + 1 - WIN,
                                           len(product) + WIN * 2, junctions,
                                           {})
        self.assertEquals(len(res), 5)
        for r in res:
            left = r["PRIMER_LEFT_SEQUENCE"]
            self.assertEquals(
                r["PRIMER_LEFT_SEQUENCE_DISTANCE_TO_JUNCTION"] >= WIN, True)
            self.assertEquals(
                template.lower().index(left.lower()) + len(left) +
                r["PRIMER_LEFT_SEQUENCE_DISTANCE_TO_JUNCTION"],
                junctions[0],
            )
            right = str(Seq(r["PRIMER_RIGHT_SEQUENCE"]).reverse_complement())
            self.assertEquals(
                r["PRIMER_RIGHT_SEQUENCE_DISTANCE_TO_JUNCTION"] >= WIN, True)
            self.assertEquals(
                template.lower().index(right.lower()) -
                r["PRIMER_RIGHT_SEQUENCE_DISTANCE_TO_JUNCTION"],
                junctions[1],
            )
コード例 #2
0
ファイル: test_primer.py プロジェクト: Chris7/edge
    def test_computes_primer_distance_to_junction(self):
        upstream = "cagtacgatcgttggtatgctgactactagcgtagctagcacgtcgtgtccaggcttgagcgacgt"
        product = "cagctggtaatcgtactcgtactagcatcgtacgtgtctgatcatctgacgtatcatctga"
        downstream = "agtgacgtcgtgtgtagcgtactgtatcgtgtgtcgcgcgtagtcatctgatcgtacgtactgaat"
        template = ''.join([upstream, product, downstream])

        WIN = 10
        junctions = [len(upstream)+1, len(upstream)+len(product)-1]
        res = design_primers_from_template(template, len(upstream)+1-WIN, len(product)+WIN*2,
                                           junctions, {})
        self.assertEquals(len(res), 5)
        for r in res:
            left = r['PRIMER_LEFT_SEQUENCE']
            self.assertEquals(r['PRIMER_LEFT_SEQUENCE_DISTANCE_TO_JUNCTION'] >= WIN, True)
            self.assertEquals(template.lower().index(left.lower()) +
                              len(left) +
                              r['PRIMER_LEFT_SEQUENCE_DISTANCE_TO_JUNCTION'], junctions[0])
            right = str(Seq(r['PRIMER_RIGHT_SEQUENCE']).reverse_complement())
            self.assertEquals(r['PRIMER_RIGHT_SEQUENCE_DISTANCE_TO_JUNCTION'] >= WIN, True)
            self.assertEquals(template.lower().index(right.lower()) -
                              r['PRIMER_RIGHT_SEQUENCE_DISTANCE_TO_JUNCTION'], junctions[1])
コード例 #3
0
def get_verification_primers(genome, region, primer3_opts):
    """
    Design primers to verify replacing region with cassette.
    """

    fragment = Fragment.objects.get(pk=region.fragment_id).indexed_fragment()
    cassette = region.cassette

    check_junction_lu = CHECK_JUNCTION_LEFT_UP
    check_junction_ld = CHECK_JUNCTION_LEFT_DN
    check_junction_ru = CHECK_JUNCTION_RIGHT_UP
    check_junction_rd = CHECK_JUNCTION_RIGHT_DN

    if primer3_opts:
        if 'EDGE_CHECK_JUNCTION_LEFT_HA' in primer3_opts:
            check_junction_ld = int(primer3_opts['EDGE_CHECK_JUNCTION_LEFT_HA'])
        if 'EDGE_CHECK_JUNCTION_RIGHT_HA' in primer3_opts:
            check_junction_ru = int(primer3_opts['EDGE_CHECK_JUNCTION_RIGHT_HA'])

    #
    # front junction
    #

    upstream_window = CHECK_JUNCTION_PRIMER_WINDOW+check_junction_lu
    downstream_window = min(len(cassette), CHECK_JUNCTION_PRIMER_WINDOW+check_junction_ld)
    back = cassette[0:downstream_window]

    # don't bother looking for primers if front part of cassette is same as
    # region to be replaced
    if region.start > 1 and back.lower() != region.sequence[0:downstream_window].lower():
        front = fragment.get_sequence(region.start-upstream_window, region.start-1)
        template = front+back
        junction = [len(front)]
        roi_start = len(front)-check_junction_lu if len(front) > check_junction_lu else 0
        roi_len = min(check_junction_lu+check_junction_ld,
                      min(len(front), check_junction_ld)+len(cassette))
        # remove primers that works on un-modified genome for creating a PCR product
        region.verification_front =\
            remove_working_primers(genome,
                                   design_primers_from_template(template, roi_start, roi_len,
                                                                junction, primer3_opts))

    #
    # back junction
    #

    upstream_window = min(len(cassette), CHECK_JUNCTION_PRIMER_WINDOW+check_junction_ru)
    downstream_window = CHECK_JUNCTION_PRIMER_WINDOW+check_junction_rd
    front = cassette[-upstream_window:]

    # don't bother looking for primers if front part of cassette is same as
    # region to be replaced
    if region.start+len(region.sequence) < fragment.length and\
       front.lower() != region.sequence[-upstream_window:].lower():
        back = fragment.get_sequence(region.start+len(region.sequence),
                                     region.start+len(region.sequence)+downstream_window-1)
        template = front+back
        junction = [len(front)]
        roi_start = len(front)-check_junction_ru if len(front) > check_junction_ru else 0
        roi_len = min(check_junction_ru+check_junction_rd,
                      min(len(back), check_junction_rd)+len(cassette))
        # remove primers that works on un-modified genome for creating a PCR product
        region.verification_back =\
            remove_working_primers(genome,
                                   design_primers_from_template(template, roi_start, roi_len,
                                                                junction, primer3_opts))

    #
    # cassette
    #

    if region.start > 1 and region.start+len(region.sequence) < fragment.length:
        front = fragment.get_sequence(region.start-CHECK_JUNCTION_PRIMER_WINDOW, region.start-1)
        back = fragment.get_sequence(region.start+len(region.sequence),
                                     region.start+len(region.sequence) +
                                     CHECK_JUNCTION_PRIMER_WINDOW-1)
        template = front+cassette+back
        junctions = [len(front), len(front+cassette)-1]
        roi_start = template.index(cassette)
        roi_len = len(cassette)
        region.verification_cassette =\
            design_primers_from_template(template, roi_start, roi_len,
                                         junctions, primer3_opts)
コード例 #4
0
ファイル: recombine.py プロジェクト: Chris7/edge
def get_verification_primers(genome, region, primer3_opts):
    """
    Design primers to verify replacing region with cassette.
    """

    fragment = Fragment.objects.get(pk=region.fragment_id).indexed_fragment()
    cassette = region.cassette

    check_junction_lu = CHECK_JUNCTION_LEFT_UP
    check_junction_ld = CHECK_JUNCTION_LEFT_DN
    check_junction_ru = CHECK_JUNCTION_RIGHT_UP
    check_junction_rd = CHECK_JUNCTION_RIGHT_DN

    if primer3_opts:
        if 'EDGE_CHECK_JUNCTION_LEFT_HA' in primer3_opts:
            check_junction_ld = int(primer3_opts['EDGE_CHECK_JUNCTION_LEFT_HA'])
        if 'EDGE_CHECK_JUNCTION_RIGHT_HA' in primer3_opts:
            check_junction_ru = int(primer3_opts['EDGE_CHECK_JUNCTION_RIGHT_HA'])

    #
    # front junction
    #

    upstream_window = CHECK_JUNCTION_PRIMER_WINDOW+check_junction_lu
    downstream_window = min(len(cassette), CHECK_JUNCTION_PRIMER_WINDOW+check_junction_ld)
    back = cassette[0:downstream_window]

    # don't bother looking for primers if front part of cassette is same as
    # region to be replaced
    if region.start > 1 and back.lower() != region.sequence[0:downstream_window].lower():
        front = fragment.get_sequence(region.start-upstream_window, region.start-1)
        template = front+back
        junction = [len(front)]
        roi_start = len(front)-check_junction_lu if len(front) > check_junction_lu else 0
        roi_len = min(check_junction_lu+check_junction_ld,
                      min(len(front), check_junction_ld)+len(cassette))
        # remove primers that works on un-modified genome for creating a PCR product
        region.verification_front =\
            remove_working_primers(genome,
                                   design_primers_from_template(template, roi_start, roi_len,
                                                                junction, primer3_opts))

    #
    # back junction
    #

    upstream_window = min(len(cassette), CHECK_JUNCTION_PRIMER_WINDOW+check_junction_ru)
    downstream_window = CHECK_JUNCTION_PRIMER_WINDOW+check_junction_rd
    front = cassette[-upstream_window:]

    # don't bother looking for primers if front part of cassette is same as
    # region to be replaced
    if region.start+len(region.sequence) < fragment.length and\
       front.lower() != region.sequence[-upstream_window:].lower():
        back = fragment.get_sequence(region.start+len(region.sequence),
                                     region.start+len(region.sequence)+downstream_window-1)
        template = front+back
        junction = [len(front)]
        roi_start = len(front)-check_junction_ru if len(front) > check_junction_ru else 0
        roi_len = min(check_junction_ru+check_junction_rd,
                      min(len(back), check_junction_rd)+len(cassette))
        # remove primers that works on un-modified genome for creating a PCR product
        region.verification_back =\
            remove_working_primers(genome,
                                   design_primers_from_template(template, roi_start, roi_len,
                                                                junction, primer3_opts))

    #
    # cassette
    #

    if region.start > 1 and region.start+len(region.sequence) < fragment.length:
        front = fragment.get_sequence(region.start-CHECK_JUNCTION_PRIMER_WINDOW, region.start-1)
        back = fragment.get_sequence(region.start+len(region.sequence),
                                     region.start+len(region.sequence) +
                                     CHECK_JUNCTION_PRIMER_WINDOW-1)
        template = front+cassette+back
        junctions = [len(front), len(front+cassette)-1]
        roi_start = template.index(cassette)
        roi_len = len(cassette)
        region.verification_cassette =\
            design_primers_from_template(template, roi_start, roi_len,
                                         junctions, primer3_opts)