'''
Copyleft Feb 11, 2017 Arya Iranmehr, PhD Student, Bafna Lab, UC San Diego,  Email: airanmehr@gmail.com
'''
import numpy as np;

np.set_printoptions(linewidth=200, precision=5, suppress=True)
import pandas as pd;

pd.options.display.max_rows = 20;
pd.options.display.expand_frame_repr = False
import pylab as plt;
import os;

home = os.path.expanduser('~') + '/'
import Utils.Estimate as est
import Utils.Plots as pplt
import Scripts.KyrgysHAPH.Utils as kutl
import Scripts.KyrgysHAPH.Plot as kplt
kplt.savefig()
reload(est)
a=pd.read_pickle(kutl.path+'/data/freq.df')

def plotSFSall(chrom=None):
    


def plotChromAll():
    a.apply(lambda x: kplt.SFSChromosomwise(x, False, False))
    a.apply(lambda x: kplt.SFSChromosomwise(x, False, True))
    a.apply(lambda x: kplt.SFSChromosomwise(x, True, False))
    a.apply(lambda x: kplt.SFSChromosomwise(x, True, True))

def SFS():
    plotSFSall()
    plotSFSall('X')
    plotSFSall('Y')
    plotChromAll()
f=est.Estimate.getSAFS
    a=pd.read_pickle(kutl.path+'/data/freq.df')
    if chrom is not None:
        suff='.chr{}'.format(chrom)
        a=a.loc[[chrom]]
    kplt.plotSFSold2(a, fold=False, fname='AFS' + suff);
    kplt.plotSFSold2(a, fold=False, fname='Scaled-AFS' + suff, f=f)
    kplt.plotSFSold2(a, fold=True, fname='AFS' + suff, );
    kplt.plotSFSold2(a, fold=True, fname='Scaled-AFS' + suff, f=f)