<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def computePCs(plink_path,k,bfile,ffile):
 """ compute the first k principal components Input: k : number of principal components plink_path : plink path bfile : binary bed file (bfile.bed, bfile.bim and bfile.fam are required) ffile : name of output file """

    try:
        output = subprocess.check_output('%s --version --noweb'%plink_path,shell=True)
        use_plink = float(output.split(' ')[1][1:-3])>=1.9
    except:
        use_plink = False


    assert bfile!=None, 'Path to bed-file is missing.'
    assert os.path.exists(bfile+'.bed'), '%s.bed is missing.'%bfile
    assert os.path.exists(bfile+'.bim'), '%s.bim is missing.'%bfile
    assert os.path.exists(bfile+'.fam'), '%s.fam is missing.'%bfile

    # create dir if it does not exist
    out_dir = os.path.split(ffile)[0]
    if out_dir!='' and (not os.path.exists(out_dir)):
        os.makedirs(out_dir)

    if use_plink:
        computePCsPlink(plink_path,k,out_dir,bfile,ffile)
    else:
        computePCsPython(out_dir,k,bfile,ffile)