MoonBit GenBank/INSDC annotation parser with feature queries, CDS validation, JSON export, and CI
moon check --deny-warn
moon test --deny-warn
moon run cmd/main
moon run cmd/main -- --json///|
test "parse a minimal record" {
let text =
#|LOCUS DEMO0001 12 bp DNA linear SYN 28-JUL-2026
#|DEFINITION Minimal MoonBit GenBank demo record.
#|ACCESSION DEMO0001
#|FEATURES Location/Qualifiers
#| source 1..12
#| /organism="synthetic construct"
#| CDS 1..12
#| /gene="demo"
#| /translation="MAIV"
#|ORIGIN
#| 1 atggccattgta
#|//
let record = parse_record(text)
inspect(record.accession, content="DEMO0001")
inspect(record.features_by_key("CDS").length(), content="1")
inspect(record.check_cds_translations()[0].ok, content="true")
}moon check --deny-warn
moon test --deny-warn
moon infomoon test --target native --deny-warn --enable-coverage
moon coverage report -f summarypub struct AssemblyResult {
sequence : String
contig_count : Int
merged_count : Int
overlaps : Array[ContigOverlap]
unresolved : Array[String]
} derive(Eq, Debug)pub struct BatchQualityReport {
record_count : Int
valid_count : Int
invalid_count : Int
total_bases : Int
mean_length : Double
mean_gc : Double
duplicate_accessions : Array[String]
records_with_remote_locations : Int
records_with_fuzzy_locations : Int
records_with_translation_errors : Int
} derive(Eq, Debug)pub struct CodingSequenceReport {
nucleotide_length : Int
complete_codons : Int
trailing_bases : Int
start_codons : Int
stop_codons : Int
ambiguous_codons : Int
gc_first : Double
gc_second : Double
gc_third : Double
usage : Array[CodonUsage]
} derive(Eq, Debug)pub struct FastaValidationReport {
record_count : Int
total_bases : Int
duplicate_ids : Array[String]
issues : Array[FastaIssue]
valid : Bool
} derive(Eq, Debug)pub struct IntervalCoverage {
intervals : Array[CoordinateInterval]
covered_bases : Int
minimum : Int
maximum : Int
gaps : Int
} derive(Eq, Debug)fn RecordCollection::records_with_feature(self : RecordCollection, key : String) -> RecordCollectionpub struct RecordMetrics {
accession : String
length : Int
gc_percent : Double
entropy : Double
feature_count : Int
feature_coverage : Int
feature_coverage_percent : Double
cds_count : Int
gene_count : Int
translation_count : Int
remote_locations : Int
fuzzy_locations : Int
between_locations : Int
validation_errors : Int
validation_warnings : Int
} derive(Eq, Debug)pub struct SequenceAnalysis {
sequence : String
length : Int
windows : Array[SequenceWindow]
composition : CompositionReport
gc_skew : Int
longest_run : Int
motifs : Array[String]
} derive(Eq, Debug)pub struct ValidationIssue {
code : String
message : String
severity : ValidationSeverity
} derive(Eq, Debug)pub struct ValidationReport {
ok : Bool
error_count : Int
warning_count : Int
issues : Array[ValidationIssue]
accession : String
sequence_length : Int
feature_count : Int
} derive(Eq, Debug)fn features_in_length_range(record : Record, minimum : Int, maximum : Int) -> Array[FeatureTableRow]fn find_orfs(sequence : String, minimum_codons : Int, maximum_bases : Int, table : CodonTable) -> Array[OpenReadingFrame]fn find_qualifier_value_matches(record : Record, name : String, value : String) -> Array[QualifierMatch]fn global_align(left : String, right : String, match_score : Int, mismatch_score : Int, gap_score : Int) -> GlobalAlignmentfn hamming_distance(left : String, right : String) -> Intfn intersect_coordinate_intervals(left : Array[CoordinateInterval], right : Array[CoordinateInterval]) -> Array[CoordinateInterval]fn is_iupac_base(ch : Char) -> Boolfn iupac_motif_count(sequence : String, motif : String) -> Intfn iupac_motif_matches_at(sequence : String, motif : String, offset : Int) -> Boolfn longest_homopolymer(sequence : String) -> Intfn mask_ambiguities(sequence : String) -> Stringfn normalize_genbank_text(text : String) -> Stringfn normalize_sequence(text : String) -> Stringfn parse_record_collection(text : String, source_name? : String) -> RecordCollection raise GenBankErrorfn protein_molecular_weight_approximation(protein : String) -> Doublefn sequence_is_clean(sequence : String) -> Boolfn sequence_is_low_complexity(sequence : String, threshold : Double) -> Boolfn sequence_pairwise_identity(left : String, right : String) -> Doublefn sequence_palindrome(sequence : String) -> Boolfn sequence_profile(sequence : String, window_size : Int, step : Int, motif : String) -> Array[SequenceProfile]fn sequence_subsequence(sequence : String, start : Int, end : Int) -> Stringfn suffix_prefix_overlap(left : String, right : String, minimum : Int) -> Intfn translate_feature(record : Record, feature_index : Int, table? : CodonTable) -> CdsTranslationResult?Install
Download zipMoonBit GenBank/INSDC annotation parser with feature queries, CDS validation, JSON export, and CI