class Trimal < Formula
  # cite Capella_2009: "https://doi.org/10.1093/bioinformatics/btp348"
  desc "Automated alignment trimming in phylogenetic analyses"
  homepage "http://trimal.cgenomics.org/"
  url "https://github.com/scapella/trimal/archive/refs/tags/v1.4.1.tar.gz"
  sha256 "cb8110ca24433f85c33797b930fa10fe833fa677825103d6e7f81dd7551b9b4e"
  license "GPL-3.0"
  head "https://github.com/scapella/trimal"

  bottle do
    root_url "https://ghcr.io/v2/brewsci/bio"
    sha256 cellar: :any_skip_relocation, sierra:       "e1796872ec4389f87131dea98c4596aa387090d4eb476f1e1472e3763bbc09ed"
    sha256 cellar: :any_skip_relocation, x86_64_linux: "e10f7b254386950ff2944caf0b1eb924d0854618485c7cb534ba5f058dc56b17"
  end

  def install
    system "make", "-C", "source", "CC=c++"
    bin.install "source/readal", "source/trimal", "source/statal"
    pkgshare.install "dataset"
  end

  test do
    %w[trimal readal statal].each do |exe|
      assert_match "Salvador", shell_output("#{bin}/#{exe} 2>&1")
    end
    assert_match "Hsa167996", shell_output("#{bin}/statal -sident -in #{pkgshare}/dataset/AA1.fas")
  end
end
