# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
import os

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sqlalchemy import create_engine

if os.getcwd().endswith('notebook'):
    os.chdir('..')
# -

sns.set(palette='colorblind', font_scale=1.3)

db_path = os.path.join(os.getcwd(), 'data/condensed_traits/db/seq.db')
engine = create_engine(f'sqlite+pysqlite:///{db_path}')

query = "select * from species_traits"
traits = pd.read_sql(query, engine)
traits.head()

traits.columns

trait = 'rRNA16S_genes'
traits[['species_taxid', trait]].groupby(trait).count().sort_values('species_taxid', ascending=False)

traits['rRNA16S_genes'].describe()

_, ax = plt.subplots(1, 1, figsize=(12, 6))
traits[traits['growth_tmp.stdev'].notnull()]['growth_tmp.stdev'].hist(ax=ax, bins=100);

candidates = traits[
    (traits['growth_tmp.stdev'].notnull()) &
    (traits['growth_tmp.stdev'] > 0) &
    (traits['growth_tmp.stdev'] < 5)
]

candidates['data_source']

[c for c in traits.columns if 'growth_tmp' in c]

candidates.iloc[10][['species', 'growth_tmp']]



StarcoderdataJupyterScriptsDedupFiltered