Production-ready Motif GA workflow with optional clustering. Legacy experiments and MATLAB/C NSGA-II code are separated under legacy.
Prerequisites:
- Java 8+
- Gradle
Build:
./gradlew build
Run (production entry point):
./gradlew run
Optional clustering run:
./gradlew runClustering
Tests:
./gradlew test
Run the GA-based shortest path search:
./gradlew runGADijkstra --args="0 3"
Output includes:
- GA best cost/path (heuristic result)
- Optimal cost/path (computed with classic Dijkstra for comparison)
How to learn it:
- GA searches over permutations of nodes (chromosomes).
- Fitness is inverse of path cost; invalid paths get zero fitness.
- Selection + crossover + mutation evolve better paths over generations.
- Compare GA output to the optimal Dijkstra output to validate.
Custom input/output paths:
./gradlew run --args="/path/to/input.txt /path/to/output.txt"
./gradlew run -Dmotif.input=/path/to/input.txt -Dmotif.output=/path/to/output.txt
Non-interactive run (no prompts):
./gradlew run -Dmotif.length=6 -Dmotif.promoter=ATGCAT -Dmotif.parents.percent=50 -Dmotif.motifs.per.sequence=4 \
--args="data/motifs-input.txt data/motifs-output.txt"
Interactive run (pipe stdin):
printf "6\nATGCAT\n50\n4\n" | ./gradlew run --args="data/motifs-input.txt data/motifs-output.txt"
Other tasks:
./gradlew runDijkstra --args="0 3"
./gradlew runGADijkstra --args="0 3"
./gradlew runKMeans
printf "6\n50\n4\n" | ./gradlew runClustering
Clustering non-interactive:
./gradlew runClustering -Dcluster.motif.length=6 -Dcluster.mutation.percent=50 -Dcluster.motifs.per.sequence=4 \
--args="data/motifs-input.txt"
- src/main/java/com/motifdiscovery/MotifGAImproved.java: Production entry point
- src/main/java/com/motifdiscovery/MotifGAClassic.java: Reference/legacy algorithm variant
- src/main/java/com/motifdiscovery/GAUtils.java: Minimal GA helpers and input/output utilities
- src/main/java/com/motifdiscovery/clustering/: Optional clustering workflow
- src/test/java/com/motifdiscovery/: Tests
- data/motifs-input.txt: Canonical input file
- data/motifs-output.txt: Canonical output file
- legacy/: Archived experiments, MATLAB, and C implementations
The canonical input file is data/motifs-input.txt in a FASTA-like format:
GeneName GeneCode SEQUENCE...
MotifGAImproved writes the predicted motif and consensus to data/motifs-output.txt.
- Random candidate motifs: random substrings sampled per sequence; the best fitness is retained.
- Weight matrix: per-position base frequency across the population.
- Pm: predicted motif from highest-frequency bases.
- cons: consensus using IUPAC ambiguity codes.
- POOL: selected parent pool for crossover.
- COUNT: GA iterations until convergence or max iterations.
Use data/test-motifs-input.txt which embeds the known motif ACGTAC in each sequence.
Example run:
./gradlew run --args="data/test-motifs-input.txt data/motifs-output.txt"
Expected behavior:
- Predicted motif should be close to ACGTAC (heuristic, not guaranteed).
Tests include a dataset validation check:
./gradlew test
- legacy/ is excluded from the Gradle build and is non-production.
- MATLAB code is kept under legacy/matlab for testing only.