code: def computeCovarianceMatrix(plink_path,bfile,cfile,sim_type='RRM'):
      
      try:
          output    = subprocess.check_output('%s --version --noweb'%plink_path,shell=True)
          m = re.match(b"^PLINK v(\d+\.\d+).*$", output)
          if m:
              use_plink = float(m.group(1)) >= 1.9
          else:
              use_plink = False
      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(cfile)[0]
      if out_dir!='' and (not os.path.exists(out_dir)):
          os.makedirs(out_dir)
  
  
      if use_plink:
          computeCovarianceMatrixPlink(plink_path,out_dir,bfile,cfile,sim_type=sim_type)
      else:
          computeCovarianceMatrixPython(out_dir,bfile,cfile,sim_type=sim_type)
docs: compute similarity matrix using plink
  
      Input:
      plink_path   :   plink path
      bfile        :   binary bed file (bfile.bed, bfile.bim and bfile.fam are required)
      cfile        :   the covariance matrix will be written to cfile.cov and the corresponding identifiers
                           to cfile.cov.id. If not specified, the covariance matrix will be written to cfile.cov and
                           the individuals to cfile.cov.id in the current folder.
      sim_type     :   {IBS/RRM} are supported