Skip to content

About

Object-oriented Java sequence library and command-line tool with BioJava, Maven and JUnit

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Java Sequence Toolkit

build java

An object-oriented Java library and command-line tool for DNA and protein sequences: FASTA parsing, lookup by ID, GC content, codon splitting, three-frame translation and regex motif scanning. It also has a BioJava layer, and the unit tests check that my own translation code gives the same proteins as BioJava.

Tools: Java 17, object-oriented design, BioJava, Maven, JUnit 5, GitHub Actions

Classes

Class What it does
DNA Immutable sequence record with validation, base counts, GC%, reverse complement and FASTA output
GeneticCode The standard genetic code (NCBI table 1) as a lookup table built from one 64-character string. Splits a sequence into codons for each frame, translates it, and finds the longest stretch without a stop codon
FastaReader Reads multi-record FASTA files into a map from ID to record, so lookups by ID are fast
MotifScanner Regex motif search (by default the C2H2 zinc finger C..C.{17}C..C) that marks each hit with * under the sequence
SeqTool Command-line tool with stats, translate, lookup and motif commands
biojava.GenBankSummary Reads multi-record GenBank files with BioJava's RichSequence
biojava.ThreeFrameTranslator Three-frame translation with BioJava's GeneticCodes.transcribe and translate

Build and test

git clone https://github.com/David-W-netizen/java-sequence-toolkit.git
cd java-sequence-toolkit
mvn package                     # compiles, runs the 8 JUnit 5 tests and builds target/seqtools.jar
java -jar target/seqtools.jar stats data/est_clones.fasta

Example output

All output below comes from the files in data/.

Per-record stats for six EST clones

$ java -jar target/seqtools.jar stats data/est_clones.fasta
id               length     GC% valid
by21f03.y1          381   63.78 true
by05e12.y1          264   66.67 true
by09f05.y1          469   62.47 true
by14f12.y1          355   63.66 true
by20g06.y1          365   64.11 true
by18g06.y1          118   69.49 true

Look up records by ID

$ java -jar target/seqtools.jar lookup data/est_clones.fasta by05e12.y1 nar08h02.q2
>by05e12.y1
CCGCCGTGCGCCCAGCCAGCCATGGGGAAGATCACCCTCTACGAGGACCG
...
The sequence id: nar08h02.q2 is not in the file.

Three-frame translation

$ java -jar target/seqtools.jar translate data/hwk3.seq
>hwk3.seq
TCAGCGAGATGGGAAAGATCACCTTCTTCGAGGACCGAGGCTTCCAGGGC

Reading frame #1
TCA GCG AGA TGG GAA AGA TCA CCT TCT TCG AGG ACC GAG GCT TCC AGG
 S   A   R   W   E   R   S   P   S   S   R   T   E   A   S   R

Reading frame #2
CAG CGA GAT GGG AAA GAT CAC CTT CTT CGA GGA CCG AGG CTT CCA GGG
 Q   R   D   G   K   D   H   L   L   R   G   P   R   L   P   G
...

Scan 375 human zinc-finger proteins for the C2H2 cysteine motif

$ java -jar target/seqtools.jar motif data/zinc_finger_proteins.fasta
>gi|224591419|ref|NP_001139192.1| putative zinc finger and BTB domain-containing protein 8B [Homo sapiens]
  motif CKGCRRTFTSHLSQGLRRFGLCDSC at 400-424
...
9 of 375 sequences contain /C..C.{17}C..C/

The BioJava classes run from the same jar, for example java -cp target/seqtools.jar bio.seqtools.biojava.GenBankSummary data/genbank_records.gb.

Design notes

  • A lookup table instead of an if/else chain. GeneticCode builds a map once from the standard TCAG-ordered 64-character string, so each codon lookup is constant-time and the whole table is easy to check by eye.
  • A map instead of a linear search. Finding a record by ID uses an insertion-ordered LinkedHashMap instead of looping over an array.
  • No GUI. The class examples opened JFileChooser file dialogs. Everything here takes file paths as arguments, so it runs from the command line and in CI.
  • Checked against a reference implementation. The test handWrittenTranslationAgreesWithBioJava translates every record in every frame with both my code and BioJava and checks that the proteins match.

Files

src/main/java/bio/seqtools/          DNA, GeneticCode, FastaReader, MotifScanner, SeqTool (command line)
src/main/java/bio/seqtools/biojava/  GenBankSummary, ThreeFrameTranslator
src/test/java/bio/seqtools/          JUnit 5 tests
data/                                EST clone FASTA, zinc-finger proteins, GenBank records
.github/workflows/build.yml          builds and tests on every push

Background

I refactored these from programs I wrote for BIFS 618 (Java for Biotechnology Applications) in my M.S. in Bioinformatics at the University of Maryland Global Campus (Fall 2026).


David Wisnieski · MIT License

About

Object-oriented Java sequence library and command-line tool with BioJava, Maven and JUnit

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages