<commit_before>require "formula"

class Phlawd < Formula
  homepage "http://www.phlawd.net/"
  #doi "10.1186/1471-2148-9-37"

  # the most up to date version of phlawd is the chinchliff fork, which contains a variety of bug fixes and new features.
  # this fork and the (original) blackrim fork will eventually be merged.
  version "3.4a"
  url "https://github.com/chinchliff/phlawd/releases/download/#{version}/phlawd_#{version}_src_with_sqlitewrapped_1.3.1.tar.gz"
  sha1 "116158ee33b6c33e83a585b26481c5497c7b4ac7"
  head "https://github.com/chinchliff/phlawd.git"

  fails_with :clang do
    build 600
    cause <<-eos
      PHLAWD requires openmp support, which is not available in clang.
      Currently, PHLAWD can only be compiled with gcc > 4.2.
    eos
  end

  fails_with :llvm do
    cause "The llvm compiler is not supported."
  end

  # correct the makefile to look for dependencies where brew installs them
  patch :DATA

  depends_on "mafft"
  depends_on "muscle"
  depends_on "quicktree"
  depends_on "sqlite"

  def install

    # compile sqlitewrapped: a dependency included here since it uncommon and unmaintained
    system *%w[make -C sqlitewrapped-1.3.1]

    # compile and install phlawd
    system *%w[make -C src -f Makefile.MAC]
    prefix.install "src/PHLAWD"
    bin.install_symlink "../PHLAWD"
  end

  test do<commit_msg>phlawd: missing 'needs :openmp' added<commit_after>class Phlawd < Formula
  desc "Phylogenetic dataset construction"
  homepage "http://www.phlawd.net/"
  # doi "10.1186/1471-2148-9-37"

  # the most up to date version of phlawd is the chinchliff fork, which contains a variety of bug fixes and new features.
  # this fork and the (original) blackrim fork will eventually be merged.
  version "3.4a"
  url "https://github.com/chinchliff/phlawd/releases/download/#{version}/phlawd_#{version}_src_with_sqlitewrapped_1.3.1.tar.gz"
  sha256 "0ec8e45359af6e932ea4a042fe4f42ddf05b04689a25df937b2d85db41038253"
  head "https://github.com/chinchliff/phlawd.git"

  fails_with :clang do
    build 600
    cause <<-eos
      PHLAWD requires openmp support, which is not available in clang.
      Currently, PHLAWD can only be compiled with gcc > 4.2.
    eos
  end

  fails_with :llvm do
    cause "The llvm compiler is not supported."
  end

  # correct the makefile to look for dependencies where brew installs them
  patch :DATA

  needs :openmp

  depends_on "mafft"
  depends_on "muscle"
  depends_on "quicktree"
  depends_on "sqlite"

  def install
    # compile sqlitewrapped: a dependency included here since it uncommon and unmaintained
    system "make", "-C", "sqlitewrapped-1.3.1"

    # compile and install phlawd
    system "make", "-C", "src", "-f", "Makefile.MAC"
    prefix.install "src/PHLAWD"
    bin.install_symlink "../PHLAWD"
  end

  test do
{'fraction_non_alphanumeric': 0.09019607843137255, 'fraction_numerical': 0.047415329768270946, 'mean_word_length': 3.5185185185185186, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5337857', 'n_tokens_mistral': 1060, 'n_tokens_neox': 976, 'n_words': 295}