Esempio n. 1
0
    def test_circ_pcr(self):
        ''' test circ pcr'''
        s = parse('''
        >MCT4_flaghis_rv
        gccgcaagcttgtcgtcatcgtctttgtagtcCATggccaggagggttggttccgcc
        >MCT4_flaghis_fw
        ccaccaccaccaccaccaccaccaccaccacggaggggccgtggtggacgagggcc''', ds=False)

        t = parse('''
        >hej circular
        TCAGGTGAGGCGGAACCAACCCTCCTGGCCATGggaggggccgtggtggacgagggccccacaggcg
        ''')

        p = pcr(s,t)

        self.assertTrue( p.seguid() == 'wYEpbWxO8tfgA_AL67wqGzYmc5k')
Esempio n. 2
0
    def test_circ_pcr(self):
        ''' test circ pcr'''
        s = parse('''
        >MCT4_flaghis_rv
        gccgcaagcttgtcgtcatcgtctttgtagtcCATggccaggagggttggttccgcc
        >MCT4_flaghis_fw
        ccaccaccaccaccaccaccaccaccaccacggaggggccgtggtggacgagggcc''',
                  ds=False)

        t = parse('''
        >hej circular
        TCAGGTGAGGCGGAACCAACCCTCCTGGCCATGggaggggccgtggtggacgagggccccacaggcg
        ''')

        p = pcr(s, t)

        self.assertTrue(p.seguid() == 'wYEpbWxO8tfgA_AL67wqGzYmc5k')
Esempio n. 3
0
def test_pth1():

    q = BPread("read1.gb", "gb")
    w = BPread("read2.gb", "gb")
    e = BPread("read3.fasta", "fasta")
    r = BPread("read4.fasta", "fasta")

    q.format("gb")
    w.format("gb")

    a, b = BPparse("pth1.txt", "gb")

    x, y = parse("pth1.txt")

    assert "".join(a.format("gb").splitlines()[1:]) == "".join(x.format("gb").splitlines()[1:])
    assert "".join(b.format("gb").strip().splitlines()[4:]) == "".join(y.format("gb").splitlines()[4:])
Esempio n. 4
0
def test_read_from_file():
    a = read("./read1.gb")
    b = read("./read2.gb")
    c = read("./read3.fasta")
    d = read("./read4.fasta")
    x,y = parse( "pth1.txt" )

    a.format("gb")
    b.format("gb")
    c.format("gb")
    d.format("gb")
    x.format("gb")
    y.format("gb")
    assert x.format()[3314:3325] == '2micron 2\xc2\xb5'
    assert x.features[13].qualifiers['label'][0] == '2micron 2\xc2\xb5'
    assert str(a.seq).lower()==str(b.seq).lower()==str(c.seq).lower()==str(d.seq).lower()
Esempio n. 5
0
    def test_parse2(self):
        from Bio.Alphabet.IUPAC import IUPACAmbiguousDNA

        seqs = parse('./RefDataBjorn.fas')

        self.assertTrue( len(seqs) == 771 )
        self.assertTrue( list(set([len (a) for a in seqs])) == [901] )

        for i,s in enumerate(seqs):
            a = s.description
            b = a.split()
            c =  "|".join([b[0],b[1],b[3]])
            s.id = b[2].replace(" ","_")+"_"+str(i)
            s.description = ""
            if b[3]=="Zenion hololepis":
                s.id = b[3].replace(" ","_")+"_"+str(i)
            s.seq.alphabet = IUPACAmbiguousDNA()
Esempio n. 6
0
def test_read_from_file():
    a = read("./read1.gb")
    b = read("./read2.gb")
    c = read("./read3.fasta")
    d = read("./read4.fasta")
    x, y = parse("pth1.txt")

    a.format("gb")
    b.format("gb")
    c.format("gb")
    d.format("gb")
    x.format("gb")
    y.format("gb")
    assert x.format()[3314:3325] == '2micron 2\xc2\xb5'
    assert x.features[13].qualifiers['label'][0] == '2micron 2\xc2\xb5'
    assert str(a.seq).lower() == str(b.seq).lower() == str(
        c.seq).lower() == str(d.seq).lower()
Esempio n. 7
0
    def test_parse2(self):
        from Bio.Alphabet.IUPAC import IUPACAmbiguousDNA

        seqs = parse('./RefDataBjorn.fas')

        self.assertTrue(len(seqs) == 771)
        self.assertTrue(list(set([len(a) for a in seqs])) == [901])

        for i, s in enumerate(seqs):
            a = s.description
            b = a.split()
            c = "|".join([b[0], b[1], b[3]])
            s.id = b[2].replace(" ", "_") + "_" + str(i)
            s.description = ""
            if b[3] == "Zenion hololepis":
                s.id = b[3].replace(" ", "_") + "_" + str(i)
            s.seq.alphabet = IUPACAmbiguousDNA()
Esempio n. 8
0
def test_pth1():

    q = BPread("read1.gb", "gb")
    w = BPread("read2.gb", "gb")
    e = BPread("read3.fasta", "fasta")
    r = BPread("read4.fasta", "fasta")

    q.format("gb")
    w.format("gb")

    a, b = BPparse("pth1.txt", "gb")

    x, y = parse("pth1.txt")
    assert a.features[13].qualifiers['label'][0] == '2micron 2\xc2\xb5'
    assert a.format("gb")[3270:3281] == '2micron 2\xc2\xb5'

    assert "".join(a.format("gb").splitlines()[1:]) == "".join(x.format("gb").splitlines()[1:])
    assert "".join(b.format("gb").strip().splitlines()[4:]) == "".join(y.format("gb").splitlines()[4:])
Esempio n. 9
0
def test_pth1():

    q = BPread("read1.gb", "gb")
    w = BPread("read2.gb", "gb")
    e = BPread("read3.fasta", "fasta")
    r = BPread("read4.fasta", "fasta")

    q.format("gb")
    w.format("gb")

    a, b = BPparse("pth1.txt", "gb")

    x, y = parse("pth1.txt")
    assert a.features[13].qualifiers['label'][0] == '2micron 2\xc2\xb5'
    assert a.format("gb")[3270:3281] == '2micron 2\xc2\xb5'

    assert "".join(a.format("gb").splitlines()[1:]) == "".join(
        x.format("gb").splitlines()[1:])
    assert "".join(b.format("gb").strip().splitlines()[4:]) == "".join(
        y.format("gb").splitlines()[4:])
Esempio n. 10
0
def main():
    import docopt
    try:
        arguments = docopt.docopt(__doc__)
    except docopt.DocoptExit as e:
        print e.message

    if arguments['--version']:
        from ._version import get_versions
        __version__      = get_versions()['version'][:5]
        del get_versions
        print "ypkpathway version:",__version__

    if arguments['<path>']:
        file_ = arguments['<path>']
        try:
            with open(file_, "rU") as f: text=f.read()
        except IOError:
            print arguments['<path>'], 'could not be opened!'
            sys.exit(1)

        print "Assembly started! (This might take a while...)"

        pw = PathWay( pydna.parse( text ) )
        pw.generate_files()

        try:
            os.makedirs('ypk_assembly')
        except OSError as exception:
            if exception.errno != errno.EEXIST:
                raise

        for name, content in pw.files.items():
            with codecs.open(os.path.join('ypk_assembly',name),'w', "utf8") as f:
                f.write(content)
        print "Assembly finished! files written to folder ypkpathway"
Esempio n. 11
0
    print "Genbank record KC562906 downloaded from NCBI\n"
else:
    xks1_gene = read("Z72979.gb")
    print "A local copy of Genbank record Z72979 is used"
    YEp24PGK = read("KC562906.gb")
    print "A local copy of Genbank record KC562906 is used\n"

raw_input("press return!\n")

primers = '''
>primer1
GCGGATCCTCTAGAATGGTTTGTTCAGTAATTCAG
>primer3
AGATCTGGATCCTTAGATGAGAGTCTTTTCCAG
'''
primer1, primer2 = parse(primers, ds=False)
xks1_pcr_product = pcr(primer1, primer2, xks1_gene)

YEp24PGK_bgl = YEp24PGK.cut(BglII).pop()
stuffer1, xks1_bam, stuffer2 = xks1_pcr_product.cut(BamHI)

YEp24PGK_XK = (YEp24PGK_bgl + xks1_bam.rc()).looped()

YEp24PGK_XK = YEp24PGK_XK.synced(YEp24PGK)

print "The sequence of YEp24PGK_XK was generated"

print "Seguid of YEp24PGK_XK is correct", YEp24PGK_XK.seguid(
) == "HRVpCEKWcFsKhw/W+25ednUfldI"

YEp24PGK_XK.write("YEp24PGK_XK.gb")
Esempio n. 12
0
def test_read_from_unicode():
    with open("pth1.txt", "rU") as f:
        text = f.read()
    assert type(text) == str
    x, y = parse(text)
    assert x.format()[3314:3325] == '2micron 2\xc2\xb5'
Esempio n. 13
0
 p578,
 p468,
 p467,
 p567,
 p568,
 p775,
 p778,
 p342) = pydna.parse( u'''  >577
                            gttctgatcctcgagcatcttaagaattc
                            >578
                            gttcttgtctcattgccacattcataagt
                            >468
                            gtcgaggaacgccaggttgcccact
                            >467
                            ATTTAAatcctgatgcgtttgtctgcacaga
                            >567
                            GTcggctgcaggtcactagtgag
                            >568
                            GTGCcatctgtgcagacaaacg
                            >775
                            gcggccgctgacTTAAAT
                            >778
                            ggtaaatccggatTAATTAA
                            >342
                            CCTTTTTACGGTTCCTGGCCT''', ds=False)




def add_line_block(s):
    return  u"\n".join( u"|{}".format(line) for line in s.splitlines())
Esempio n. 14
0
def test_read_from_unicode():
    with open("pth1.txt", "rU") as f: text = f.read()
    x,y = parse( text )
    assert x.format()[3270:3281] == '2micron 2\xc2\xb5'
Esempio n. 15
0
    def test_parse1(self):
        ''' test parsing fasta sequences from a text'''

        text = '''
                points....: 1

                The sequence seq below represents a double stranded linear DNA molecule.

                >seq
                CTCCCCTATCACCAGGGTACCGATAGCCACGAATCT

                Give the sequence(s) of the fragment(s) formed after digesting seq
                with the restriction enzyme Acc65I in the order that they appear in seq.

                Use FASTA format and give the Watson strand(s) in 5'-3' direction below.
                Give the sequences the names frag1,frag2,... etc.
                >frag1
                CTCCCCTATCACCAGG

                >frag2
                GTACCGATAGCCACGAATCT

                *********** Question 4 ***********

                QuestionID:
                '''
        result = parse(text)

        correct = [
            'CTCCCCTATCACCAGGGTACCGATAGCCACGAATCT', 'CTCCCCTATCACCAGG',
            'GTACCGATAGCCACGAATCT'
        ]

        self.assertEqual([str(s.seq) for s in result], correct)

        self.assertEqual([s.linear for s in result], [True, True, True])

        input = '''
                LOCUS       ScCYC1                   330 bp    DNA              UNK 01-JAN-1980
                DEFINITION  ScCYC1
                ACCESSION   ScCYC1
                VERSION     ScCYC1
                KEYWORDS    .
                SOURCE      .
                  ORGANISM  .
                            .
                FEATURES             Location/Qualifiers
                ORIGIN
                        1 ATGACTGAAT TCAAGGCCGG TTCTGCTAAG AAAGGTGCTA CACTTTTCAA GACTAGATGT
                       61 CTACAATGCC ACACCGTGGA AAAGGGTGGC CCACATAAGG TTGGTCCAAA CTTGCATGGT
                      121 ATCTTTGGCA GACACTCTGG TCAAGCTGAA GGGTATTCGT ACACAGATGC CAATATCAAG
                      181 AAAAACGTGT TGTGGGACGA AAATAACATG TCAGAGTACT TGACTAACCC AAAGAAATAT
                      241 ATTCCTGGTA CCAAGATGGC CTTTGGTGGG TTGAAGAAGG AAAAAGACAG AAACGACTTA
                      301 ATTACCTACT TGAAAAAAGC CTGTGAGTAA
                //
                '''
        result = parse(input).pop()

        self.assertEqual(str(result.seq), str(read(input).seq))

        correct = '''ATGACTGAATTCAAGGCCGGTTCTGCTAAGAAAGGTGCTACACTTTTCAAGACTAGATGTCTACAATGCCACACCGTGGAAAAGGGTGGCCCACATAAGGTTGGTCCAAACTTGCATGGTATCTTTGGCAGACACTCTGGTCAAGCTGAAGGGTATTCGTACACAGATGCCAATATCAAGAAAAACGTGTTGTGGGACGAAAATAACATGTCAGAGTACTTGACTAACCCAAAGAAATATATTCCTGGTACCAAGATGGCCTTTGGTGGGTTGAAGAAGGAAAAAGACAGAAACGACTTAATTACCTACTTGAAAAAAGCCTGTGAGTAA'''

        self.assertEqual(str(result.seq), correct)

        self.assertTrue(result.linear == True)
        self.assertTrue(result.circular == False)

        seqs = parse('./RefDataBjorn.fas')

        self.assertEqual(len(seqs), 771)
        self.assertEqual(list(set([len(a) for a in seqs])), [901])

        pAG25 = read("./pAG25.gb")

        self.assertTrue(pAG25.circular == True)
        self.assertTrue(pAG25.linear == False)

        pCAPs = read("./pCAPs.gb")

        self.assertTrue(pCAPs.circular == True)
        self.assertTrue(pCAPs.linear == False)

        pUC19 = read("./pUC19.gb")

        self.assertTrue(pUC19.circular == True)
        self.assertTrue(pUC19.linear == False)
Esempio n. 16
0
def test_read_from_unicode():
    with open("pth1.txt", "rU") as f: text = f.read()
    assert type(text) == str
    x,y = parse( text )
    assert x.format()[3314:3325] == '2micron 2\xc2\xb5'
Esempio n. 17
0
    def test_pcr(self):
        ''' test pcr'''

        raw = []

        raw.append((
            '7JOV1MJBZJp2Smja/7KFGhS2SWY',
            parse('''
        >524_pFA6aF (29-mer)
        cacatacgatttaggtgacactatagaac

        >523_AgTEF1tpR (21-mer)
        ggttgtttatgttcggatgtg
        '''),
            parse("./pAG25.gb"),
        ))

        raw.append((
            '7pPxy/bQvs4+7CaOgiywQVzUFDc',
            parse('''
        >lowgc_f
        TTTCACTAGTTACTTGTAGTCGacgtgccatctgtgcagacaaacgcatcaggatat

        >lowgc_r
        AAGTTGGAAATCTAGCTTTTCTTgacgtcagcggccgcattgcaca
        '''),
            parse("./pCAPs.gb"),
        ))

        raw.append((
            '7JOV1MJBZJp2Smja/7KFGhS2SWY',
            parse('''
        >524_pFA6aF (29-mer)
        cacatacgatttaggtgacactatagaac

        >523_AgTEF1tpR (21-mer)
        ggttgtttatgttcggatgtg
        '''),
            parse("../tests/pAG25.gb"),
        ))

        raw.append((
            'yshvYTXr9iXCnh3YytWQRDBNQzI',
            parse('''
        >ForwardPrimer1
        gctactacacacgtactgactg

        >ReversePrimer
        tgtggttactgactctatcttg

        LOCUS       sequence_50_bp            46 bp    DNA     circular UNK 08-FEB-2013
        DEFINITION  sequence_50_bp circular
        ACCESSION   sequence_50_bp
        VERSION     sequence_50_bp
        KEYWORDS    .
        SOURCE      .
          ORGANISM  .
                    .
        FEATURES             Location/Qualifiers
        ORIGIN
                1 ccaagataga gtcagtaacc acagctacta cacacgtact gactgt
        //

        '''),
        ))

        raw.append((
            'yshvYTXr9iXCnh3YytWQRDBNQzI',
            parse('''
        >ForwardPrimer2
        gctactacacacgtactgactg

        >ReversePrimer
        tgtggttactgactctatcttg

        LOCUS       template                  46 bp    DNA     circular UNK 15-OCT-2012
        DEFINITION  template circular
        ACCESSION   template
        VERSION     template
        KEYWORDS    .
        SOURCE      .
          ORGANISM  .
                    .
        FEATURES             Location/Qualifiers
        ORIGIN
                1 ccaagataga gtcagtaacc acagctacta cacacgtact gactgt
        //
        '''),
        ))
        raw.append((
            'yshvYTXr9iXCnh3YytWQRDBNQzI',
            parse('''
        >ForwardPrimer3
        gctactacacacgtactgactg

        >ReversePrimer
        tgtggttactgactctatcttg

        LOCUS       template                  46 bp    DNA     circular UNK 08-FEB-2013
        DEFINITION  template circular
        ACCESSION   template
        VERSION     template
        KEYWORDS    .
        SOURCE      .
          ORGANISM  .
                    .
        FEATURES             Location/Qualifiers
        ORIGIN
                1 tccaagatag agtcagtaac cacagctact acacacgtac tgactg
        //
        '''),
        ))

        raw.append((
            'yshvYTXr9iXCnh3YytWQRDBNQzI',
            parse('''
        >ForwardPrimer4
        gctactacacacgtactgactg

        >ReversePrimer
        tgtggttactgactctatcttg

        LOCUS       template                  46 bp    DNA     circular UNK 15-OCT-2012
        DEFINITION  template circular
        ACCESSION   template
        VERSION     template
        KEYWORDS    .
        SOURCE      .
          ORGANISM  .
                    .
        FEATURES             Location/Qualifiers
        ORIGIN
                1 gtccaagata gagtcagtaa ccacagctac tacacacgta ctgact
        //
        '''),
        ))

        raw.append((
            '60meNXeGKO7ahZwcIl5yXHFC3Yg',
            parse('''
        >fw1
        cacatacgatttaggtgacactatagaac
        >rv
        ggttgtttatgttcggatgtg

        LOCUS       tm                        50 bp    DNA     circular UNK 15-OCT-2012
        DEFINITION  tm circular
        ACCESSION   tm
        VERSION     tm
        KEYWORDS    .
        SOURCE      .
          ORGANISM  .
                    .
        FEATURES             Location/Qualifiers
        ORIGIN
                1 cacatccgaa cataaacaac ccacatacga tttaggtgac actatagaac
        //
        '''),
        ))

        raw.append((
            '60meNXeGKO7ahZwcIl5yXHFC3Yg',
            parse('''
        >fw2
        cacatacgatttaggtgacactatagaac
        >rv
        ggttgtttatgttcggatgtg

        LOCUS       tm                        50 bp    DNA     circular UNK 15-OCT-2012
        DEFINITION  tm circular
        ACCESSION   tm
        VERSION     tm
        KEYWORDS    .
        SOURCE      .
          ORGANISM  .
                    .
        FEATURES             Location/Qualifiers
        ORIGIN
                1 acatccgaac ataaacaacc cacatacgat ttaggtgaca ctatagaacc
        //

        '''),
        ))

        raw.append((
            '60meNXeGKO7ahZwcIl5yXHFC3Yg',
            parse('''
        >fw3
        cacatacgatttaggtgacactatagaac
        >rv
        ggttgtttatgttcggatgtg
        LOCUS       tm                        50 bp    DNA     circular UNK 15-OCT-2012
        DEFINITION  tm circular
        ACCESSION   tm
        VERSION     tm
        KEYWORDS    .
        SOURCE      .
          ORGANISM  .
                    .
        FEATURES             Location/Qualifiers
        ORIGIN
                1 ccacatccga acataaacaa cccacatacg atttaggtga cactatagaa
        //

        '''),
        ))

        raw.append((
            'y6ohCJ4O+8Is012DItz4F4saxNo',
            parse('''
        >f_Eric_Ma
        ARATGAGTCTTCTRACCGAGGTCG
        >r_Eric_Ma
        TGAAAAGACATCYTCAAGYYTCTG
        >templ
        AGCAAAAGCAGGTAGATATTGAAAAATGAGTCTTCTAACCGAGGTCGAAACGTACGTTCTCTCTATCGTCCCGTCAGGCCCCCTCAAAGCCGAGATCGCGCAGAGACTTGAAGATGTCTCTGCAGGGAAGAACACTGATCTCGAGGCTCTCATGGAATGGCTAAAGACAAGACCAATCCTGTCACCTCTGACTAAGGGGATTTTAGGGTTTGTGTTCACGCTCACCGTGCCCAGTGAGCGAGGACTGCAGCGTAGACGCTTTGTCCAGAATGCCTTAAATGGGAATGGAGACCCAAACAACATGGACAGGGCAGTCAAACTATACAGGAAGCTGAAAAGAGAGATAACATTCCATGGGGCTAAAGAGGTTGCACTCAGCTATTCAACCGGTGCACTTGCCAGTTGCATGGGTCTCATATACAACAGGATGGGAACGGTAACCACAGAAGTAGCTTTTGGCCTGGTGTGTGCCACTTGTGAGCAGATTGCTGACTCACAGCATCGATCTCACAGACAGATGGTGACTACCACCAACCCACTAATCAGGCATGAAAACAGAATGGTGCTGGCCAGCACTACAGCTAAGGCTATGGAGCAGATGGCTGGATCGAGTGAACAGGCAGCGGAAGCCATGGAGGTTGCTAGTCAGGCTAGGCAGATGGTGCAGGCAATGAGGACAATTGGGACTCACCCTAGCTCCAGTGCCGGTCTGAAAGATGATCTTCTTGAAAATTTGCAGGCCTACCAGAAGCGGATGGGAGTGCAAATGCAGCGATTCAAGTGATCCTCTCGTTATTGCCGCAAGTATCATTGGGATCTTGCACTTGATATTGTGGATTCTTGATCGTCCTTTCTTCAAATGTATTTATCGTCGCCTTAAATACGGTTTGAAAAGAGGGCCTTCTACGGAAGGAGTGCCTGAGTCTATGAGGGAAGAGTATCGGCAGGAACAGCAGAGTGCTGTGGATGTTGACGATGGTCATTTTGTCAACATAGAGCTGGAGTAAAAAACTACCTTGTTTCTACT
        '''),
        ))

        for key, tst in enumerate(raw):
            print key
            print tst[1][0].name
            print "pcr test", key
            print
            self.assertEqual(tst[0], seguid(pcr(tst[1:]).seq))

#######################################################
gb = pydna.Genbank("*****@*****.**") # Tell Genbank who you are!

gene = gb.nucleotide("X06997") # Kluyveromyces lactis LAC12 gene for lactose permease.

#######################################################


genome = pydna.read('FSC237.fasta')

#genome = fasta_seq('FSC237.fasta')
primer_f,primer_r = pydna.parse(''' >B4_400_1-F
                                    AGCAGTGCCTGTTGTACC

                                    >B4_400_1-R
                                    AGTTTCTCAACATGGAAT
                                    ''', ds=False)

pcr_prod = pydna.pcr(primer_f,primer_r, genome)



#stssearch  -seqall genome.fasta -infile primers.txt -stdout --auto
primersearch  -seqall genome.fasta -infile primers.txt -mismatchpercent 1 -stdout --auto -mismatchpercent 10
primersearch  -seqall ../../rawdata/FSC770.1.fna -infile primers.txt -mismatchpercent 1 -stdout --auto -mismatchpercent 20 -scircular1



Esempio n. 19
0
    print "Genbank record KC562906 downloaded from NCBI\n"
else:
    xks1_gene = read("Z72979.gb")
    print "A local copy of Genbank record Z72979 is used"
    YEp24PGK  = read("KC562906.gb")
    print "A local copy of Genbank record KC562906 is used\n"

raw_input("press return!\n")

primers='''
>primer1
GCGGATCCTCTAGAATGGTTTGTTCAGTAATTCAG
>primer3
AGATCTGGATCCTTAGATGAGAGTCTTTTCCAG
'''
primer1, primer2 = parse(primers, ds=False)
xks1_pcr_product = pcr(primer1, primer2, xks1_gene)

YEp24PGK_bgl = YEp24PGK.cut(BglII).pop()
stuffer1, xks1_bam, stuffer2 = xks1_pcr_product.cut(BamHI)

YEp24PGK_XK = (YEp24PGK_bgl+xks1_bam.rc()).looped()

YEp24PGK_XK = YEp24PGK_XK.synced(YEp24PGK)

print "The sequence of YEp24PGK_XK was generated"

print "Seguid of YEp24PGK_XK is correct", YEp24PGK_XK.seguid() == "HRVpCEKWcFsKhw/W+25ednUfldI"

YEp24PGK_XK.write("YEp24PGK_XK.gb")
Esempio n. 20
0
# coding: utf-8
from pydna import parse, eq

new_primer = parse("/home/bjorn/Dropbox/wikidata/PrimersToBuy.wiki", ds=False)
primer = parse("/home/bjorn/Dropbox/wikidata/Primers.wiki", ds=False)

primer = primer[::-1]
old_primer = primer[:37 + 18]
primer = primer[37 + 18:]

new_primer_dict = dict((p.id, p) for p in new_primer)
primer_dict = dict((p.id, p) for p in primer)
old_primer_dict = dict((p.id, p) for p in old_primer)

assert str(primer_dict["509_mycGFPr"].seq) == "CTACTTGTACAGCTCGTCCA"
assert primer[0].id == "0_S1"
assert primer[1].id == "1_5CYC1clone"
assert primer[580].id == "580_GXF1_YPK_fwd"

fprimer = parse("/home/bjorn/Dropbox/wikidata/New10.wiki", ds=False)
fprimer = fprimer[::-1]
fold_primer = fprimer[:37 + 18]
fprimer = fprimer[37 + 18:]

print len(primer), len(fprimer)

for i in range(1, len(primer)):
    if not eq(primer[i], fprimer[i]):
        print i
        print primer[i].id, fprimer[i].id
        raw_input()
Esempio n. 21
0
    def test_parse1(self):
        ''' test parsing fasta sequences from a text'''

        text   =  '''
                points....: 1

                The sequence seq below represents a double stranded linear DNA molecule.

                >seq
                CTCCCCTATCACCAGGGTACCGATAGCCACGAATCT

                Give the sequence(s) of the fragment(s) formed after digesting seq
                with the restriction enzyme Acc65I in the order that they appear in seq.

                Use FASTA format and give the Watson strand(s) in 5'-3' direction below.
                Give the sequences the names frag1,frag2,... etc.
                >frag1
                CTCCCCTATCACCAGG

                >frag2
                GTACCGATAGCCACGAATCT

                *********** Question 4 ***********

                QuestionID:
                '''
        result = parse(text)

        correct = ['CTCCCCTATCACCAGGGTACCGATAGCCACGAATCT',
                   'CTCCCCTATCACCAGG',
                   'GTACCGATAGCCACGAATCT']

        self.assertEqual( [str(s.seq) for s in result], correct )

        self.assertEqual( [s.linear for s in result], [True,True,True] )


        input =   '''
                LOCUS       ScCYC1                   330 bp    DNA              UNK 01-JAN-1980
                DEFINITION  ScCYC1
                ACCESSION   ScCYC1
                VERSION     ScCYC1
                KEYWORDS    .
                SOURCE      .
                  ORGANISM  .
                            .
                FEATURES             Location/Qualifiers
                ORIGIN
                        1 ATGACTGAAT TCAAGGCCGG TTCTGCTAAG AAAGGTGCTA CACTTTTCAA GACTAGATGT
                       61 CTACAATGCC ACACCGTGGA AAAGGGTGGC CCACATAAGG TTGGTCCAAA CTTGCATGGT
                      121 ATCTTTGGCA GACACTCTGG TCAAGCTGAA GGGTATTCGT ACACAGATGC CAATATCAAG
                      181 AAAAACGTGT TGTGGGACGA AAATAACATG TCAGAGTACT TGACTAACCC AAAGAAATAT
                      241 ATTCCTGGTA CCAAGATGGC CTTTGGTGGG TTGAAGAAGG AAAAAGACAG AAACGACTTA
                      301 ATTACCTACT TGAAAAAAGC CTGTGAGTAA
                //
                '''
        result = parse(input).pop()

        self.assertEqual( str(result.seq) , str(read(input).seq) )

        correct = '''ATGACTGAATTCAAGGCCGGTTCTGCTAAGAAAGGTGCTACACTTTTCAAGACTAGATGTCTACAATGCCACACCGTGGAAAAGGGTGGCCCACATAAGGTTGGTCCAAACTTGCATGGTATCTTTGGCAGACACTCTGGTCAAGCTGAAGGGTATTCGTACACAGATGCCAATATCAAGAAAAACGTGTTGTGGGACGAAAATAACATGTCAGAGTACTTGACTAACCCAAAGAAATATATTCCTGGTACCAAGATGGCCTTTGGTGGGTTGAAGAAGGAAAAAGACAGAAACGACTTAATTACCTACTTGAAAAAAGCCTGTGAGTAA'''

        self.assertEqual( str(result.seq) , correct )

        self.assertTrue( result.linear   == True )
        self.assertTrue( result.circular == False )

        seqs = parse('./RefDataBjorn.fas')

        self.assertEqual( len(seqs) , 771 )
        self.assertEqual( list(set([len (a) for a in seqs])) ,[901])

        pAG25 = read("./pAG25.gb")

        self.assertTrue( pAG25.circular == True )
        self.assertTrue( pAG25.linear   == False)

        pCAPs = read("./pCAPs.gb")

        self.assertTrue( pCAPs.circular == True )
        self.assertTrue( pCAPs.linear   == False)

        pUC19 = read("./pUC19.gb")

        self.assertTrue( pUC19.circular == True )
        self.assertTrue( pUC19.linear   == False)
Esempio n. 22
0
def test_primer_Design_saving_to_text_file():

    files_ = [dedent(x) for x in
    ('''\
    >fw64 t-sequence
    atgactgctaacccttc
    >rv64 t-sequence
    catcgtaagtttcgaac''',

    '''\
    >fw64 t-sequence
    atgactgctaacccttcN
    >rv64 t-sequence
    catcgtaagtttcgaacN''',

    '''\
    >fw64 t-sequence
    atgactgctaacccttcN''',

    '''\
    >fw64 t-sequence
    atgactgctaacccttcN
    >rv64 t-sequence
    catcgtaagtttcgaac''',

    '''\
    >rv64 t-sequence
    catcgtaagtttcgaacN''',

    '''\
    >rv64 t-sequence
    catcgtaagtttcgaacN
    >fw64 t-sequence
    atgactgctaacccttc''',

    '''\
    >fw64 t-sequenceZ
    atgactgctaacccttc
    >rv64 t-sequenceZ
    catcgtaagtttcgaac''',

    '''\
    >fw64 t-sequenceZ
    atgactgctaacccttc
    >rv64 t-sequenceZ
    catcgtaagtttcgaac
    >fw64 t-sequence
    atgactgctaacccttc
    >rv64 t-sequence
    catcgtaagtttcgaac''',

    '''\
    >fw64x t-sequence
    atgactgctaacccttc
    >rv64x t-sequence
    catcgtaagtttcgaac''',

    '''\
    >fw64x t-sequence
    atgactgctaacccttc
    >rv64x t-sequence
    catcgtaagtttcgaac
    >fw64 t-sequence
    atgactgctaacccttc
    >rv64 t-sequence
    catcgtaagtttcgaac''',
    )]

    templ=Dseqrecord("atgactgctaacccttccttggtgttgaacaagatcgacgacatttcgttcgaaacttacgatg")

    templ.accession = "t-sequence"

    try:
        os.remove("PRIMERS.TXT")
    except OSError:
        pass

    pf, pr = cloning_primers(templ, path="PRIMERS.TXT")

    assert os.path.isfile("PRIMERS.TXT")

    with open("PRIMERS.TXT", "r") as f: text=f.read().strip()

    assert text == files_[0]

    with open("PRIMERS.TXT", "w") as f: text=f.write(files_[1])

    pf, pr = cloning_primers(templ, path="PRIMERS.TXT")

    with open("PRIMERS.TXT", "r") as f: text=f.read().strip()

    assert text == files_[1]

    with open("PRIMERS.TXT", "w") as f: text=f.write(files_[2])

    pf, pr = cloning_primers(templ, path="PRIMERS.TXT")

    with open("PRIMERS.TXT", "r") as f: text=f.read().strip()

    assert text == files_[3]

    with open("PRIMERS.TXT", "w") as f: text=f.write(files_[4])

    pf, pr = cloning_primers(templ, path="PRIMERS.TXT")

    with open("PRIMERS.TXT", "r") as f: text=f.read().strip()

    assert text == files_[5]

    with open("PRIMERS.TXT", "w") as f: text=f.write(files_[6])

    pf, pr = cloning_primers(templ, path="PRIMERS.TXT")

    with open("PRIMERS.TXT", "r") as f: text=f.read().strip()

    assert text == files_[7]

    with open("PRIMERS.TXT", "w") as f: text=f.write(files_[8])

    pf, pr = cloning_primers(templ, path="PRIMERS.TXT")

    with open("PRIMERS.TXT", "r") as f: text=f.read().strip()

    assert text == files_[9]

    with open("PRIMERS.TXT", "w") as f: text=f.write('')

    pf, pr = cloning_primers(templ, path="PRIMERS.TXT")

    f, r = parse("PRIMERS.TXT", ds=False)

    assert f.description == "fw64 t-sequence"
    assert r.description == "rv64 t-sequence"
Esempio n. 23
0
    def test_pcr(self):
        ''' test pcr'''

        raw=[]

        raw.append(

        ('7JOV1MJBZJp2Smja/7KFGhS2SWY',

        parse('''
        >524_pFA6aF (29-mer)
        cacatacgatttaggtgacactatagaac

        >523_AgTEF1tpR (21-mer)
        ggttgtttatgttcggatgtg
        '''),

        parse("./pAG25.gb"),)
        )

        raw.append(

        ('7pPxy/bQvs4+7CaOgiywQVzUFDc',

        parse('''
        >lowgc_f
        TTTCACTAGTTACTTGTAGTCGacgtgccatctgtgcagacaaacgcatcaggatat

        >lowgc_r
        AAGTTGGAAATCTAGCTTTTCTTgacgtcagcggccgcattgcaca
        '''),
        parse("./pCAPs.gb"),)
        )

        raw.append(

        ('7JOV1MJBZJp2Smja/7KFGhS2SWY',

        parse('''
        >524_pFA6aF (29-mer)
        cacatacgatttaggtgacactatagaac

        >523_AgTEF1tpR (21-mer)
        ggttgtttatgttcggatgtg
        '''),

        parse("../tests/pAG25.gb"),

        ))

        raw.append(

        ('yshvYTXr9iXCnh3YytWQRDBNQzI',

        parse('''
        >ForwardPrimer1
        gctactacacacgtactgactg

        >ReversePrimer
        tgtggttactgactctatcttg

        LOCUS       sequence_50_bp            46 bp    DNA     circular UNK 08-FEB-2013
        DEFINITION  sequence_50_bp circular
        ACCESSION   sequence_50_bp
        VERSION     sequence_50_bp
        KEYWORDS    .
        SOURCE      .
          ORGANISM  .
                    .
        FEATURES             Location/Qualifiers
        ORIGIN
                1 ccaagataga gtcagtaacc acagctacta cacacgtact gactgt
        //

        '''),))

        raw.append(

        ('yshvYTXr9iXCnh3YytWQRDBNQzI',

        parse('''
        >ForwardPrimer2
        gctactacacacgtactgactg

        >ReversePrimer
        tgtggttactgactctatcttg

        LOCUS       template                  46 bp    DNA     circular UNK 15-OCT-2012
        DEFINITION  template circular
        ACCESSION   template
        VERSION     template
        KEYWORDS    .
        SOURCE      .
          ORGANISM  .
                    .
        FEATURES             Location/Qualifiers
        ORIGIN
                1 ccaagataga gtcagtaacc acagctacta cacacgtact gactgt
        //
        '''),))
        raw.append(

        ('yshvYTXr9iXCnh3YytWQRDBNQzI',

        parse('''
        >ForwardPrimer3
        gctactacacacgtactgactg

        >ReversePrimer
        tgtggttactgactctatcttg

        LOCUS       template                  46 bp    DNA     circular UNK 08-FEB-2013
        DEFINITION  template circular
        ACCESSION   template
        VERSION     template
        KEYWORDS    .
        SOURCE      .
          ORGANISM  .
                    .
        FEATURES             Location/Qualifiers
        ORIGIN
                1 tccaagatag agtcagtaac cacagctact acacacgtac tgactg
        //
        '''),))

        raw.append(
        ('yshvYTXr9iXCnh3YytWQRDBNQzI',

        parse('''
        >ForwardPrimer4
        gctactacacacgtactgactg

        >ReversePrimer
        tgtggttactgactctatcttg

        LOCUS       template                  46 bp    DNA     circular UNK 15-OCT-2012
        DEFINITION  template circular
        ACCESSION   template
        VERSION     template
        KEYWORDS    .
        SOURCE      .
          ORGANISM  .
                    .
        FEATURES             Location/Qualifiers
        ORIGIN
                1 gtccaagata gagtcagtaa ccacagctac tacacacgta ctgact
        //
        '''),))

        raw.append(
        ('60meNXeGKO7ahZwcIl5yXHFC3Yg',
        parse('''
        >fw1
        cacatacgatttaggtgacactatagaac
        >rv
        ggttgtttatgttcggatgtg

        LOCUS       tm                        50 bp    DNA     circular UNK 15-OCT-2012
        DEFINITION  tm circular
        ACCESSION   tm
        VERSION     tm
        KEYWORDS    .
        SOURCE      .
          ORGANISM  .
                    .
        FEATURES             Location/Qualifiers
        ORIGIN
                1 cacatccgaa cataaacaac ccacatacga tttaggtgac actatagaac
        //
        '''),)
        )

        raw.append(

        ('60meNXeGKO7ahZwcIl5yXHFC3Yg',
        parse('''
        >fw2
        cacatacgatttaggtgacactatagaac
        >rv
        ggttgtttatgttcggatgtg

        LOCUS       tm                        50 bp    DNA     circular UNK 15-OCT-2012
        DEFINITION  tm circular
        ACCESSION   tm
        VERSION     tm
        KEYWORDS    .
        SOURCE      .
          ORGANISM  .
                    .
        FEATURES             Location/Qualifiers
        ORIGIN
                1 acatccgaac ataaacaacc cacatacgat ttaggtgaca ctatagaacc
        //

        '''),)
        )

        raw.append(

        ('60meNXeGKO7ahZwcIl5yXHFC3Yg',
        parse('''
        >fw3
        cacatacgatttaggtgacactatagaac
        >rv
        ggttgtttatgttcggatgtg
        LOCUS       tm                        50 bp    DNA     circular UNK 15-OCT-2012
        DEFINITION  tm circular
        ACCESSION   tm
        VERSION     tm
        KEYWORDS    .
        SOURCE      .
          ORGANISM  .
                    .
        FEATURES             Location/Qualifiers
        ORIGIN
                1 ccacatccga acataaacaa cccacatacg atttaggtga cactatagaa
        //

        '''),)
        )


        raw.append(
        ('y6ohCJ4O+8Is012DItz4F4saxNo',
        parse('''
        >f_Eric_Ma
        ARATGAGTCTTCTRACCGAGGTCG
        >r_Eric_Ma
        TGAAAAGACATCYTCAAGYYTCTG
        >templ
        AGCAAAAGCAGGTAGATATTGAAAAATGAGTCTTCTAACCGAGGTCGAAACGTACGTTCTCTCTATCGTCCCGTCAGGCCCCCTCAAAGCCGAGATCGCGCAGAGACTTGAAGATGTCTCTGCAGGGAAGAACACTGATCTCGAGGCTCTCATGGAATGGCTAAAGACAAGACCAATCCTGTCACCTCTGACTAAGGGGATTTTAGGGTTTGTGTTCACGCTCACCGTGCCCAGTGAGCGAGGACTGCAGCGTAGACGCTTTGTCCAGAATGCCTTAAATGGGAATGGAGACCCAAACAACATGGACAGGGCAGTCAAACTATACAGGAAGCTGAAAAGAGAGATAACATTCCATGGGGCTAAAGAGGTTGCACTCAGCTATTCAACCGGTGCACTTGCCAGTTGCATGGGTCTCATATACAACAGGATGGGAACGGTAACCACAGAAGTAGCTTTTGGCCTGGTGTGTGCCACTTGTGAGCAGATTGCTGACTCACAGCATCGATCTCACAGACAGATGGTGACTACCACCAACCCACTAATCAGGCATGAAAACAGAATGGTGCTGGCCAGCACTACAGCTAAGGCTATGGAGCAGATGGCTGGATCGAGTGAACAGGCAGCGGAAGCCATGGAGGTTGCTAGTCAGGCTAGGCAGATGGTGCAGGCAATGAGGACAATTGGGACTCACCCTAGCTCCAGTGCCGGTCTGAAAGATGATCTTCTTGAAAATTTGCAGGCCTACCAGAAGCGGATGGGAGTGCAAATGCAGCGATTCAAGTGATCCTCTCGTTATTGCCGCAAGTATCATTGGGATCTTGCACTTGATATTGTGGATTCTTGATCGTCCTTTCTTCAAATGTATTTATCGTCGCCTTAAATACGGTTTGAAAAGAGGGCCTTCTACGGAAGGAGTGCCTGAGTCTATGAGGGAAGAGTATCGGCAGGAACAGCAGAGTGCTGTGGATGTTGACGATGGTCATTTTGTCAACATAGAGCTGGAGTAAAAAACTACCTTGTTTCTACT
        '''),)
        )

        for key, tst in enumerate(raw):
            print key
            print tst[1][0].name
            print "pcr test", key
            print
            self.assertEqual(tst[0], seguid(pcr(tst[1:]).seq))
Esempio n. 24
0
#!/usr/bin/env python
# -*- coding: utf-8 -*- 

from pydna import pcr, parse, Assembly
from Bio.Restriction import ZraI, AjiI, EcoRV

from pYPK0 import pYPK0

p167,p166 = parse('''>167_pCAPSfw (24-mer)
                     TCCTGACGGGTAATTTTGATTTGC
                     >166_pCAPSrv (24-mer)
                     CTGTGAAGTGGCTGAAATTTCGTA''')                      

p413,p625 = parse('''>413_ScPDC1tpf (24-mer)
                     TTAAATAAGGGTAGCCTCCCCATA
                     >625_ScPDC1tpr_PacI (34-mer)
                     taattaaTTTGATTGATTTGACTGTGTTATTTTG''', ds=False)
                       
p648,p647 = parse('''>648_ScRPS19btpf2
                     ttaaatTCTAGTATGGTTTGAAACCT 
                     >647_ScRPS19btpr_PacI
                     taattaaCTTTATTATCTTTGGTTCTAT''', ds=False)


#652
p538,p651 = parse('''>538_ScRPS19atpr_FspA (26-mer)
                     gcgcatGTTAACTGAAATGAAAATTT                         
                     >651_ScRPS19atpr_PacI
                     taattaaTTTTACTCTATTTGTCGATC''', ds=False)

p419,p621 = parse('''>419_ScTPI1tpf (32-mer)