class Beetl < Formula
  desc "Burrows-Wheeler Extended Tool Library"
  homepage "https://github.com/BEETL/BEETL"
  head "https://github.com/BEETL/BEETL.git", branch: "RELEASE_1_1_0"
  # doi "10.1093/bioinformatics/bts173"
  # tag "bioinformatics"

  stable do
    url "https://github.com/BEETL/BEETL/archive/BEETL-0.10.0.tar.gz"
    sha256 "161ff8b4b3c99fd313851778c15dc32ab95dcaaf16912402940d53c56a74c283"

    # Fixes "error: 'accumulate' is not a member of 'std'"
    # Upstream commit "Little fix for compilation on mac"
    patch do
      url "https://github.com/BEETL/BEETL/commit/ba47b6f9.patch?full_index=1"
      sha256 "bc8217a12b3849faa0d6f466eecf8bed8a89a126cd245603bae73592a1816d36"
    end
  end

  bottle do
    root_url "https://archive.org/download/brewsci/bottles-science"
    sha256 cellar: :any, el_capitan:   "32b190deb3501cb8fe2600860e97edbd78231cc0e400d1236ff09a82e222f5ee"
    sha256 cellar: :any, yosemite:     "f03a3fae57263a692697141f59ae103466b912939734d13d653156bbda59dfc2"
    sha256 cellar: :any, mavericks:    "afec472f36aaf5fb71f7d82e92419299be2c54479a2f50a02362407695dbc156"
    sha256 cellar: :any, x86_64_linux: "57c967ead12e01ffe2bd14b9a4b0caa02ad9e80eee5444a7369f26940c449f2c"
  end

  depends_on "boost" => :optional
  depends_on "seqan" => :optional

  needs :openmp

  def install
    boost = Formula["boost"].opt_prefix
    seqan = Formula["seqan"].opt_prefix/"include"
    args = %W[
      --disable-dependency-tracking
      --disable-silent-rules
      --prefix=#{prefix}
    ]
    args << "--with-boost=#{boost}" if build.with? "boost"
    args << "--with-seqan=#{seqan}" if build.with? "seqan"
    system "./configure", *args
    system "make", "install"
  end

  test do
    system "beetl", "--version"
  end
end
