<commit_before>package funpep
package data

import java.nio.file.Path

import scalaz._
import scalaz.syntax.equal._

import scalaz.concurrent._
import scalaz.stream._

import atto._

import util.ops.foldable._
import util.types._


final case class Fasta[A] (
  val entries: NonEmptyList[Sequence[A]]
)(implicit val ev: A ⇒ Compound) {

  def toString(length: Int): String = {
    def format(seq: Sequence[A]): String =
      ">" + seq.header + "\n" + seq.residues.mkString(_.code.toString).grouped(length).mkString("\n")

    entries.map(format).mkString(identity, "\n")
  }

  def toFile(path: Path): Process[Task, Unit] =
    Process(toString(70)).pipe(text.utf8Encode).to(nio.file.chunkW(path))

}

object Fasta {

  def apply[A](head: Sequence[A], tail: Sequence[A]*)(implicit ev: A ⇒ Compound): Fasta[A] =
    new Fasta(NonEmptyList(head, tail: _*))

  implicit def FastaEqual[A: Equal]: Equal[Fasta[A]] =
    Equal.equal(_.entries ≟ _.entries)

  implicit def FastaShow[A]: Show[Fasta[A]] =
    Show.shows(_.toString(70))

}

final class FastaParser[A] private[data] (val compound: Parser[A])(implicit val ev: A ⇒ Compound) {

  import java.nio.channels.AsynchronousFileChannel

  import scalaz.syntax.applicative._
  import scalaz.syntax.foldable._

  import atto.parser.character._
  import atto.parser.combinator._
  import atto.parser.text._
  import atto.syntax.parser._
  import atto.syntax.stream.all._

  lazy val fasta:    Parser[Fasta[A]]    = many1(sequence).map(ss ⇒ Fasta(ss))
  lazy val sequence: Parser[Sequence[A]] = (header |@| residues)(Sequence.apply)

  lazy val header:   Parser[String]   = char('>') ~> takeWhile(c ⇒ c != '\r' && c != '\n') <~ eol
  lazy val residues: Parser[IList[A]] = many1(residuesLine).map(_.toIList.flatten)
<commit_msg>Change implicit val fields to constructor params in Fasta/FastaParser<commit_after>package funpep
package data

import java.nio.file.Path

import scalaz._
import scalaz.syntax.equal._

import scalaz.concurrent._
import scalaz.stream._

import atto._

import util.ops.foldable._
import util.types._


final case class Fasta[A] (
  val entries: NonEmptyList[Sequence[A]]
)(implicit ev: A ⇒ Compound) {

  def toString(length: Int): String = {
    def format(seq: Sequence[A]): String =
      ">" + seq.header + "\n" + seq.residues.mkString(_.code.toString).grouped(length).mkString("\n")

    entries.map(format).mkString(identity, "\n")
  }

  def toFile(path: Path): Process[Task, Unit] =
    Process(toString(70)).pipe(text.utf8Encode).to(nio.file.chunkW(path))

}

object Fasta {

  def apply[A](head: Sequence[A], tail: Sequence[A]*)(implicit ev: A ⇒ Compound): Fasta[A] =
    new Fasta(NonEmptyList(head, tail: _*))

  implicit def FastaEqual[A: Equal]: Equal[Fasta[A]] =
    Equal.equal(_.entries ≟ _.entries)

  implicit def FastaShow[A]: Show[Fasta[A]] =
    Show.shows(_.toString(70))

}

final class FastaParser[A] private[data] (val compound: Parser[A])(implicit ev: A ⇒ Compound) {

  import java.nio.channels.AsynchronousFileChannel

  import scalaz.syntax.applicative._
  import scalaz.syntax.foldable._

  import atto.parser.character._
  import atto.parser.combinator._
  import atto.parser.text._
  import atto.syntax.parser._
  import atto.syntax.stream.all._

  lazy val fasta:    Parser[Fasta[A]]    = many1(sequence).map(ss ⇒ Fasta(ss))
  lazy val sequence: Parser[Sequence[A]] = (header |@| residues)(Sequence.apply)

  lazy val header:   Parser[String]   = char('>') ~> takeWhile(c ⇒ c != '\r' && c != '\n') <~ eol
  lazy val residues: Parser[IList[A]] = many1(residuesLine).map(_.toIList.flatten)

{'fraction_non_alphanumeric': 0.15228285077951, 'fraction_numerical': 0.0038975501113585748, 'mean_word_length': 4.252923976608187, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1448852', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1271, 'n_words': 282}