title: Adjust ulimit [open file handle limit] on Mac OS X Sierra to run GATK tools
body: <p>I'm trying to run the <a href="https://software.broadinstitute.org/gatk/documentation/tooldocs/3.8-0/org_broadinstitute_gatk_tools_walkers_variantutils_VariantsToBinaryPed.php" rel="nofollow noreferrer">VariantsToBinaryPed</a> tool from GATK3, but it seems that my system's 'open file handle limit' is too small for it to successfully run. </p>
  
  <p>I've tried increasing the limit using <code>ulimit</code>, as shown below, but the command still fails. </p>
  
  <p>The GATK command:</p>
  
  <pre><code> &gt; java -jar GenomeAnalysisTK.jar \
     -T VariantsToBinaryPed \
     -R Homo_sapiens_assembly38.fasta \
     -V  ~/vcf/snp.indel.recal.splitMA_norm.vcf.bgz\
     -m ~/03_IdentityCheck/KING/targeted_seq_ped_clean.fam\
     -bed output.bed\
     -bim output.bim\
     -fam output.fam\
     --minGenotypeQuality 0
  </code></pre>
  
  <p>Returns this error:</p>
  
  <pre><code>ERROR MESSAGE: An error occurred because there were too many files 
  open concurrently; your system's open file handle limit is probably too small.  
  See the unix ulimit command to adjust this limit or 
  ask your system administrator for help.
  </code></pre>
  
  <p>Following the advice given <a href="http://blog.mact.me/2014/10/22/yosemite-upgrade-changes-open-file-limit" rel="nofollow noreferrer">here</a>, I ran:</p>
  
  <pre><code>echo kern.maxfiles=65536 | sudo tee -a /etc/sysctl.conf
  echo kern.maxfilesperproc=65536 | sudo tee -a /etc/sysctl.conf
  sudo sysctl -w kern.maxfiles=65536
  sudo sysctl -w kern.maxfilesperproc=65536
  sudo ulimit -n 65536 65536
  </code></pre>
  
  <p>and added this line to my <code>.bash_profile</code> and sourced it:</p>
  
  <pre><code>ulimit -n 65536 65536
  </code></pre>
  
  <p>So that now, when I run <code>ulimit -n</code>, I get:</p>
  
  <p><code>65536</code></p>
  
  <p>However, I still get the same error from GATK:</p>
  
  <pre><code>ERROR MESSAGE: An error occurred because there were too many files 
  open concurrently; your system's open file handle limit is probably too small.  
  See the unix ulimit command to adjust this limit or 
  ask your system administrator for help.
  </code></pre>
  
  <p>Is there anything else I can do to avoid this error?</p>