Upgrade to Pro — share decks privately, control downloads, hide ads and more …

181129_BPStudy.pdf

Saito Tsutomu
November 29, 2018
410

 181129_BPStudy.pdf

Saito Tsutomu

November 29, 2018
Tweet

Transcript

  1. ͓લ୭Αʢ1/2ʣ • ਺ཧ࠷దԽɺΦϖϨʔγϣϯζɾϦαʔνͷઐ໳Ոʢ↓ग़൛ॻ੶ʣ • ࠓ೔͔Β࢖͑Δ!૊߹ͤ࠷దԽ • PythonݴޠʹΑΔϏδωεΞφϦςΟΫε - ࣮຿ՈͷͨΊͷ࠷దԽɾ౷ܭղੳɾػցֶश -

    • ϞσϦϯάͷॾ૬ (γϦʔζ:࠷దԽϞσϦϯά) • ϚωʔδϯάɾβɾαϓϥΠɾνΣΠϯ • σʔλ෼ੳϥΠϒϥϦʔΛ༻͍ͨ࠷దԽϞσϧͷ࡞Γํ
  2. ࣾձͷ࠷దԽ໰୊ ʮORΛ୳ͤʂʯϙελʔΑΓ • ආ೉ࢪઃͷ഑ஔܭը࡞੒ • ΤωϧΪʔϚωʔδϝϯτܭը࡞੒ • ঎඼ͷ഑ஔ࠷దԽ • ళһͷγϑτεέδϡʔϦϯά

    • ঎඼ͷ഑ૹܭըͷ࡞੒ • ྻंͷӡߦεέδϡʔϦϯά • ྻंͷ৐຿һεέδϡʔϦϯά • Ӻͷ৐Γ׵͑ͷ࠷దԽ • ෺ྲྀίϯςφͷύοΩϯά • ੜ࢈ܭըͷ࡞੒ • ࡏݿܭըͷ࡞੒
  3. ࢀߟɿ८ճηʔϧεϚϯ໰୊ͷॻ੶ • ڻ͖ͷ਺ֶ ८ճηʔϧεϚϯ໰୊ɿ΢ΟϦΞϜɾJɾΫοΫ (ஶ), দӜढ़ี (຋༁) • ८ճηʔϧεϚϯ໰୊΁ͷট଴ɿࢁຊ ๕࢚

    (ஶ), ٱอ װ༤ (ஶ) • άϥϑཧ࿦ͷັ࿭ͷੈք- ८ճηʔϧεϚϯ໰୊ɺ࢛৭໰୊ɺதࠃਓ༣ศ഑ ୡ໰୊ɿΞʔαʔɾϕϯδϟϛϯ ଞ(ஶʣ
  4. ໰୊1ɿ࠷୹௒จࣈྻ໰୊ͱ͸ ೖྗɿจࣈྻͷू߹S ग़ྗɿSதͷ͢΂ͯͷจࣈྻΛ෦෼จࣈྻͱؚͯ͠Ή ࠷୹ͷจࣈྻ S = ['TAG', 'ACTA', 'GTC', 'GAC']

    ͳΒ͹ɺ ࠷୹௒จࣈྻ͸ GACTAGTCɻ ࢀߟɿʮྋٶϋϧώͷ༕ᓔʯͷ͓͔͛Ͱ25೥ղ͚ͳ͔ͬͨ਺ֶͷ೉໰ ͕ղܾ͞ΕΔ͔΋͠Εͳ͍
  5. σϞ def overlap(s,t): """sͱtͷॏͳΓͷ௕͞""" m = len(s) n = max(0,

    m-len(t)) for i in range(n,m): if s[i:] == t[:m-i]: return m-i return 0 overlap('12345' , '3456') overlap('1234' , '12345') overlap('1234' , '2345') from ortoolpy import tsp def shortest_superstring(words): """࠷୹௒จࣈྻ໰୊""" words = [''] + words n = len(words) dist = {(i, j): len(t) - overlap(s, t) for i, s in enumerate(words) for j, t in enumerate(words) if i != j} _, lst = tsp(words, dist) return ''.join(words[j][len(words[j]) - dist[i, j]:] for i, j in zip(lst, lst[1:])) shortest_superstring(['TAG', 'ACTA', 'GTC', 'GAC'])
  6. import io, pickle, requests with requests.get('https://www.dropbox.com/s/' 'rci3cofa7fiz4wr/image.pkl?dl=1') as r: with

    io.BytesIO(r.content) as fp: pieces, dist = pickle.load(fp) plt.imshow(np.concatenate(pieces), cmap='gray');
  7. n = len(pieces) lst = tsp(range(len(pieces)), dist)[1] # ๚໰ॱ res

    = [pieces[i] for i in lst] plt.imshow(np.concatenate(res), cmap='gray'); plt.imshow(np.concatenate( res[21:]+res[:21]), cmap='gray');
  8. PyQͰ໰୊ղֶܾ͕΂·͢ • ࿦ཧͱ໰୊ղܾ • ֬཰ͷ໰୊ • άϥϑཧ࿦ॳڃ • άϥϑཧ࿦தڃ •

    άϥϑΛ࢖ͬͨ࠷దԽ • ઢܗ࠷దԽॳڃ • σʔλ෼ੳͱ࠷దԽ • ૊߹ͤ࠷దԽॳڃ • ૊߹ͤ࠷దԽͰղ͘ ύζϧ શ෦Ͱ120໰ ࠓޙ΋૿͍͑ͯ͘༧ఆ