human
I am working on the file "Nature-Cooperation.ipynb".
The first task is:
Genomes are Sequences
Quasispecies equation
\begin{align}
\dot{x_i} =\sum_{j=0}^{n} x_j ~ f_j ~ q_{ji} - \phi x_i.
\end{align}

$x$: population ratio of type $i$.
$f_i$: fitness for type $i$.
$q_{ji}$: probability of mutation from type $j$ to $i$
$q_{ji} = u^{h_ij}(1-u)^{L-h_{ij}}$  $~L:$ Length of genome. $~u:$ mutation prob. at one gene.
Can you write Python code for it?
 ... Give me a the Python code you requested?
assistant
#Here is the Python code you requested.

fig = plt.figure()
plt.close(fig)

def genomeSequence(N,drich_alpha,point_mut):
  np.random.seed(0)
  clear_output(wait=True)
  if point_mut is not None:
    L,u = point_mut
  t_f = 10 
  dt = 0.1
  
  x_ = np.random.uniform(size=(N))
  x_ = x_/x_.sum()

  f = np.random.lognormal(size=(N))
  
  if drich_alpha is not None:
    Q = np.zeros((N,N))
    for j in range(N):    
      Q[j,:] = np.random.dirichlet(np.roll(np.logspace(1,drich_alpha+1,N)[::-1], j), 1)
  elif point_mut is not None:
    Q = np.zeros((N,N))
    for j in range(N):
      for i in range(N):
        Q[j,i] = (u**(np.abs(j-i)))*((1-u)**(L-np.abs(j-i)))
  else:
    print("One of the two arguments should not be None")
    return
  
  def int_(t,x):
    x = np.asarray(x).reshape((x.shape[0],1))
    dev = np.zeros(x.shape[0])
    mean = f.dot(x)
    for i in range(x.shape[0]):
      for j in range(x.shape[0]):
        dev[i] += f[j]*Q[j,i]*x[j]
      dev[i] -= mean*x[i]
    return dev

  integ = integrate.ode(int_)
  integ.set_integrator("dopri5").set_initial_value(np.asarray(x_))
  y = np.zeros((int(t_f/dt)+1,x_.shape[0]))
  x = np.zeros((int(t_f/dt)+1,x_.shape[0]))
  xdot = np.zeros((int(t_f/dt)+1,x_.shape[0]))

  i = 0
  while integ.successful() and integ.t<t_f:
    y[i,:] = integ.y
    x[i,:] = integ.t
    xdot[i,:] = int_(integ.t,y[i,:])
    integ.integrate(integ.t+dt)
    i=i+1
    
  fig.clf()
  
  
  ax = fig.gca()
  with sns.color_palette("PuBuGn_d",n_colors=2):
    for ind_ in range(x.shape[1]):
      ax.plot(x[:,ind_], y[:,ind_], label=("$f_%d$: %.2f" % (ind_ +1,f[ind_])))
  
  ax.set_ylim(-0.1,1.1)
  ax.set_xlabel("time")
  ax.set_ylabel("Quasi specie")
  
  ax2 = ax.twinx()
  with sns.color_palette("PuBuGn_d",n_colors=2):
    ax2.plot(np.arange(0,t_f+dt,dt),y.dot(f), label="fitness ",linestyle='-.')
  ax2.set_ylabel('$f$', rotation=0)
  ax2.set_ylim(0,3)
  ax2.grid('off')
  ax.legend(ncol=min(4,x.shape[1]))
  ax2.legend(loc=4)
  display(fig)
  return

items_gene = [
  widgets.IntSlider(
    value=2,
    min=2,
    max=6,
   ...