<jupyter_start><jupyter_text>This is a Python notebook.  It ships with the default kernel (IPython), which is one of the most featurefull kernels.  As any other kernels, Notebook can contain narrative (in markdown) including math.Classical exponetial decay: $$r(t) = A.e^{(-t/\tau)}$$WE can plot such an exponential decay using matplotlib.<jupyter_code>%matplotlib inline
from numpy import arange, exp
from  matplotlib.pyplot import plot, ylim
t = arange(0,10, 0.1)
from ipywidgets import interact

@interact(τ=(0.1,5, 0.1))
def decay(τ=3):
    plot(t, exp(-t/τ))
    ylim(0,1.1)
# this does not work (yet) on JupyterLab py3dMol need to be updated.
import py3Dmol

styles = ['stick', 'cartoon','line', 'cross', 'sphere']

mols = {'actin M':'1J6Z','GFP':'4KW4','Arp2/3':'1K8K', 'Zika':'5IRE', 'acin F':'6BNO'}

@interact(mol=mols, style=styles)
def view(mol, style='cartoon', assembly=False, color='spectrum'):
    view = py3Dmol.view(query=f'pdb:{mol}', options={'doAssembly':assembly})
    view.setStyle({style:{'color':color}})
    return view<jupyter_output><empty_output><jupyter_text>See [here](http://nbviewer.jupyter.org/github/3dmol/3Dmol.js/blob/master/py3Dmol/examples.ipynb) for more examples, plug your own from http://www.rcsb.org/<jupyter_code>%load_ext julia.magic
%%julia
using FastaIO
%%julia
sequences = Dict()
FastaReader("zika_assembled_genomes.fasta") do fr
   for (desc, seq) in fr
       sequences[desc] = seq
   end
end


function searchall(s, t, overlap::Bool=false)
    idxfcn = overlap ? first : last
    r = search(s, t)
    n = 0
    while last(r) > 0
        n += 1
        r = search(s, t, idxfcn(r) + 1)
    end
    return n
end
%%julia

function search_all_pairs(sequences)
    data = Dict()
    for (name, seq) in sequences
        stat = Dict()
        for B1 in "ACGT"
            for B2 in "ACGT"
                sub = B1*B2
                count = searchall(seq, sub, true)
                stat[sub] = count
            end
        end
        data[name] = stat
    end
    data
end
data = %julia search_all_pairs(sequences)
%matplotlib inline
import matplotlib.pyplot as plt

@interact(k1=data.keys(), k2=data.keys())
def pl(k1, k2):
    fig, (ax1, ax2, ax3) = plt.subplots(1,3)
    fig.set_figwidth(20)
    d1 = data[k1]
    ax1.bar(d1.keys(), d1.values())
    ax1.set_title(k1)
    d2 = data[k2]
    ax2.bar(d2.keys(), [a-b for a,b in zip(d1.values(), d2.values())] ) 
    ax2.axhline(0, color='k')
    ax3.bar(d2.keys(), d2.values())
    ax3.set_title(k2)

%%julia
stops = Dict()
for (name, seq) in sequences
    stat = Dict()
    for B1 in ["TAG", "TAA", "TGA"]
        count = searchall(seq, B1, true)
        stat[B1] = count
    end
    stops[name] = stat
end
stops =  %julia stops

@interact(k1=stops.keys(), k2=stops.keys())
def pl(k1, k2):
    fig, (ax1, ax2, ax3) = plt.subplots(1,3)
    fig.set_figwidth(20)
    data = stops
    d1 = data[k1]
    ax1.bar(d1.keys(), d1.values())
    ax1.set_title(k1)
    d2 = data[k2]
    ax2.bar(d2.keys(), [a-b for a,b in zip(d1.values(), d2.values())] ) 
    ax2.axhline(0, color='k')
    ax3.bar(d2.keys(), d2.values())
    ax3.set_title(k2)<jupyter_output><empty_output><jupyter_text>More resourcesSee [A gallery of interesting notebooks](https://github.com/jupyter/jupyter/wiki/A-gallery-of-interesting-Jupyter-Notebooks) which is a community curated list of notebooks:  - [An Introduction to Applied Bioinformatics](http://readiab.org/)  - [Bioinformatics with Python cookbook's notebooks](https://github.com/tiagoantao/bioinf-python/blob/master/notebooks/Welcome.ipynb)  - [An open RNA-Seq data analysis pipeline tutorial with an example of reprocessing data from a recent Zika virus study](http://nbviewer.jupyter.org/github/maayanlab/Zika-RNAseq-Pipeline/blob/master/Zika.ipynb)  - [Multi-tiered genomic analysis of head and neck cancer ties TP53 mutation to 3p loss](https://github.com/theandygross/TCGA)  Something extra : Fasta in JupyterLab<jupyter_code>from IPython.display import display
class Fasta:
    def __init__(self, data):
        self.data = data
    def _ipython_display_(self):
        bundle = {
            'application/vnd.fasta.fasta': self.data,
            'text/plain': data
        }
        display(bundle, raw=True)
with open('zika_assembled_genomes.fasta') as f:
    data = f.read()
Fasta(data)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14492753623188406, 'fraction_numerical': 0.024384633080285253, 'mean_word_length': 3.4917355371900825, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, 'https://': 3, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '615162', 'license': 'CC0-1.0', 'n_tokens_mistral': 1706, 'n_tokens_neox': 1636, 'n_words': 385, 'path': 'JGI demo.ipynb', 'repo_name': 'Carreau/JGI-demo', 'size': '4347'}