Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/scala-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
- uses: sbt/setup-sbt@v1
- name: sbt-test
shell: bash
run: sbt -v +test
run: sbt -v +test osvScan
1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("net.nmoncho" % "sbt-osv" % "0.2.0")
27 changes: 13 additions & 14 deletions src/main/scala/emc/rna/Codon.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package rna
case class Codon(_1: Nucleotide, _2: Nucleotide, _3: Nucleotide) derives CanEqual:
lazy val asRNA : RNA = RNA(_1, _2, _3)
lazy val isStart: Boolean = Codon.Start.equals(this)
lazy val isStop: Boolean = Codon.StopCodons.contains(this)
lazy val isStop: Boolean = Codon.Stop.Codons.contains(this)

def aminoAcid: AminoAcid =
AminoAcid.fromCodon(this).getOrElse(sys.error("dirty rna"))
Expand Down Expand Up @@ -34,25 +34,24 @@ object Codon:
val Occur = Codon(U,G,A)
val Opal = Codon(U,A,A)

/**
* Convenience definition for the set of stop codons.
*/
val Codons: Set[Codon] =
Set(Amber, Occur, Opal)

/**
* Convenience definition of the set of stop codon names.
*/
val CodonNames: Codon => String =
Map(Amber -> "Amber", Occur -> "Occur", Opal -> "Opal")

def apply(n1: Nucleotide, n2: Nucleotide, n3: Nucleotide): Codon =
Codon(n1, n2, n3)

def unapply(codon: Codon): Option[(Nucleotide,Nucleotide,Nucleotide)] =
if codon.isStop then Some((codon._1, codon._2, codon._3)) else None

import Stop.*

/**
* Convenience definition for the set of stop codons.
*/
val StopCodons: Set[Codon] =
Set(Amber, Occur, Opal)

/**
* Convenience definition of the set of stop codon names.
*/
val StopCodonNames: Codon => String =
Map(Amber -> "Amber", Occur -> "Occur", Opal -> "Opal")

/**
* Constructs a codon from the first three nucleotides of given sequence.
Expand Down