{% macro gene_cell(variant) %}
  <div class="align-items-center">
    {% for gene in variant.genes %}
      <a data-toggle="tooltip" data-html="true" title="
      <div>
        <div>
          <strong>{{ gene.hgnc_symbol }}</strong>: {{ gene.description }}
        </div>
        {% if gene.inheritance %}
          <div>
            <strong>Models</strong>: {{ gene.inheritance|join(',') }}
          </div>
        {% endif %}
        {% if gene.phenotypes %}
          <div><strong>OMIM disease</strong>
          {% for disease in gene.phenotypes %}
            <div>
                {{ disease.description }}
            </div>
          {% endfor %}
          </div>
        {% endif %}
      </div>"
        href="{{ url_for('genes.gene', hgnc_id=gene.hgnc_id) }}">{{ gene.hgnc_symbol or gene.hgnc_id }}
      </a>
    {% endfor %}
    {% if variant.panels|count > 0 %}
        <a
          class="badge badge-secondary text-white"
          data-toggle="popover"
          data-html="true"
          data-trigger="hover click"
          data-content="<strong>Overlapping gene panels:</strong><br>{{variant.panels|join('<br>')|safe}}"
          title="">{{variant.panels|count}}
         </a>
    {% endif %}
  </div>
{% endmacro %}

{% macro frequency_cell_general(variant) %}
  <div data-toggle="tooltip" data-placement="left" data-html="true" title="
      <div class='text-left'>
        {% for freq_name, value, link in variant.frequencies %}
          <div>
            <strong>freq_name</strong>: {{ value|human_decimal}}
          </div>
        {% endfor %}
        <div>
          <strong>Local (arch.)</strong>: {{ variant.local_obs_old or 0 }} obs.
        </div>
      </div>
    ">
    {{ variant.gnomad_frequency|human_decimal if variant.gnomad_frequency else '~' }}
  </div>
{% endmacro %}

{% macro frequency_cell(variant) %}
  <div data-toggle="tooltip" data-placement="left" data-html="true" title="
    <div class='text-left'>
      {% if 'gnomad_mt_homoplasmic_frequency' in variant %}
        <div>
          <strong>gnomAD(MT) hom</strong>: {{ variant.gnomad_mt_homoplasmic_frequency|human_decimal if variant.gnomad_mt_homoplasmic_frequency }}
        </div>
      {% endif %}
      {% if 'gnomad_mt_heteroplasmic_frequency' in variant %}
        <div>
          <strong>gnomAD(MT) het</strong>: {{ variant.gnomad_mt_heteroplasmic_frequency|human_decimal if variant.gnomad_mt_heteroplasmic_frequency }}
        </div>
      {% endif %}

      {% if 'gnomad_frequency' in variant %}
        <div>
          <strong>gnomAD</strong>: {{ variant.gnomad_frequency|human_decimal if variant.gnomad_frequency }}
        </div>
        <div>
          <strong>gnomAD (max)</strong>: {{ variant.max_gnomad_frequency|human_decimal if variant.max_gnomad_frequency }}
        </div>
      {% endif %}
      <div>
        <strong>1000G</strong>: {{ variant.thousand_genomes_frequency|human_decimal if variant.thousand_genomes_frequency }}
      </div>
      <div>
        <strong>1000G (max)</strong>: {{ variant.max_thousand_genomes_frequency|human_decimal if variant.max_thousand_genomes_frequency }}
      </div>
      <div>
        <strong>ExAC</strong>:
        {{ variant.exac_frequency|human_decimal if variant.exac_frequency }}
      </div>
      <div>
        <strong>ExAC (max)</strong>:
        {{ variant.max_exac_frequency|human_decimal if variant.max_exac_frequency }}
      </div>
      <div>
        <strong>Local (arch.)</strong>: {{ variant.local_obs_old or 0 }} obs.
      </div>
      {% if variant.mitomap_associated_diseases %}
        <strong>MITOMAP</strong>: {{ variant.mitomap_associated_diseases }}<br
      {% endif %}
      {% if variant.cosmic_ids %}
      <strong>COSMIC</strong>: {{variant.cosmic_ids|count}} obs
      {% endif %}
      {% if variant.clinsig_human %}
        <strong>ClinVar</strong>:
          {% for clinsig in variant.clinsig_human %}
            <strong>{{clinsig.human}}</strong> {{ clinsig.revstat }} {{ clinsig.accession }}<br>
          {% endfor %}
      {% endif %}
    </div>
  ">
  {% if variant.clinsig_human %}
    <span class="badge badge-dark">ClinVar</span>
    <br>
  {% endif%}
  {% if variant.cosmic_ids %}
    <span class="badge badge-dark">COSMIC</span>
    <br>
  {% endif %}
  {% if variant.mitomap_associated_diseases %}
    <span class="badge badge-dark">MITOMAP</span>
    <br>
  {% endif %}
  {% if variant.chromosome != "MT" %}
    {{ variant.gnomad_frequency|human_decimal if variant.gnomad_frequency else '~' }}
  {% else %}
    {{ variant.gnomad_mt_homoplasmic_frequency|human_decimal if variant.gnomad_mt_homoplasmic_frequency else '~' }}
  {% endif %}
  </div>
{% endmacro %}
