reading in

def computePCsPython(out_dir,k,bfile,ffile):
    """ reading in """
    RV = plink_reader.readBED(bfile,useMAFencoding=True)
    X  = np.ascontiguousarray(RV['snps'])

    """ normalizing markers """
    print('Normalizing SNPs...')
    p_ref = X.mean(axis=0)/2.
    X -= 2*p_ref

    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        X /= sp.sqrt(2*p_ref*(1-p_ref))

    hasNan = sp.any(sp.isnan(X),axis=0)
    if sp.any(hasNan):
        print(('%d SNPs have a nan entry. Exluding them for computing the covariance matrix.'%hasNan.sum()))
        X  = X[:,~hasNan]

    """ computing prinicipal components """
    U,S,Vt = ssl.svds(X,k=k)
    U -= U.mean(0)
    U /= U.std(0)
    U  = U[:,::-1]

    """ saving to output """
    np.savetxt(ffile, U, delimiter='\t',fmt='%.6f')