[med-svn] [phipack] 01/02: Imported Upstream version 0.0.20060425
Andreas Tille
tille at debian.org
Wed Apr 20 06:52:48 UTC 2016
This is an automated email from the git hooks/post-receive script.
tille pushed a commit to branch master
in repository phipack.
commit dceefc2b16e5a674ddf4ee76114ed92d999874e2
Author: Andreas Tille <tille at debian.org>
Date: Wed Apr 20 08:51:17 2016 +0200
Imported Upstream version 0.0.20060425
---
ATP6.phy | 32 +
README | 20 +
h_pylori.fasta | 297 +++++
noro.fasta | 650 ++++++++++
rana.fasta | 152 +++
src/Makefile | 35 +
src/fasta.c | 250 ++++
src/fasta.h | 8 +
src/global.c | 79 ++
src/global.h | 80 ++
src/graphCode.c | 443 +++++++
src/graphCode.h | 8 +
src/main.c | 652 ++++++++++
src/maxChi.c | 212 ++++
src/maxChi.h | 9 +
src/mem.c | 96 ++
src/mem.h | 25 +
src/misc.c | 87 ++
src/misc.h | 17 +
src/normal.c | 101 ++
src/normal.h | 5 +
src/options.h | 33 +
src/pairScore.c | 207 ++++
src/pairScore.h | 6 +
src/phylip.c | 280 +++++
src/phylip.h | 28 +
src/ppma_2_bmp/Makefile | 18 +
src/ppma_2_bmp/bmp_io.C | 2848 +++++++++++++++++++++++++++++++++++++++++++
src/ppma_2_bmp/bmp_io.H | 74 ++
src/ppma_2_bmp/ppma_2_bmp.C | 374 ++++++
src/ppma_2_bmp/ppma_io.C | 897 ++++++++++++++
src/ppma_2_bmp/ppma_io.H | 18 +
src/profile.c | 662 ++++++++++
src/profile_options.h | 28 +
src/queue.c | 92 ++
src/queue.h | 30 +
src/seqManip.c | 441 +++++++
src/seqManip.h | 55 +
src/stats.c | 232 ++++
src/stats.h | 24 +
40 files changed, 9605 insertions(+)
diff --git a/ATP6.phy b/ATP6.phy
new file mode 100755
index 0000000..efdafc7
--- /dev/null
+++ b/ATP6.phy
@@ -0,0 +1,32 @@
+31 639
+Gomphus_fl GCTCCTGTTATCGGTTATTTAAATCTTAGCCTAACAAATTTAGCTCTTTACTCTTTGATCGTTTTCATTTTAGTCCTT---GGTTTACACTTAGCTTTTAAAAAATTAATTCCTTCAACCTGGTCTATCGCTTTAGAAAGTTCATTTGCAAGCATCAATGCTATCGTGCGAGAACAAATAGGACTGCGAAATGAAATCTATTTACCTTTTATTTACTCATTGTTCTTTTTTATAATTATTGCTAATTTAATTGGAAACACTCCTTATTCTTTTACAATAACAACTTCTATAGTATTATCTGTAGGATTAAGCTTTACTATTTTTATTGGA---GTGACTTTAATAGGACTCGCTAAACATGGTTTACACTTTTTTTCATTCTTTATCCCTTCTGGTACACCTTTAGCATTAGTACCGTTACTTGTTTTAATTGAAGTGACTTCTTATTTAGCTAGAGCCCTTTCTTTAGGGGTTCGTTTA [...]
+Sarcodon_i GCTCCAATTTTTGGTTATTTAAATTTAACTTTAACTAATTTAAGTTTCTATTCTTTATTAGTTTTATTTTTAATTATT---AGTATACATGTTATTAGTAATAAATTATTACCTTCCAAATGGTCAATAGGATTAGAAAGTATCTTTGCAAGTGTAAATTCAATGGTTAGAGAACAATTAGGT------AAAGAAATTTATTTACCTTTTATTTATTCTTTATTCTTTTTTATCTTAATAGCTAATTTAACAGGTAATGTACCTTATTCTTATACAGTTACAACTTCAATAATAGTAACAATAGGTTTATCTTTTACTATATTAATTGGA---GTTACTATATTAGGATTATCTATACATAAATTACATTTTTTTTCTTATTTTATTCCTTCTGGAACTCCTTTAGCTTTAGTTCCTTTATTAGTTTTAATTGAAATGGTAAGTTACTTAGCTAGAGCTTTCTCTTTAGGTATCCGATTA [...]
+Russula_ro GCACCTATTTTTGGTTATATAAATATAACTTTAAGTAATTTAGGTTTATATTCTATATTAATCTTATTAATAATATTA---AGTTTACATATAATAAGTAATAAAATTTTACCTTCAAAATGAAGTATAGCAATAGAAAGTATATTTACAACAATTAATACAATGGTAAGAGAACAATTAGGT------AAAGAAATTTATTTACCTTTTATTTATTCATTATTTTTCTTTATATTAATAAGTAATTTAATAGGTAATATACCTTATTCATACACAATTACAACTTCTGTAATAGTAACTATTGGATTATCATTTACTATATTAACAGGT---GTAACTATATTAGGATTATATATTCATAAATTACATTTTTTCTCATATTTTGTTCCATCTGGAACTCCTTTAGCTTTAGTTCCATTATTAGTTTTAATTGAAACTGTATCTTATTTAGCTAGAGCTTTATCATTAGGTATAAGATTA [...]
+Agaricus_b GCACCTATTTTAGGTCACATAAATTTAACTTTAACAAATTTAGGATTATATTCTTTATTAGTATTATTTGTAGTATTA---GGTTTCCATTACTGGGGAAATAAATTAATACCTAGTAAATGGTCAATTTCTTTAGAATCATCTTATGCTAGTTTAAGTTCTATGGTTAGAGAACAAATAGGAGCACAAAGTGAAATTTATTTACCATTTGTATATTCATTATTCTTCTTCATATTAATTGGTAACTTAATATCTAATGTACCATATTCATTTGCTGTAACAGCTAGTGGAGTAGTTTCATTGGGATTATCTTTCACAATTTTTTGTGCAATTGCAACAATTATAGGACTGTATACACACAAACTTCATTTCTTTTCTTTGTTTGTTCCAGCAGGATGTCCTCTAGCTTTAGTTCCTTTACTTGTTTTAATTGAAACTGTATCTTATTTAGCTAGAGCTGTTTCTTTAGGAGTTCGATTA [...]
+Brauniellu GCACCTATTTTAGGTTACATTGGATTAACTTTAACTAATTTAGCTTTATACTCATTATTAATTTTTATTTTAATTGTA---GGATTACATTATATGGGGAATAAATTATTACCTTCTAAGTGGTCTATACTATTAGAAAGTTTATTTGCAAGTATTAATTCAATGGTTAGAGAACAAATAGGT------AGAGAAATTTATTTACCTTTTATTTATTCTTTATTCTTTTTCATTTTAATAGCTAATTTATTAGGTAACATCCCATACTCATATACAATTACTACTTCAGTTATTGTATCTATTGGATTGTCATTTACTATATTAATTGGT---GTAACAATACTTGGATTATCTATTCATAAAATTCATTTCTTCTCATTCTTTATACCTTCCGGTACTCCTTTAGCTTTAGTTCCTTTATTAGTTTTAATTGAATTAATTAGTTATTTAGCTAGAGCTTTCTCTTTAGGTATCAGATTA [...]
+Rhizopogon GCACCTATTTTAGGTTATATTGGTTTAACTTTAACTAATTTAGCTTTATACTCAATTTTAATTTTTATTTTAATTGTT---GGATTACATTTTATGGGTAATAAATTATTACCTTCTAAATGGTCTATATTATTAGAAAGTTTATTTGCAAGTATTAATTCAATGGTTAGAGAACAAATAGGT------AGAGAAATTTATTTACCTTTTATTTATTCTTTATTCTTTTTTATCTTAATAGCTAATTTATTAGGTAACATCCCATACTCATTTACAATTACTACTTCAGTTATTGTATCTATTGGTTTATCATTTACTATATTAATTGGT---GTAACAATACTTGGATTATCTATTCATAAAATTCATTTCTTCTCATTCTTTATACCTTCTGGAACTCCTTTAGCTTTAGTTCCTTTATTAGTTTTAATTGAATTAATTAGTTATTTAGCTAGAGCTTTCTCTTTAGGAATAAGATTA [...]
+Truncocolu GCACCTATTTTTGGTTATATTGGATTAACTTTAACTAATTTAGCTTTATACTCATTATTAATTTTTATTTTAATTGTA---GGATTACATTATATGGGAAATAAATTATTACCTTCTAAATGGTCTATATTATTAGAAAGTTTATTTGCAAGTATTAATTCAATGGTTAGAGAACAAATAGGT------AGAGAAATTTATTTACCTTTTATTTATTCTTTATTCTTTTTCATCTTAATAGCTAATTTATTAGGTAACATTCCATACTCATATACAATTACTACTTCAGTTATTGTATCTATTGGAATGTCATTTACTATATTAATTGGT---GTAACAATACTTGGATTATCTATTCATAAAATTCATTTCTTCTCATTCTTTATACCTTCTGGTACTCCTTTAGCTTTAGTTCCTTTATTAGTTTTAATTGAATTAATTAGTTATTTAGCTAGAGCTTTCTCTTTAGGTATAAGATTA [...]
+Suillus_la GCACCTATTTTTGGTTATATTGGTTTAACTTTAACTAATTTAGCTTTATACTCCTTATTAATTTTTATCTTAATTGTA---GGATTACATTATATGGGAAATAAATTATTACCTTCTAAATGGTCTATATTATTAGAAAGTTTATTTGCAAGTATTAATTCAATGGTTAGAGAACAAATAGGT------AGAGAAATTTATTTACCTTTTATTTATTCTTTATTCTTTTTCATCTTAATAGCTAATTTATTAGGTAACATACCATACTCATATACAATTACTACTTCAGTTATTGTATCTATTGGATTGTCATTTACTATATTAATTGGT---GTAACAATACTTGGATTATCTATTCATAAAATTCATTTCTTCTCATTCTTTATACCTTCTGGTACTCCTTTAGCTTTAGTTCCTTTATTAGTTTTAATTGAATTAATTAGTTATTTAGCTAGAGCTTTCTCTTTAGGTATCAGATTA [...]
+Suillus_va GCACCTATTTTTGGTTACATTGGATTAACTTTAACTAATTTAGCTTTATACTCATTATTAATTTTAAGTTTAATTGTA---GGTTTACATTTTATGGGAAATAAATTATTACCTTCTAAATGGTCTATATTATTAGAAAGTTTATTTGCAAGTATTAATTCAATGGTTAGAGAACAAATAGGT------AGAGAAATTTATTTACCTTTTATTTATTCTTTATTCTTTTTCATATTAATAGCTAATTTATTAGGTAACATACCATACTCATATACAATTACTACTTCAGTTATTGTATCTATTGGATTATCATTTACTATTTTAATTGGT---GTAACAATACTTGGATTATCTATTCATAAAATTCATTTCTTCTCATTCTTTATACCTTCTGGTACTCCTTTAGCTTTAGTTCCTTTATTAGTTTTAATTGAATTAATTAGTTATTTAGCTAGAGCTTTCTCTTTAGGTATAAGATTA [...]
+Suillus_gr GCACCTATTTTTGGTTACATTGGATTAACTTTAACTAATTTAGCTTTATACTCATTATTAATTTTTATTTTAATTGTA---GGTTTACATTATATGGGAAATAAATTATTACCTTCTAAATGGTCTATATTATTAGAAAGTTTATTTGCAAGTATTAATTCAATGGTTAGAGAACAAATAGGT------AGAGAAATTTATTTACCTTTTATTTATTCTTTATTCTTTTTTATCTTAATAGCTAATTTATTAGGTAACATACCATACTCATATACAATTACTACTTCAGTAATTGTATCTATTGGATTGTCATTTACTATATTAATTGGT---GTTACAATACTTGGATTATCTATTCATAAAATTCATTTCTTTTCATTCTTTATACCTTCTGGTACTCCTTTAGCTTTAGTACCTTTATTAGTTTTAATTGAATTAATTAGTTATTTAGCTAGAGCTTTCTCTTTAGGTATAAGATTA [...]
+Suillus_lu GCACCTATTTTTGGTTACATTGGATTAACTTTAACTAATTTAGCTTTATACTCATTAATTATTTTTACTTTAATTGTT---GGTTTACATTATATGGGAAATAAATTATTACCTTCTAAATGGTCTATATTATTAGAAAGTTTATTTGCAAGTATTAATTCTATGGTTAGAGAACAAATTGGT------AGAGAAATTTATTTACCTTTTATTTATTCTTTATTCTTTTTCATATTAATAGCTAATTTATTAGGTAATATTCCATACTCATATACAATTACTACTTCAGTTATTGTTTCTATTGGATTATCTTTTACTATATTAATTGGT---GTAACAATACTTGGATTATCTATTCATAAAATTCATTTCTTCTCATTCTTTATACCTTCTGGTACTCCTTTAGCTTTAGTTCCTTTATTAGTTTTAATTGAATTAATTAGTTATTTAGCTAGAGCTTTCTCATTAGGAATAAGATTA [...]
+Gyroporus_ GCTCCTTTATTTGGTTACATAAGTTTCACTTTAACTAATTTAGCTTTATATTCTGGTATAATTTTAGCTTTAATCGTG---GGATTGCATATAATGGGTAATAAATTATTACCTTCTAAATGGTCTATCTTATTTGAAAGTTTCTTTGCAAGTATAAATACTATGGTAAGAGAACAAATTGGT------AAAGAAATTTATTTACCCTTTATTTATTCTTTATTCTTCTTTATATTAGTATCTAATTTAGTAGGTAATGTTCCATATTCATATACTATAACAACATCTGTAATTGTATCTATTGGATTATCATTTACTATATTAATAGGT---GTTACTATACTTGGATTATATGAACATAAAATTCATTTTTTCTCATTCTTTATACCTTCAGGTACTCCATTAGCTTTAGTTCCTTTATTAGTTTTAATTGAATTAATAAGTTACTTAGCTAGAGCTTTCTCACTAGGTATAAGATTA [...]
+Scleroderm GCTCCTTTATTTGGTTATATWAGTTTGACTTTGACTAATTTAGCATTATATGCTGGTATTATATTATCTTTAATTGTA---AGTTTACATTTATTAGGAAATAACTTATTACCTTCAAAATGGTCTATTCTATTTGAAAGTTTTTTTGCTAGTGTAAATACTATGGTAAGAGAGCAAATAGGA------AGAGAAATTTATTTACCTTTTATTTATTCATTATTCTTCTTTATTTTAGTAGCTAATTTAGTAGGGAATGTCCCATATTCATTTACTATAACAACTTCAGTAATAGTATCTATTGGGTTATCATTCACTATTCTTATTGGT---GTAACTATATTAGGATTATATATTCATAAACTTCATTTCTTCTCATTCTTTATACCTTCAGGTACACCTTTAGCTTTAGTACCTTTATTAGTTTTAATTGAATTAATAAGTTACTTAGCTAGAGCTTTCTCATTAGGTATCAGATTA [...]
+Scleroderm GCTCCTTTATTTGGTTATATAAGTTTCACTATTACTAATTTAGCATTATATGCTGGTATTATATTATCTATAATTGTA---RGTTTACATTTACTAGGAAATAAATTATTACCTTCAAAATGGTCTATTCTATTTGAAAGTTTCTTTGCTAGTGTAAATACTATGGTAAGAGACCAAATAGGA------AGAGAAATTTATTTACCTTTTATTTATTCATTATTCTTCTTCATTTTAGTAGCTAATTTAGTAGGTAATGTACCATATTCATTTACTATAACAACTTCAGTAATAGTCTCTATTGGTTTATCATTCACTATTCTTATTGGT---GTAACTATATTAGGATTATATATACATAAACTGCATTTCTTCTCATTCTTTATTCCTTCTGGAACACCTTTAGCTTTAGTACCTTTATTAGTTTTAATTGAATTAATAAGTTACTTAGCTAGAGCTTTCTCTTTAGGTATAAGATTA [...]
+Pisolithus GCTCCTTTATTTGGTTATATTAGTTTCACTATTACTAATTTAGCTGTATATACAGGTATTATTTTTTCTGTAATTGTA---GGTTTACATTTTTTAGGAAATAAATTATTACCTTCTAAATGGTCTATTTTATTTGAAAGTTTCTTTGCAAGTATTAATACTATGGTAAGAGAACAAATAGGT------AGAGAAATTTATTTACCTTTTATTTATTCATTATTTTTCTTTATTTTAGTCTCTAATTTAGTAGGTAATATTCCATATTCATTTACTATAACTACATCAGTAATAGTATCTATTGGTTTATCATTTACTATCTTAATTGGT---GTTACTATACTTGGATTATATATACATAAAATTCATTTCTTCTCTTTCTTTATACCTGCTGGGACACCTTTAGCTTTAGTTCCTTTATTAGTTTTAATTGAATTAATAAGTTACTTAGCTAGAGCTTTCTCATTAGGTATAAGATTA [...]
+Gyrodon_li GCTCCTTTATTTGGTTATATTTCTTTAACTTTAACTAATTTAGCTTTATATGCTATTATTATTTTATCTTTAACTGTT---GGTTTACATGTTTATGGAAATAAATTATTACCTTCTAAATGGTCTATCTTATTAGAAAGTTTCTTTGCAAGTATTAACACTATAGTAAGAGATCAAATCGGT------AGAGAAATTTATTTACCTTTTATTTATTCTTTATTTTTCTTTATTTTAGTTGCTAATTTAGTAGGTAATATACCTTATTCATTTACTATAACAACCTCAGTAATTGTATCTATTGGATTATCATTTACTATTTTAATTGGT---GTAACTATTTTAGGTTTATCTATCCATAAAATTCATTTCTTCTCATTCTTTATACCTTCTGGTACACCTTTAGCATTAGTTCCTTTATTAGTTTTAATTGAATTAATTAGTTATTTAGCTAGAGCTTTTTCATTAGGAATAAGATTA [...]
+Boletinell GCTCCTTTATTAGGATATATTAGTTTAACTATAACTAATTTAGCTTTATATTCAAGTATAATTTTATCTTTAATTGTA---GGATTACATATTTTTGGAAATAAATTATTACCTTCTAAATGGTCTATCTTATTAGAAAGTTTCTTTGCAAGTATTAATACTATGGTAAGAGATCAAATAGGT------AAAGAAATTTATTTACCATTTATTTATTCTTTATTCTTCTTTATTTTAGTAGCTAATTTAGTAGGTAATATACCTTATTCATTTACTATTACAACATCTGTAATTGTATCTATTGGATTATCTTTTACTATTTTAATTGGT---GTAACTATCCTTGGATTATCTATCCATAAAATACATTTCTTTTCATTCTTTATTCCTTCTGGTACACCTTTAGCATTAGTACCTCTATTAGTTTTAATTGAATTAATTAGTTACTTAGCTAGAGCTTTCTCATTAGGTATAAGATTA [...]
+Phaeogyrop GCACCTATATTAGGATATATAAGTTTAACATTAACTAATTTAGCCTTATATTCATGTATAATTTTATCTTTACTAGTA---GGATTACATATTTATGGAAATAAATTATTACCTTCTAAATGGTCTATCTTATTAGAAAGTTTTTTTGCTAGTATTAATACTATGGTTAGAGATCAAATAGGA------AGAGAAATATATTTACCATTTATTTATTCTTTATTCTTTTTTATATTAGTAGCTAATTTATTAGGTAATATTCCTTATTCATTTACTATAACTACATCAGTTATTGTATCTATTGGATTATCTTTTACTATTTTAATTGGA---GTGACTATACTTGGATTATCTATCCATAAAATACATTTCTTCTCATTCTTTATTCCTTCTGGTACACCTTTAGCATTAGTACCTTTATTAGTTTTAATTGAATTAATTAGTTATATTGCTAGAGCTTTCTCATTAGGTATAAGATTA [...]
+Coniophora GCTCCTGTATTAGGTTACTTTAATATTACATTAACTAACTTAGCTCTATACTCAGGTTTAATCTTCTCTTTAATTGTA---GGATTACATTACATGGGAAATAAATTATTACCATCAAGATGGTCAATTGTTTTAGAAAGTCTATTTGCTTCAATTAATTCAATGGTTAGAGACCAAATTGGA------AGAGAAATTTATTTACCTTTCATCTACGGATTATTCTTCTTCATCTTAATTGCAAATTTAGTAGGTAATGTGCCGTACTCATTTACTATAACTACTTCTGTTATTGTTTCTATCGGTTTATCATTCACTATTTTAATTGGT---GTAACTATCTTAGGATTAAGTATCCACAAAGTACACTTCTTCTCATTCTTCATTCCTTCAGGTACTCCTTTAGCCTTAGTTCCTTTATTAGTTTTAATTGAATTAATCAGTTACTTAGCTAGAGCTTTCTCATTAGGTATCCGATTA [...]
+Hygrophoro GCTCCTATATTAGGTTATATCAGTTTAACTTTAACAAATTTAGCTTTATACTCACTAATAATCTTTTCTATAATAATT---GGAATACACTATATGGGTAATAGATTGTTACCTTCAAAATGGTCTATTTTATTAGAAAGTTTATTTGCAAGTATAAATTCAATGGTTAGAGAACAAATAGGA------AAAGAAATATATTTACCATTTATTTATTCTTTATTTTTCTTCATATTAATTGCTAATTTATTAGGTAATATACCATATTCATTTACAATAACAACATCAGTAATTGTATCAATAGGTCTATCATTTACTATATTAATAGGA---GTAACAATTCTTGGTTTATATATTCACAAAATTCATTTCTTCTCATTCTTTATTCCTTCAGGAACTCCTTTAGCTTTAGTACCTTTATTAGTTTTAATTGAATTAATAAGTTACTTAGCTAGAGCTTTCTCATTAGGTATAAGATTA [...]
+Serpula_hi GCACCAATTTTAGGTTATATAAGTTTCACTTTAACTAATTTAGGATTATACTCAGCATTAATCTTTACAGTAATTTTA---GGACTACATTATATGGGAAATAAATTATTACCTTCAAAATGGTCTATAGCCTTAGAAGTTTTATTTGCAAGTATAAACTCAATAGTAAGAGAACAAATCGGT------AAAGAAATTTATTTACCATTTATTTATTCACTATTCTTTTTCATATTAACAGCCAATTTAATAGGTAATATACCATATTCATATACAATAACTACTTCAATTATAGTATCAATTGGATTATCTTTTACAATATTAATAGGA---GTAACAATTTTAGGATTATCTATACATAAAATACATTTCTTTTCTTTCTTTATACCTTCAGGAACACCTTTAGCTTTAGTACCTCTATTAGTTTTAATTGAATTAATAAGTTACTTAGCTCGAGCATTTTCTTTAGGAATACGATTA [...]
+Tapinella_ GCTCCTCTTTTTGGATATTTAAATATAACTGTAACTAACTTATCTTTATATTCTTTATTAATTTTCAGTGTTATTGTT---GGATTACATTATATGGGTAATAAATTATTACCTTCTAAATGGTCTATAACATTAGAAAGTTTATTTGCAAGTATTAATTCTATGGTTAGAGAACAAATAGGG------AAAGAAATTTATTTACCATTTATTTATGCTTTATTCTTCTTTATTTTAATAGCTAATTTAATGGGTAATATCCCTTATTCATATACAATTACTACTTCAATAATTGTTTCTATAGGATTATCTTTCACTATTTTAATTGGA---GTAACAATTTTAGGAATTTCTATCCATAAATTACATTTTTTCTCCTTTTTTATACCTTCCGGTACTCCTTTAGCTTTAGTTCCTTTACTTGTATTAATTGAATTAATAAGTTATTTAGCTAGAGCATTTTCTTTAGGAATAAGATTA [...]
+Paxillus_a GCTCCTATTTTTGGATACTTAAATATAACTTTAACTAATTTATCATTATATTCATTTTTAATATTTAGTCTTATTATA---GGATTACATTATATGAGCAATAAATTAATACCATCTAAATGGTCTATAACATTAGAAAGTTTATTTGCAAGTATTAATTCTATGGTTAGAGAACAAATAGGT------AAAGAAATTTATTTACCATTTATTTATGCTTTATTCTTCTTTATTTTAATAGCTAATTTAATAGGTAATATTCCATATTCATATACAATAACTACCTCAATTATTGTCTCCATTGGGTTATCTTTTACTATATTAATTGGA---GTAACAATTTTAGGTTTATCAATTCATAAATTACATTTCTTCTCTTTCTTTATACCTTCTGGAACTCCTTTGGCTTTAGTTCCTTTATTAGTTTTAATTGAATTAATTAGTTATTTAGCTAGAGCATTTTCTTTAGGTATAAGATTA [...]
+Paxillus_i GCTCCTTTATTTGGTTATATTTCTTTAACTTTAACTAATTTAGCTTTATATGCTATTATTATTTTATCTTTAACTGTT---GGTTTACATATTTACGGAAATAAATTATTACCATCTAAATGGTCTATCTTATTTGAAAGTTTCTTTGCAAGTATTAATTCTATAGTTAGAGATCAAATCGGT------AAAGAAATTTATTTACCTTTTATTTATTCTTTATTTTTCTTTATTTTAGTAGCTAATTTAGTAGGTAATATTCCTTATTCATTTACTATTTCAACATCAGTTATTGTATCTATTGGATTATCTTTTACTATTTTAATTGGT---GTAACTATTTTAGGTTTATCTATTCATAAAATTCATTTCTTCTCATTCTTTATTCCTTCTGGAACACCTTTAGCTTTAGTTCCTCTATTAGTTTTAATTGAATTAATTAGTTATTTAGCTAGAGCTTTCTCATTAGGTATTAGATTA [...]
+Paxillus_f GCTCCTTTATTTGGTTATATTTCTTTAACTTTAACTAATTTAGCTTTATATGCTATTATTATTTTATTTTTAACTGTT---GGTTTACATATTTACGGAAATAAATTATTACCATCTAAATGGTCTATCTTATTTGAAAGTTTCTTTGCAAGTATTAATTCTATAGTTAGAGATCAAATTGGT------AAAGAAATTTATTTACCTTTTATTTATTCTTTATTTTTCTTTATTTTAGTAGCTAATTTAGTAGGTAATATTCCTTATTCATTTACTATTACAACATCAGTTATTGTATCTATTGGATTATCTTTTACTATTTTAATTGGT---GTAACTATTTTAGGTTTATCTATTCATAAAATTCATTTCTTCTCATTCTTTATTCCTTCTGGAACACCTTTAGCTTTAGTTCCTCTATTGGTTTTAATTGAATTAATTAGTTATTTAGCTAGAGCTTTCTCATTAGGTATTAGATTA [...]
+Chalciporu TCTCCTTTATTATTAAATACATCTATAAATATAACAAATTCAGCTATATATACATATATAGTTGTTCAAATAATTTTACTTTTTATATATAATTATGCTGGAAAATTAATACCTAATAAAAAATATATTTTATTAGAAAGTTTATTTGCAAGTATAAATACTATGGTAAGAGATCAAATAGGT------AGAGAAATCTATTTACCTTTTATATATTGTTTATTTGTATTTATTTTATTTGCTAATTTAGTAGGAAATATACCATATACATTTACAATAACAACCTCAGTAATAATCTCTATAGGATTATCATTTACTATTTTAATAGGT---GTAACTATTTTAGGATTATCAATCCATAAAATTCACTTTTTCTCATTCTTTATTCCTTCTGGAACACCTTTAGCATTAGTTCCTTTATTAGTTTTAATTGAATTAATAAGTTATTTAGCTAGAGCTTTCTCATTAGGTATAAGATTA [...]
+Chamonixia TCTCCTTTATTATTTAATACATCATTTTCTCTTACAAATTCAGCTTTATTTACAGTTTTAGTATTAACTTTAATTTTA---TTTATACATAAAAATATTGGGAAATTAATACCAAATAAAGAAAGTATCTTATTAGAAAGTTTCTTTGCTAGTATAAATACTATAGTAAGAGATCAAATTGGT------AGAGAAGCTTATTTACCTTTTATCTATTCTTTATTCTTATTTATTTTATGTTCTAATTTAGTTGGTAATATACCTTATACATTTACTATTACAACCTCAATAATAATTTCAATAGGATTATCATTTACTATATTAATAGGT---GTAACTATTTTAGGTTTATCTATCCATAAAATTCACTTCTTCTCATTCTTTATTCCTTCTGGTACTCCTTTAGCTTTAGTTCCTTTATTAGTTTTAATTGAATTAATTAGTTATTTAGCAAGAGCTTTCTCATTAGGAATAAGATTA [...]
+Phylloporu TCTCCTTTATTCTTAAATACGTCTTTTACTGTTACAAATTCAGCTTTATTTACAGTATTAGTATTATCTCTTATTTTA---TTTTTACATCAAAATAGTGGGAAATTAATACCTAATAAAGAAAGTATCTTATTAGAAAGTTTATTTGCAAGTATTAATACTATAGTAAGAGATCAAATAGGT------AGAGAAGTATATTTACCTTTTATCTATTCTTTATTCTTATTTATTTTATGTTCTAATTTAGTTGGTAATATACCTTATACATTTACTATAACTACTTCAATTATAGTTTCTATAGGATTATCATTCACTATCTTAATTGGT---GTAACTATTTTAGGATTATCTATTCATAAAATTCACTTTTTCTCATTCTTTATTCCTTCTGGAACACCTTTAGCTTTAGTTCCTTTATTAGTTTTAATTGAATTAATTAGTTATTTAGCTAGAGCTTTCTCATTAGGTATAAGATTA [...]
+Xerocomus_ TCTCCTGAATTCTTTAATACATCTTTTGCTCTTACAAATTTAGCTTTATTTTCAGTATTAGTATTATCTCTTATTTTA---TTTTTACATCAAAATAGTGGTAAATTAATACCAAATAAAGAAAGTATCTTATTAGAAAGTTTATTTGCTAGTATTAATACTATAGTAAGAGATCAAATTGGT------AGAGAAGTATATTTACCATTTATCTATTCTTTATTCTTATTTATTTTATGTTCTAATTTAGTTGGTAATATACCATATACATTTACTATAACAACATCAATAATAGTTTCAATAGGATTATCATTTACTATATTAATAGGT---GTAACTATTTTAGGTTTATCTATTCATAAAATTCACTTTTTCTCATTCTTTATTCCTTCCGGAACACCTTTAGCTTTAGTTCCTTTATTAGTTTTAATTGAATTAATTAGTTATTTAGCTAGAGCTTTCTCATTAGGTATAAGATTA [...]
+Boletus_pa TCTCCTTTATTCTTTAATACATCTTTTACTATTACAAATTCAGCTTTATTTACAGTATTAGTATTATCTTTAATTTTA---TTTATACACCAAAACAGTGGAAAATTAATACCAAATAAAGAAAGTATCTTATTAGAAAGTTTATTTGCAAGTATTAATACTATAGTAAGAGATCAAATAGGT------AGAGAAGTGTATTTACCATTTATCTATTCTTTATTCTTATTTATTTTATGTTCTAATTTAGTTGGTAATATCCCTTATACATTCACTATAACAACCTCAATAATAATATCAATAGGTTTATCATTTACTATATTAATAGGT---GTAACTATATTAGGATTATCTATTCATAAAATACACTTTTTCTCATTCTTTATCCCTTCAGGTACACCTTTAGCTTTAGTTCCTCTATTAGTTTTAATTGAATTAATTAGTTATTTAGCTAGAGCTTTCTCATTAGGTATAAGATTA [...]
+Boletus_ed TCTCCTTTATTCTTTAATACATCTTTTACTATTACAAATTCAGCTTTATTTACAGTATTAGTATTATCTCTAATTTTA---TTTATACATCAAAATAGTGGTAAATTAATACCAAATAAAGAAAGTATCTTATTAGAAAGTTTATTTGCAAGTATTAATACTATAGTAAGAGATCAAATAGGT------AGAGAAGTGTATTTACCTTTTATCTATTCTTTATTCTTATTTATATTATGTTCTAATTTAGTTGGTAATATCCCTTATACATTTACTATAACAACATCAATAATAGTATCAATAGGATTATCATTTACTATATTAATAGGT---GTAACTATTTTAGGTTTATCTATTCACAAAATTCACTTTTTCTCATTCTTTATTCCTTCTGGTACACCTTTAGCTTTAGTTCCTTTATTAGTTTTAATTGAATTAATTAGTTATTTAGCTAGAGCTTTCTCATTAGGTATAAGATTA [...]
diff --git a/README b/README
new file mode 100644
index 0000000..b5d7c46
--- /dev/null
+++ b/README
@@ -0,0 +1,20 @@
+Basic installation is done by moving to the /src directory
+and typing:
+> make
+
+This creates the executables:
+
+Phi & ppma_2_bmp
+
+For help type:
+
+> Phi
+
+To run on a fasta file type:
+
+> Phi -f filename.fasta
+
+See the file manual.pdf for further details.
+
+Email comments or questions to trevor at mcb.mcgill.ca
+See also: www.mcb.mcgill.ca/~trevor
diff --git a/h_pylori.fasta b/h_pylori.fasta
new file mode 100644
index 0000000..a8413cd
--- /dev/null
+++ b/h_pylori.fasta
@@ -0,0 +1,297 @@
+>gi|2228443|gb|U63254.1|HPU63254 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCCGATAAAATCGGTCAGGTTCGTATCGCTACGGGTGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTCAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTAAAAGTTTCTAGTTCAGCAGGCA
+CAGGGATTGGCGTGTTAGCAGAAGTGATTAACAAAAATTCTAACCGAACAGGGGTTAAAGCTTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATTCAT
+TTGGGTAATATCGCAGATATTAAGAAAAATGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGTGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATCAAGACCGATAGCGTCAGTAATGGGCCTAGCGCTTTAACG
+
+>gi|2228441|gb|U63253.1|HPU63253 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCAGATAAAATCGGTCAGGTTCGTATCGCTACAGGCGCGTTAATCACGGCTTCTGGAGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTGACTTTAGAGAGCGTAAAAATCTCTAGTTCAGCAGGCA
+CAGGGATTGGCGTGTTAGCAGAAGTGATCAACAAAAACTCTAACCAAACAGGGGTTAAAGCTTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTTCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATTCAT
+TTGGGCAATATCGCAGACATTAAGAAAAACGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGTGTGGAAGCTTATACGGATCCAAAAGGGCGCTTGAATTTGCGCAGTTTAGATGGTCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAATGGGCCTAGCGCTTTAACG
+
+>gi|2228433|gb|U63249.1|HPU63249 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCAGATAAAATCGGTCAGGTTCGTATCGCTACAGGTGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTAAAAATCTCTAGTTCAGCAGGCA
+CAGGGATTGGCGTGTTAGCAGAAGTGATTAACAAAAACTCTAACCAAACAGGGGTTAAAGCTTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTTCAGTCAGGAAGTTTGAGTAATTTAACCTTAAACGGGATTCAT
+TTGGGTAATATCGCAGACATTAAGAAAAACGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGCGTGGAAGCTTACACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTTTAGATGGTCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAATGGGCCTAGCGCTTTAACG
+
+>gi|2228431|gb|U63248.1|HPU63248 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCCGATAAAATCGGTCAGGTTCGTATCGCTACAGGTGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGTGTGAATGATGTAACTTTAGAGAGCGTAAAAGTTTCTAGTTCAGCAGGCA
+CAGGGATTGGCGTGTTAGCGGAAGTGATCAACAAAAACTCTAACCGAACAGGCGTTAAAGCCTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATTCAT
+TTGGGTAATATCGCAGATATTAAGAAAAACGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGCGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGCCG
+TGGGATTGAAATTAAAACCGATAGTGTCAGTAATGGGCCTAGCGCTTTAACG
+
+>gi|2228429|gb|U63247.1|HPU63247 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCTGATAAAATCGGTCAGGTTCGTATCGCTACAGGTGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAGTCTCTAGTTCAGCAGGCA
+CAGGGATCGGTGTGTTAGCGGAAGTGATCAACAAAAACTCTAACCGAACAGGCGTTAAAGCTTATGCGAG
+CGTTATCACCACCAGCGATGTGGCGGTCCAATCAGGAAGTTTGAGTAATTTAACCTTAAATGGAATCCAT
+TTGGGTAATATCGCAGATATTAAGAAAAACGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGCGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAATGGGCCTAGTGCTTTAACG
+
+>gi|2228427|gb|U63246.1|HPU63246 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCAGATAAAATCGGTCAGGTTCGTATCGCTACAGGTGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTAAAAATCTCTAGTTCAGCAGGCA
+CAGGGATTGGCGTGTTAGCAGAAGTGATTAACAAGAACTCTAACCAAACAGGGGTTAGAGCTCATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACCTTAAACGGGATCCAT
+TTGGGTAATATCGCAGATATTAAGAAAAACGACTCAGACGGAAGGTTGGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGTGTGGAAGCTTATACGGATCAAAACGGGCGCTTGAATTTGCGCAGTTTAGATGGTCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAGTGGGCCTAGTGCTTTAACG
+
+>gi|2228425|gb|U63245.1|HPU63245 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCCGATAAAATCGGTCAGGTTCGTATCGCTACAGGTGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAGTCTCTAGTTCAGCAGGCA
+CAGGGATTGGCGTGTTAGCAGAAGTGATTAACAAGAACTCTAACCGAACAGGGGTTAAAGCTTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACTTTAAATGGGATTCAT
+TTGGGTAATATCGCAGATATTAAGAAAAACGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGTGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATCAAGACCGATAGCGTCAGTAACGGGCCTAGTGCTTTAACG
+
+>gi|2228421|gb|U63243.1|HPU63243 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCTGATAAAATTGGTCAGGTTCGTATCGCTACAGGTGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAGTCTCTAGTTCAGCAGGCA
+CAGGGATCGGCGTGTTAGCAGAAGTGATCAACAAAAACTCTAACCGAACAGGCGTTAAAGCTTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACTTTAAATGGGATTCAT
+TTGGGTAATATCGCAGATATTAAGAAAAACGACTCAGACGGACGATTGGTTGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGCGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAATGGGCCTAGTGCTTTAACG
+
+>gi|2228419|gb|U63242.1|HPU63242 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCCGATAAAATCGGTCAGGTTCGTATCGCTACAGGTGCGTTAATCACCGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAGTCTCTAGTTCAGCAGGCA
+CAGGGATCGGTGTGTTAGCAGAAGTGATTAACAAAAATTCTAACCGAACAGGCGTTAAAGCTTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATCCAT
+TTGGGGAATATCGCAGATATTAAGAAAAATGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGCGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAACGGGCCTAGTGCTTTAACG
+
+>gi|2228417|gb|U63241.1|HPU63241 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCAGATAAAATCGGTCAGGTTCGTATCGCTACAGGCGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAGTCTCTAGTTCAGCAGGCA
+CAGGCATTGGCGTGTTAGCAGAAGTGATTAACAAAAATTCTAACCGAACAGGGGTTAAAGCTTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTCCAATCAGGAAGTTTGAGTAATTTAACTTTAAATGGGATCCAT
+TTGGGCAATATCGCAGATATTAAGAAAAACGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGTGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAATGGGCCTAGTGCTTTAACG
+
+>gi|2228415|gb|U63240.1|HPU63240 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCCGATAAAATCGGCCAGGTTCGTATCGCTACAGGTGCGTTAATCACCGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAGTCTCTAGTTCAGCAGGCA
+CAGGGATTGGCGTGTTAGCGGAAGTGATCAACAAAAACTCTAACCGAACAGGGGTCAAAGCTTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATTCAT
+TTGGGGAATATCGCAGATATTAAGAAAAACGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGTGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGTAGTATAGATGGTCG
+TGGGATTGAAATCAAGACCGATAGCGTCAGTAATGGGCCTAGTGCTTTAACG
+
+>gi|2228413|gb|U63239.1|HPU63239 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCCGATAAAATCGGTCAGGTTCGTATCGCTACAGGCGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAGTTTCTAGTTCAGCAGGCA
+CGGGGATCGGTGTGTTAGCGGAAGTGATCAACAAAAACTCTAACCGAACAGGGGTTAAAGCTTATGCGAG
+CGTTATCACTACGAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATTCAT
+TTGGGTAATATCGCAGATATTAAGAAAAATGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGCGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAACGGGCCTAGCGCTTTAACG
+
+>gi|2228411|gb|U63238.1|HPU63238 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCAGATAAAATCGGTCAGGTTCGTATCGCTACAGGTGCATTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTAAAAATCTCTAGTTCAGCAGGCA
+CAGGGATCGGCGTGTTAGCGGAAGTGATTAACAAAAACTCTAACCAAACAGGGGTTAAAGCTTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTTCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATTCAT
+TTGGGCAATATTGCAGACATTAAGAAAAACGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGCGTGGAAGCTTACACGGATCAAAACGGGCGCTTGAATTTGCGCAGTTTAGATGGTCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAATGGGCCTAGCGCTTTAACG
+
+>gi|2228409|gb|U63237.1|HPU63237 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCCGATAAAATCGGTCAGGTTCGTATCGCTACAGGCGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTGACTTTAGAGAGCGTAAAAGTTTCTAGTTCAGCAGGCA
+CAGGGATCGGCGTGTTAGCGGAAGTGATCAACAAAAACTCTAACCGAACAGGGGTTAAAGCTTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATTCAT
+TTGGGTAATATCGCAGACATTAAGAAAAACGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTCA
+CTTCAGAAACCGGTGTGGAAGCTTATACAGATCAAAAAGGGCGCTTGAATTTGCGCAGTTTGGATGGTCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAACGGGCCTAGCGCTTTAACG
+
+>gi|2228407|gb|U63236.1|HPU63236 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCGGATAAAATCGGTCAGGTTCGTATCGCTACAGGTGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAGTCTCTAGTTCAGCAGGCA
+CAGGGATCGGCGTGTTAGCAGAAGTGATCAACAAAAACTCTAACCAAACAGGCGTTAAGGCTTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTCCAATCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATCCAT
+TTGGGTAATATCGCAGATATTAAGAAAAACGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGCGTGGAAGCTTATACGGATCAAAACGGGCGCTTGAATTTGCGCAGTTTAGATGGCCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAATGGGCCTAGCGCTTTAACG
+
+>gi|2228405|gb|U63235.1|HPU63235 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCTGATAAAATCGGTCAGGTTCGTATCGCTACAGGCACGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAGTCTCTAGTTCAGCAGGCA
+CAGGGATTGGCGTGTTAGCAGAAGTGATTAACAAAAACTCTAACCGAACAGGCGTTAAAGCTTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGAATCCAT
+TTGGGCAATATCGCAGATATTAAGAAGAATGACTCAGACGGAAGGTTAGTCGTAGCGATCAATGCGGTTA
+CTTCAGAAACCGGTGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAACGGGCCTAGTGCTTTAACG
+
+>gi|2228403|gb|U63234.1|HPU63234 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCCGATAAAATCGGTCAGGTTCGTATCGCTACAGGTGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTCAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTAAAAGTTTCTAGTTCAGCAGGTA
+CAGGGATTGGCGTGTTAGCAGAAGTGATCAACAAAAACTCTAACCGAACAGGCGTTAAAGCTTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTCCAATCAGGAAGTTTGAGTAATTTAACCTTAAATGGAATTCAT
+TTGGGTAATATCGCAGATATTAAGAAAAACGACTCAGATGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGCGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAATGGGCCTAGCGCTTTAACG
+
+>gi|2228401|gb|U63233.1|HPU63233 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCCGATAAAATCGGTCAGGTTCGTATCGCTACAGGCGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTGACTTTAGAGAGCGTGAAAGTCTCTAGTTCAGCAGGCA
+CAGGGATTGGCGTGTTAGCAGAAGTGATCAACAAAAACTCTAACCGAACAGGGGTTAAAGCCTATGCGAG
+CGTTATCACCACAAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATTCAT
+TTGGGTAATATCGCAGATATTAAGAAAAACGACTCAGACGGACGGTTGGTTGCAGCGATCAATGCGGTTA
+CTTCAGAGACCGGCGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGCCG
+TGGGATTGAAATTAAAACCGATAGCGTCAGTAATGGGCCTAGCGCTTTAACG
+
+>gi|2228399|gb|U63232.1|HPU63232 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCTGATAAAATCGGTCAGGTTCGTATCGCTACAGGTGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCATGAAAGTCTCTAGTTCAGCAGGCA
+CAGGGATCGGCGTGTTGGCAGAAGTGATTAACAAAAACTCTAACCGAACAGGCGTTAAAGCCTATGCGAG
+CGTTATCACTACAAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATTCAT
+TTGGGGAATATCGCAGATATTAAGAAAAATGACTCAGACGGACGATTGGTTGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGTGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAACGGGCCTAGCGCTTTAACG
+
+>gi|2228397|gb|U63231.1|HPU63231 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCCGATAAAATCGGTCAGGTTCGTATCGCTACAGGCGCGTTAATCACAGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAGTCTCTAGTTCAGCAGGCA
+CAGGGATTGGCGTGTTAGCAGAAGTGATTAACAAAAATTCTAACCGAACAGGGGTTAAAGCTTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATCCAT
+TTGGGTAATATCGCAGATATTAAGAAAAACGACTCAGACGGACGATTGGTTGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGCGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAATGGGCCTAGTGCTTTAACG
+
+>gi|2228395|gb|U63230.1|HPU63230 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCTGATAAAATCGGTCAGGTTCGTATCGCTACAGGCGCATTAATCACCGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAGTTTCTAGTTCAGCAGGCA
+CGGGGATCGGTGTGTTAGCGGAAGTGATCAACAAAAACTCTAACCGAACAGGCGTTAAAGCTTATGCGAG
+CGTTATTACCACAAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATCCAT
+TTGGGCAATATCGCAGATATTAAGAAAAACGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGCGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAATGGGCCTAGCGCTTTAACG
+
+>gi|2228393|gb|U63229.1|HPU63229 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCCGATAAAATCGGTCAGGTTCGTATCGCTACAGGCGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAGTTTCTAGTTCAGCAGGCA
+CAGGGATTGGCGTGTTAGCGGAAGTGATCAACAAAAATTCTAACCGAACAGGGGTTAAAGCTTATGCGAG
+CGTTATCACCACAAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATCCAT
+TTGGGTAATATCGCAGATATTAAGAAAAATGACTCAGACGGACGATTGGTTGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGCGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATCAAAACCGACAGCGTCAGTAATGGGCCTAGTGCTTTAACG
+
+>gi|2228391|gb|U63228.1|HPU63228 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCAGATAAAATCGGTCAGGTTCGTATCGCTACAGGTGCGTTAATCACGGCTTCTGGAGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAATCTCTAGTTCAGCAGGCA
+CAGGGATTGGCGTGTTAGCAGAAGTGATCAACAAAAACTCTAACCAAACAGGGGTTAGAGCCTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATTCAT
+TTGGGCAATATTGCAGATATTAAGAAAAACGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGCGTGGAAGCTTATACGGATCAAAATGGGCGCTTAAATTTGCGCAGTTTAGATGGCCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAGTGGGCCTAGCGCTTTAATG
+
+>gi|2228389|gb|U63227.1|HPU63227 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCCGATAAAATCGGTCAGGTTCGTATCGCTACAGGTGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAGTCTCTAGTTCAGCAGGCA
+CAGGGATTGGTGTGTTAGCAGAAGTGATCAACAAAAACTCTAACCGAACAGGGGTTAAAGCTTATGCGAG
+CGTTATTACCACAAGCGATGTGGCGGTCCAATCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATCCAT
+TTGGGTAATATCGCAGATATTAAGAAAAACGACTCAGACGGACGATTGGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGCGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAATGGGCCTAGTGCTTTAACG
+
+>gi|2228387|gb|U63226.1|HPU63226 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCCGATAAAATCGGTCAGGTTCGTATCGCTACAGGCGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTCAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTAAAAGTTTCTAGTTCAGCAGGTA
+CAGGGATTGGCGTGTTAGCAGAAGTGATCAACAAAAACTCTAACCGAACAGGCGTTAAAGCTTATGCGAG
+CGTTACCACCACAAGCGATGTGGCGGTCCAATCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATTCAT
+TTGGGTAATATCGCAGATATTAAGAAAAATGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGTGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATTAAAACCGATAGCGTCAGTAACGGGCCTAGTGCTTTAACG
+
+>gi|2228385|gb|U63225.1|HPU63225 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCTGATAAAATCGGTCAGGTTCGTATCGCTACAGGTGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAGTCTCTAGTTCAGCAGGCA
+CAGGGATTGGCGTGTTAGCAGAAGTGATTAACAAGAACTCTAACCGAACAGGGGTTAAAGCTTATGCGAG
+CGTTATTACCACAAGCGATGTGGCGGTTCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATCCAT
+TTGGGGAATATCGCAGATATTAAGAAAAATGACTCAGACGGACGATTGGTTGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGCGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGCCG
+TGGGATTGAAATTAAAACCGATAGCGTCAGTAATGGGCCTAGCGCTTTAACG
+
+>gi|2228383|gb|U63224.1|HPU63224 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCCGATAAAATCGGTCAGGTTCGTATCGCTACAGGTGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAGTCTCTAGTTCAGCAGGCA
+CAGGGATTGGCGTGTTAGCAGAAGTGATTAACAAAAACTCTAACCGAACAGGGGTTAAGGCTTATGCGAG
+CGTTATCACCACAAGCGATGTTGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATCCAT
+TTGGGCAATATCGCAGATATTAAGAAAAACGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGCGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAACGGGCCTAGCGCTTTAACG
+
+>gi|2228381|gb|U63223.1|HPU63223 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCCGATAAAATCGGTCAGGTTCGTATCGCTACAGGTGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAGTCTCTAGTTCAGCAGGCA
+CAGGGATTGGCGTGTTAGCGGAAGTGATCAACAAAAACTCTAACCGAACAGGCGTTAAAGCCTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATTCAT
+TTGGGTAATATCGCAGATATTAAGAAAAATGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGTGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATCAAAACCGACAGCGTCAGTAACGGGCCTAGCGCTTTAACG
+
+>gi|2228379|gb|U63222.1|HPU63222 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCCGATAAAATCGGTCAGGTTCGTATCGCTACAGGTGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTAGATGGCGTGAATGATGTAACTTTAGAGAGCGTAAAAGTTTCTAGTTCAGCAGGCA
+CAGGGATTGGCGTGTTAGCAGAAGTGATTAACAAAAATTCTAACCGAACAGGGGTTAAAGCTTATGCGAG
+CGTTATCACCACAAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATCCAT
+TTGGGCAATATCGCAGATATTAAGAAAAACGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTCA
+CTTCAGAAACCGGTGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATCAAAACCGATAGCGTCAGTAATGGGCCTAGCGCTTTAACG
+
+>gi|2228377|gb|U63221.1|HPU63221 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCCGATAAAATCGGTCAGGTTCGTATCGCTACAGGCGCATTAATCACCGCTTCTGGGGATATTAGCTTG
+ACTTTCAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAGTCTCTAGTTCAGCAGGCA
+CAGGGATCGGCGTGTTGGCAGAAGTGATTAACAAAAACTCTAACCGAACAGGCGTTAAAGCCTATGCGAG
+CGTTATCACCACAAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGCAATTTAACCTTAAATGGGATCCAT
+TTGGGTAATATCGCAGATATTAAGAAAAATGACTCAGACGGACGATTGGTTGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGCGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGCCG
+TGGGATTGAAATTAAAACCGATAGCGTCAGTAACGGGCCTAGCGCTTTAACG
+
+>gi|2228375|gb|U63220.1|HPU63220 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCGGATAAAATCGGTCAGGTTCGTATCGCTACAGGCGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTCAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTAAAAGTTTCTAGTTCAGCAGGCA
+CGGCGATCGGTGTGTTAGCAGAAGTGATCAACAAAAACTCTAACCGAACAGGCGTTAAAGCTTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTCCAATCAGGAAGTTTGAGTAATTTAACCTTAAACGGGATCCAT
+TTGGGCAATATCGCAGATATTAAGAAAAATGACTCAGACGGACGATTGGTTGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGCGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATTAAAACCGATAGCGTCAGTAATGGGCCTAGCGCTTTAACG
+
+>gi|2228373|gb|U63219.1|HPU63219 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCCGATAAAATCGGTCAGGTTCGTATCGCTACAGGTGCATTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTCAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAGTTTCTAGTTCAGCAGGCA
+CAGGGATTGGCGTGTTAGCAGAAGTGATCAACAAAAACTCTAACCGAACAGGGGTTAAAGCTTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTCCAGTCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATTCAT
+TTGGGTAATATCGCAGATATTAAGAAAAACGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGTGTGGAAGCTTATACGGATCAAAAAGGGCGCTTGAATTTGCGCAGTATAGATGGTCG
+TGGGATTGAAATCAAAACCGACAGCGTCAGTAATGGGCCTAGTGCTTTAACG
+
+>gi|2228371|gb|U63218.1|HPU63218 Helicobacter pylori major flagellar protein gene (flaA), partial cds
+TTCCGATAAAATCGGTCAGGTTCGTATCGCTACAGGCGCGTTAATCACGGCTTCTGGGGATATTAGCTTG
+ACTTTTAAACAAGTGGATGGCGTGAATGATGTAACTTTAGAGAGCGTGAAAGTTTCTAGTTCAGCAGGTA
+CAGGGATTGGCGTGTTAGCGGAAGTGATTAACAAAAACTCTAACCAAACAGGGGTTAAGGCTTATGCGAG
+CGTTATCACCACGAGCGATGTGGCGGTCCAATCAGGAAGTTTGAGTAATTTAACCTTAAATGGGATCCAT
+TTGGGTAATATCGCAGATATTAAGAAAAACGACTCAGACGGAAGGTTAGTCGCAGCGATCAATGCGGTTA
+CTTCAGAAACCGGTGTGGAAGCTTATACGGATCAAAACGGGCGCTTGAATTTGCGCAGTTTAGATGGTCG
+TGGGATTGAAATCAAAACTGACAGCGTCAGTAATGGGCCTAGCGCTTTAACG
+
diff --git a/noro.fasta b/noro.fasta
new file mode 100644
index 0000000..502d694
--- /dev/null
+++ b/noro.fasta
@@ -0,0 +1,650 @@
+>gi|47230997|gb|AY532135.1| Norovirus Hamburg316/1998/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCACCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATAT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATTTGAACCCCTACCTTTCTCATTTGGCCA
+GAATGTACAATGGTTATGCAGGTGGTTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTTACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAATTGGAACCTGTGTTGATCCCCTTACCTGATGTTAGGAACA
+ATTTCTATCATTACAATCAATCAAATGATTCTACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGAGTCCTCACGAGGCCATCCCCCGATTTT
+GATTTCATATTCTTGGTGCCACCCACAGTTGAATCAAGAACTAAACCATTCACCGTCCCAATCTTAACTG
+TTGAGGAAATGTCCAATTCAAGATTCCCCATTCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGATGGCGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTTACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGTGTGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTTCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGTCAAAACACGAAGTTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCAACAATGGGTACTCCCAAATTACTCAGGCAGAACTGGTCATAATGTGCACCTAGCTCCTGCC
+GTTGCCCCCACTTTTCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGATGTAGCGGGTATC
+CCAACATGAATCTGGATTGCCTACTCCCCCAGGAATGGGTGCAGCACTTCTACCAAGAAGCAGCTCCAGC
+ACAATCTGATGTGGCTCTACTGAGATTCGTGAATCCAGATACAGGTAGGGTTCTGTTTGAGTGCAAGCTC
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TTAGATTTGATTCCTGGGTCAACCAGTTCTACACACTTGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230995|gb|AY532134.1| Norovirus Hamburg236/1997/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATAT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATTTGAACCCCTACCTTTCTCATTTGGCCA
+GAATGTACAATGGTTATGCAGGTGGTTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTTACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAATTGGAACCTGTGTTGATCCCCTTACCTGATGTTAGGAACA
+ATTTCTATCATTACAATCAATCAAATGATTCTACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGAGTCCTCACGAGGCCATCCCCCGATTTT
+GATTTCATATTCTTGGTGCCACCCACAGTTGAATCAAGAATTAAACCATTCACCGTCCCGATCTTAACTG
+TTGAGGAAATGTCCAATTCAAGATTCCCCATTCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGATGGCGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTTACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGTGTGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTTCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGTCAAAACACGAAGTTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCAACAATGGGTACTCCCAAATTACTCAGGCAGAGCTGGTCATAATGTGCACCTAGCTCCTGCC
+GTTGCCCCCACTTTTCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGATGTAGCGGGTATC
+CCAACATGAATCTGGATTGCCTACTCCCCCAGGAATGGGTGCAGCACTTCTACCAAGAAGCAGCTCCAGC
+ACAATCTGATGTGGCTCTACTGAGATTCGTGAATCCAGATACAGGTAGGGTTCTGTTTGAGTGCAAGCTC
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TTAGATTTGATTCCTGGGTCAACCAGTTCTACGCACTTGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230993|gb|AY532133.1| Norovirus Hamburg189/1997/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATGT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGAGCCCTGATTTGAACCCCTACCTTTCTCATCTGGCCA
+GAATGTACAACGGTTATGCAGGTGGTTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCTAGCCAGGTTACTATG
+TTCCCCCACATAATAGTAGATGTTAGGCAATTGGAACCCGTGTTGATCCCCTTACCTGATGTTAGGAATA
+ACTTCTATCACTACAACCAATCAAATGACTCTACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACGGTCTCTTGTCGAGTCCTCACGAGGCCATCCCCCGATTTT
+GATTTTATATTCTTGGTGCCACCCACAGTTGAATCAAGAATTAAACCATTCACCGTCCCAATCTTAACTG
+TTGAGGAAATGTCCAATTCAAGGTTCCCCATTCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCATT
+TGTTGTCCAACCACAAAATGGTAGGTGCACGACTGACGGCGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTCACCCACATTGCAGGCAGCCACGACTATACAATGAATCTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATTCAAGGCATGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTTCACTTTACTCCAAAGCTGGGCAGTGTTCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGCCAAAACACGAAATTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCTCAACAATGGGTACTCCCAAATTACTCAGGTAGAACTGGTCATAATGTGCACCTAGCTCCTGCC
+GTTGCCCCCACTTTCCCGGGTGAGCAACTTCTTTTCTTCAGGTCCACTATGCCCGGATGTAGCGGGTATC
+CCAATATGAATCTGGATTGTCTACTCCCCCAGGAATGGGTGCAGCACTTTTACCAAGAAGCAGCTCCAGC
+GCAATCTGATGTGGCCCTGCTGAGATTTGTGAATCCAGACACAGGTAGGGTTCTGTTTGAGTGCAAGCTC
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TTAGATTTGATTCCTGGGTCAACCAGTTCTACACACTTGCCCCCATGGGAAATGGAGCGGGGCGCAGGCG
+TGCATTA
+
+>gi|47230991|gb|AY532132.1| Norovirus Hamburg180/1997/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATGT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATTTGAACCCCTACCTTTCTCATCTGGCCA
+GAATGTACAACGGTTATGCAGGTGGTTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCTAGCCAGGTTACTATG
+TTCCCCCACATAATAGTAGATGTTAGGCAATTGGAACCCGTGTTGATCCCCTTACCTGATGTTAGGAATA
+ACTTCTATCACTACAACCAATCAAATGACTCTACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGACGATGTCTTCACGGTCTCTTGTCGAGTCCTCACGAGGCCATCCCCCGATTTT
+GATTTTATATTCTTGGTGCCCCCCACAGTCGAATCAAGAACTAAACCATTCACCGTCCCAATCTTAACTG
+TTGAGGAAATGTCCAATTCAAGATTCCCCATTCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCATT
+TGTTGTCCAACCACAAAATGGTAGGTGCACGACTGACGGCGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTCACCCACATTGCAGGCAGCCACGACTATACAATGAATCTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATTCAAGGCATGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGCGTTCACTTTACTCCAAAGCTGGGCAGTGTTCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGCCAAAACACGAAATTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCTCAACAATGGGTACTCCCAAATTACTCAGGTAGAACTGGTCATAATGTGCACCTAGCTCCTGCC
+GTTGCCCCCACTTTCCCGGGTGAGCAACTTCTTTTCTTCAGGTCCACTATGCCCGGATGTAGCGGGTATC
+CCAATATGAATCTGGATTGTCTACTCCCCCAGGAATGGGTGCAGCACTTTTACCAAGAAGCAGCTCCAGC
+GCAATCTGATGTGGCCCTGCTGAGATTTGTGAATCCAGACACAGGTAGGGTTCTGTTTGAGTGCAAGCTC
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TTAGATTTGATTCCTGGGTCAACCAGTTCTACACACTTGCCCCCATGGGAAATGGAGCGGGGCGCAGGCG
+TGCATTA
+
+>gi|47230989|gb|AY532131.1| Norovirus Hamburg139/1997/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATAT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATTTGAACCCCTACCTTTCTCATTTGGCCA
+GAGTGTACAATGGTTATGCAGGTGGTTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTTACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAATTGGAACCTGTGTTGATCCCCTTACCTGATGTTAGGAACA
+ATTTCTATCATTACAATCAATCAAATGATTCTACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGAGTCCTCACGAGGCCATCCCCCGATTTT
+GATTTCATATTCTTGGTGCCACCCACAGTTGAATCAAGAACTAAACCATTCACCGTCCCAATCTTAACTG
+TTGAGGAAATGTCCAATTCAAGGTTCCCCATTCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGATGGCGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTTACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGTATGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTAAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTTCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGCCAAAACACGAAGTTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCAACAATGGGTACTCCCAAGTTACTCAGGCAGAACTGGCCATAATGTGCACCTAGCTCCTGCC
+GTTGCCCCCACTTTTCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGATGTAGCGGGTATC
+CCAACATGAATCTGGATTGCCTACTCCCCCAGGAATGGGTGCAGCACTTCTACCAAGAAGCAGCTCCAGC
+ACAATCTGATGTGGCTCTGCTGAGATTCGTGAATCCAGATACAGGTAGGGTTCTGTTTGAGTGCAAGCTC
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TTAGATTTGATTCCTGGGTCAACCAGTTCTACACACTTGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230987|gb|AY532130.1| Norovirus Hamburg137/1997/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATAT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATTTGAACCCCTACCTTTCTCATCTGGCCA
+GAATGTACAATGGTTATGCAGGTGGTTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTCCACCGCCGG
+GAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTTACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAATTGGAACCCGTGTTGATCCCCTTACCTGATGTTAGGAACA
+ATTTCTATCATTACAATCAATCAAATGATTCTACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGAGTCCTCACGAGGCCATCCCCCGATTTT
+GATTTCATATTCTTGGTGCCACCCACAGTTGAATCAAGAATTAAACCATTCACCGTCCCAATCTTAACTG
+TTGAGGAAATGTCCAATTCAAGGTTCCCCATTCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGATGGCGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTTACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGTATGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTAAGCACTGGGAGTGCCCACTTTACTCCAAAGCTGGGCAGTGTTCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGCCAAAACACGAAGTTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCAACAATGGGTACTCCCAAGTTACTCAGGCAGAACTGGCCATAATGTGCACCTAGCTCCTGCC
+GTTGCCCCCACTTTTCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGATGTAGCGGGTATC
+CCAACATGAATCTGGATTGCCTACTCCCCCAGGAATGGGTGCAGCACTTCTACCAAGAAGCAGCTCCAGC
+ACAATCTGATGTGGCTCTGCTGAGATTCGTGAATCCAGATACAGGTAGGGTTCTGTTTGAGTGCAAGCTC
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TTAGATTTGATTCCTGGGTCAACCAGTTCTACACACTTGCCCCCATGAGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230985|gb|AY532129.1| Norovirus Hamburg135/1998/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATGT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCATGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTAGGCCCTGATTTGAACCCCTACCTTTCTCATTTGGCCA
+GAATGTACAATGGTTATGCAGGTGGTTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTTACTATG
+TTTCCCCATATAATAGTAGATGTTAGGCAATTGGAACCTGTGTTGATTCCCTTACCTGATGTTAGGAATA
+ATTTCTATCATTACAATCAGTCAAATGACTCTACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGAGTCCTCACGAGGCCATCCCCCGATTTT
+GATTTCATATTCTTGGTGCCACCCACAGTTGAATCAAGAACTAAACCATTCACCGTCCCAATCTTAACTG
+TTGAGGAAATGTCCAATTCAAGATTCCCCATTCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+CGTTGTCCAACCACAAAATGGCAGGTGCACGACTGATGGCGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTCACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAGCTACGACCCAACAGAAGAGATCCCAGCCCCCCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGCATGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTCCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGCCAAAACACGAAATTCACCCCAGTCGGTGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCAACAATGGGTGCTCCCAAATTACTCAGGCAGAACAGGTCATAATGTACACCTAGCTCCTGCC
+GTTGCCCCCACTTTTCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGATGTAGCGGGTATC
+CCAACATGAATCTGGATTGCCTACTCCCCCAGGAATGGGTGCAGCACTTCTACCAAGAAGCAGCTCCAGC
+ACAATCTGATGTGGCTCTGCTGAGATTTGTGAATCCAGATACAGGTAGGGTTCTGTTTGAGTGCAAGCTC
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTATT
+TTAGATTTGATTCCTGGGTCAACCAGTTCTACACACTTGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTG
+
+>gi|47230983|gb|AY532128.1| Norovirus Hamburg048/1997/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATAT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATTTGAACCCCTACCTTTCTCATTTGGCCA
+GAATGTACAATGGTTATGCAGGTGGTTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTTACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAATTGGAACCTGTGTTGATCCCCTTACCTGATGTTAGGAACA
+ATTTCTATCATTACAATCAATCAAATGATTCTACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACGGTCTCTTGTCGAGTCCTCACGAGGCCATCCCCCGATTTT
+GATTTTATATTCTTGGTGCCCCCCACAGTCGAATCAAGAACTAAACCATTCACCGTCCCAATCTTAACTG
+TTGAGGAAATGTCCAATTCAAGATTCCCCATTCCTTTGGAAAAGTTGTACACGGGTCCCAGTAGTGCATT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGACGGTGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTCACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGTATACTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTAAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTTCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGCCAAAACACGAAGTTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCAACAATGGGTACTCCCAAGTTACTCAGGCAGAACTGGCCATAATGTGCACCTAGCTCCTGCC
+GTTGCCCCCACTTTTCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGATGTAGCGGGTATC
+CCAACATGAATCTGGATTGCCTACTCCCCCAGGAATGGGTGCAGCACTTCTACCAAGAAGCAGCTCCAGC
+ACAATCTGATGTGGCTCTGCTGAGATTCGTGAATCCAGATACAGGTAGGGTTCTGTTTGAGTGCAAGCTC
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TTAGATTTGATTCCTGGGTCAACCAGTTCTACACACTTGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230981|gb|AY532127.1| Norovirus Bochum339/1997/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATGT
+AATTGACCCCTGGATTAGAAACAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATTTGAACCCCTACCTTTCTCATTTGGCCA
+GAATGTACAATGGTTATGCAGGTGGTTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAGGGCTTGAGCCCCAGCCAGGTTACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAATTGGAACCTGTGTTGATTCCCTTACCTGATGGTAGGAACA
+ATTTCTACCATTACAATCAATCAAATGATTCTACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGAGTCCTCACGAGGCCATCCCCCGATTTT
+GATTTCATATTCTTGGTGCCACCCACAGTTGAATCAAGAACTAAACCATTCACCGTCCCAATCTTAACTG
+TTGAGGAAATGTCCAATTCAAGATTCCCCATTCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGATGGCGTGCTCCTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTCACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGCACGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGCTCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGCCAAAACACGAAATTCACCCCAGTCGGTGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCAACAATGGGTACTCCCAAATTACTCAGGTAGGACTGGTCATAATGTGCACCTAGCTCCTGCC
+GTTGCCCCCACTTTTCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGATGTAGCGGGTATC
+CCAACATGAATCTGGATTGCCTACTCCCCCAGGAATGGGTGCAGCACTTCTACCAAGAAGCAGCTCCAGC
+ACAATCTGATGTGGCTCTGCTGAGATTTGTGAATCCAGACACAGGTAGGGTTCTGTTTGAGTGTAAGCTC
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TTAGATTTGATTCCTGGGTCAACCAGTTCTACACACTTGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230980|gb|AY532126.1| Norovirus Bochum272/1998/GE nonfunctional capsid protein, partial sequence
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATGT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTGTCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATTTGAACCCCTACCTTTCCCATTTGGCCA
+GAATGTACAATGGTTATGCAGGTGGTTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+AAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTCACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAATTGGAACCTGTGTTGATCCCCTTACCTGATGTTAGGAACA
+ATTTCTACCATTACAATCAATCAAATGATTCTACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCCAATAATGCTGGGGATGATGTTTTCACAGTCTCTTGTCGAGTCCTCACGAGGCCATCCCCCGATTTT
+GATTTTATATTCTTGGTGCCACCCACAGTTGAATCAAGAACTAAACCATTCACCGTCCCAATCTTAACTG
+TTGAGGAAATGTCCAATTCAAGATTCCCCATTCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGATGGCGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACTTTCAGAGGGGATGTCACCCACATTGCAGGCAGTCATGATTACACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAATAAATCCCAGCCCCTCTGGGAACCCCAGATTTCGT
+GGGAAAGATCCAAGGCGTGCTCTCCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTTCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGCCAAAACACGAAATTCACCCCAGTCGGCGTCATCCAGGACGGCGGTAACCATCAAAA
+TGAACCCCACCAATGGGTGCTCCCAAACTACTCAGGTAGAACTGGTCATAATGTGCACCTAGCCCCTGCC
+GTTGCCCCCACTTTTCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGATGTAGCGGGTATC
+CCAATATGAATCTGGATTGCCTACTCCCCCAGGAATGGGTGCAGCACTTCTACCAAGAAGCAGCTCCAGC
+ACAATCTGATGTGGCTCTGCTGAGATTTGTGAATCCAGACACAGGTAGGGTTCTGTTTGAGTGCAAGCTC
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TTAGATTTGATTCTTGGGTCAACCAGTTTTACACACTTGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230978|gb|AY532125.1| Norovirus Bochum224/1998/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATGT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATTTGAACCCTTACCTTTCTCATTTGGCCA
+GAATGTACAATGGTTATGCAGGTGGCTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAGTCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTTACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAACTGGAACCTGTGTTGATCCCCTTACCTGATGTCAGGAACA
+ATTTCTATCATTACAATCAATCAAATGATTCCACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGAGTCCTCACAAGGCCATCCCCCGATTTT
+GATTTTATATTTTTGGTGCCACCCACAGTTGAATCAAGAACTAAACCGTTCACCGTCCCAATCCTAACTG
+TTGAGGAAATGTCCAATTCAAGGTTCCCCATCCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGATGGTGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTCACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGCATGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTCCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGCCAAAACACGAAATTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCAACAATGGGTGCTCCCAAATTACTCAGGTAGAACTGGTCATAATGTACACCTAGCTCCTGCC
+GTTGCCCCCACTTTTCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGGTGTAGCGGGTATC
+CTAACATGAATCTGGATTGCCTACTCCCCCAAGAATGGGTGCAGCACTTCTACCAAGAAGCAGCTCCAGC
+ACAATCTGATGTGGCTCTGCTGAGATTTGTGAATCCAGATACAGGTAGGGTTCTGTTTGAGTGCAAGCTT
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TCAGATTTGATTCCTGGGTCAACCAGTTCTACACACTCGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230976|gb|AY532124.1| Norovirus Bochum220/1997/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCGCCTGTAGCGGGCCAACAAAATGT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATTTGAACCCTTACCTTTCTCATTTGGCCA
+GAATGTACAATGGTTATGCAGGTGGCTTTGAAGTGCAGGTAATCCTCGCGAGGAACGCGTTCACCGCCGG
+GAAAGTCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTTACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAACTGGAACCTGTGTTGATCCCCTTACCTGATGTCAGGAACA
+ATTTCTATCATTACAATCAATCAAATGATTCCACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGAGTCCTCACAAGGCCATCCCCCGATTTT
+GATTTTATATTTTTGGTACCACCCACAGTTGAATCAAGAACTAAACCGTTCACCGTCCCAATCCTAACTG
+TTGAGGAAATGTCCAATTCAAGGTTCCCCATCCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGATGGTGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTCACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGCATGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTCCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGCCAAAACACGAAATTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCAACAATGGGTGCTCCCAAATTACTCAGGTAGAACTGGTCATAATGTACACCTAGCTCCTGCC
+GTTGCCCCCACTTTTCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGGTGTAGCGGGTATC
+CCAACATGAATCTGGATTGCCTACTCCCCCAAGAATGGGTGCAGCACTTCTACCAAGAAGCAGCTCCAGC
+ACAATCTGATGTGGCTCTGCTGAGATTTGTGAATCCAGATACAGGTAGGGTTCTATTTGAGTGCAAGCTT
+CATAAATCAGGCTATGTCACAGTGGCCCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TCAGATTTGATTCCTGGGTCAACCAGTTCTACACACTCGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230974|gb|AY532123.1| Norovirus Bochum136/1998/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATGT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATTTGAACCCTTACCTTTCTCATTTGGCCA
+GAATGTACAATGGTTATGCAGGTGGCTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAGTCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTTACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAACTGGAACCTGTGTTGATCCCCTTACCTGATGTCAGGAACA
+ATTTCTATCATTACAATCAATCAAATGATTCCACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGAGTCCTCACAAGGCCATCCCCCGATTTT
+GATTTTATATTTTTGGTGCCACCCACAGTTGAATCAAGAACTAAACCGTTCACCGTCCCAATCCTAACTG
+TTGAGGAAATGTCCAATTCAAGGTTCCCCATCCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGATGGTGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTCACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGCATGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTCCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGCCAAAACACGAAATTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCAACAATGGGTGCTCCCAAATTACTCAGGTAGAACTGGTCATAATGTACACCTAGCTCCTGCC
+GTTGCCCCCACTTTTCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGGTGTAGCGGGTATC
+CCAACATGAATCTGGATTGCCTACTCCCCCAAGAATGGGTGCAGCACTTCTACCAAGAAGCAGCTCCAGC
+ACAATCTGATGTGGCTCTGCTGAGATTTGTGAATCCAGATACAGGTAGGGTTCTGTTTGAGTGCAAGCTT
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TCAGATTTGATTCCTGGGTCAACCAGTTCTACACACTCGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230972|gb|AY532122.1| Norovirus Bochum108/1997/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATGT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATTTGAACCCTTACCTTTCTCATTTGGCCA
+GAATGTACAATGGTTATGCAGGTGGCTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAGTCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTTACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAACTGGAACCTGTGTTGATCCCCTTACCTGATGTCAGGAACA
+ATTTCTATCATTACAATCAATCAAATGATTCCACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGAGTCCTCACAAGGCCATCCCCCGATTTT
+GATTTTATATTTTTGGTGCCACCCACAGTTGAATCAAGAACTAAACCGTTCACCGTCCCAATCCTAACTG
+TTGAGGAAATGTCCAATTCAAGGTTCCCCATCCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGATGGTGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCGGAGGGGATGTCACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGCATGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTCCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGCCAAAACACGAAATTCACCCCAGTCGGCGTCATCCAGGACGGTGATAACCATCAAAA
+TGAACCCCAACAATGGGTGCTCCCAAATTACTCAGGTAGAACTGGTCATAATGTACACCTAGCTCCTGCC
+GTTGCCCCCACTTTTCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGGTGTAGCGGGTATC
+CTAACATGAATCTGGATTGCCTACTCCCCCAAGAATGGGTGCAGCACTTCTACCAAGAAGCAGCTCCAGC
+ACAATCTGATGTGGCTCTGCTGAGATTTGTGAATCCAGATACAGGTAGGGTTCTGTTTGAGTGCAAGCTT
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TCAGATTTGATTCCTGGGTCAACCAGTTCTACACACTCGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230970|gb|AY532121.1| Norovirus Bochum031/1997/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATGT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATTTGAACCCTTACCTTTCTCATTTGGCCA
+GAATGTACAATGGTTATGCAGGTGGCTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAGTCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTTACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAACTGGAACCTGTGTTGATCCCCTTACCTGATGTCAGGAACA
+ATTTTTATCATTACAATCAATCAAATGATTCCACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGAGTCCTCACAAGGCCATCCCCCGATTTT
+GATTTTATATTTTTGGTGCCACCCACAGTTGAATCAAGAACTAAACCGTTCACCGTCCCAATCCTAACTG
+TTGAGGAAATGTCCAATTCAAGGTTCCCCATCCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGATGGTGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTCACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGCACGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTCCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGCCAAAACACGAAATTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCAACAATGGGTGCTCCCAAATTACTCAGGTAGAACTGGTCATAATGTGCACCTAGCTCCTGCC
+GTTGCCCCCACTTTTCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGGTGTAGCGGGTATC
+CCAACATGAATCTGGATTGCCTACTCCCCCAAGAATGGGTGCAGCACTTCTACCAAGAAGCAGCTCCAGC
+ACAATCTGATGTGGCTCTGCTGAGATTTGTGAATCCAGATACAGGTAGGGTTCTGTTTGAGTGCAAGCTT
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TCAGATTTGATTCCTGGATCAACCAGTTCTACACACTCGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230968|gb|AY532120.1| Norovirus Bochum026/1997/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATAT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATTTGAACCCCTACCTTTCTCATTTGGCCA
+GAATGTACAATGGTTATGCAGGTGGTTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTTACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAATTGGAACCTGTGTTGATCCCCTTACCTGATGTTAGGAACA
+GTTTCTATCATTACAATCAATCAAATGATTCTACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGAGTCCTCACGAGGCCATCCCCCGATTTT
+GATTTCATATTCTTGGTGCCACCCACAGTTGAATCAAGAACTAAACCATTCACCGTCCCAATCTTAACTG
+TTGAGGAAATGTCCAATTCAAGATTCCCCATTCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGATGGCGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTTACCCACATTGCGGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGTATGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTTCAATACACCACTGACACAAACAGTG
+ATTTCCAAACTGGCCAAAACACGAAGTTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCAACAATGGGTACTCCCAAATTACTCAGGCGGAACTGGTCATAATGTGCACCTAGCTCCTGCC
+GTTGCCCCCACTTTTCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGATGTAGCGGGTATC
+CCAACATGAATTTGGATTGCTACTCCCCCCAGGAATGGGTGCAGCACTTCTACCAAGAAGCAGCTCCAGC
+ACAATCTGATGTGGCTCTGTTGAGATTCGTGAATCCAGATACAGGTAGGGTTCTGTTTGAGTGCAAGCTC
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGACTTGGTTATCCCCCCCAATGGTTACT
+TTAGATTTGATTCCTGGGTCAACCAGTTCTACACACTTGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230966|gb|AY532119.1| Norovirus Bochum024/1998/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAGTGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATGT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATTTGAACCCCTACCTTTCTCATTTGGCCA
+GAATGTACAACGGTTATGCAGGTGGTTTTGAAGTGCAGGTAATCCTCGCGGGGAATGCGTTCACCGCCGG
+GAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTTACTATG
+TTCCCCCACATAATAGTAGATGTTAGGCAACTGGAACCCGTGTTGATCCCCTTACCTGATGTTAGGAATA
+ATTTTTATCATTACAACCAATCAAATGATTCTACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACGGTCTCTTGTCGAGTCCTCACGAGGCCATCCCCCGATTTT
+GATTTTATATTCTTGGTGCCCCCCACAGTCGAATCAAGAACTAAACCATTCACCGTCCCAATCTTAACTG
+TTGAGGAAATGTCCAATTCAAGATTCCCCATTCCTTTGGAAAAGTTGTACACGGGTCCCAGTAGTGCATT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGACGGTGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTCACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGTATGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTTCAATACACCACTGACACAAACAGTG
+ATTTTCAAACTGGCCAAAACACGAAATTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCAGCAATGGGTGCTCCCAAATTATTCAGGTAGAACTGGTCATAATGTGCACCTAGCTCCTGCC
+GTTGCCCCCACTTTCCCGGGTGAGCAACTTCTTTTCTTCAGGTCCACTATGCCCGGATGTAGCGGGTATC
+CCAACATGAATCTGGATTGTCTGCTCCCCCAGGAATGGGTGCAGCACTTTTACCAAGAAGCGGCTCCAGC
+GCAATCTGATGTGGCTCTGTTGAGATTTGTGAATCCAGACACAGGTAGGGTTCTGTTTGAGTGCAAGCTC
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TTAGATTTGATTCCTGGGTCAACCAGTTCTATACACTTGCCCCCATGGGAAATGGAGCGGGGCGCAGACG
+TGCATTA
+
+>gi|47230964|gb|AY532118.1| Norovirus Dresden319/1997/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATAT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTGTCCCCTAGAAAT
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATCTGAACCCCTACCTTTCCCATTTGGCCA
+GAATGTACAATGGTTATGCAGGTGGTTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGGGCCCCAGCCAGGTCACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAATTGGAACCTGTGCTGATCCCTTTACCTGATGTTAGGAATA
+ATTTCTATCATTACAATCAATCAAATGATTCTACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGAGTCCTCACGAGGCCATCCCCCGACTTT
+GACTTCATATTCTTGGTGCCACCCACAGTTGAATCAAGAACTAAACCATTCACCGTCCCAATCTTAACTG
+TTGAGGAAATGTCCAATTCAAGATTCCCCGTTCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+CGTTGTCCAACCACAAAACGGCAGATGCACGACTGATGGCGTGCTCTTAGGCACCACCCAGCTGTCTGCA
+GTCAACATCTGCACCTTCAGAGGGGATGTCACCCACATTGCAGGCAGTCGTGATTACACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACCCCAGATTTCGT
+GGGAAAGATTCAAGGCGTGCTCACCCAAACCACAAGAGAGGACGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTTCAATACACTACTGACACAGACAATG
+ATTTTCAAACTGGCCAAAACACGAAATTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCAACAATGGGTGCTCCCAAACTACTCAGGTAGACCTGGTCATAATGTGCACTTAGCCCCTGCC
+GTTGCCCCCACTTTTCTGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGATGTAGCGGGTATC
+CCAATATGAATCTGGATTGCCTACTCCCCCAGGAATGGGTGCAGCACTTCTACCAAGAAGCAGCTCCAGC
+ACAATCTGATGTGGCTCTGCTGAGATTTGTGAATCCAGACACAGGTAGGGTTCTGTTTGAGTGCAAACTC
+CATAAGTCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTATT
+TTAGATTTGATTCTTGGGTCAATCAGTTTTACACGCTTGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230962|gb|AY532117.1| Norovirus Dresden267/1997/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATGT
+AATTGACCCCTGGATTAGAAATAATTTTGTACTGGGCCCCTGGGGAGAGTTTACAGTGTCCCCTAGAAAC
+GCTCCGGGTGAGATACTGTGGAGCGCGCCCTTGGGCCCTGATTTGAACCCTTACCTTTCTCATTTGGCCA
+GAATGTACAATGGTTACGCAGGTGGCTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTTACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAATTGGAACCTGTGTTGATCCCCTTACCTGATGTTAGGAACA
+ATTTCTATCATTACAATCAGTCAAATGATTCTACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGAGTCCTCACGAGGCCATCCCCCGATTTT
+GATTTCATATTCTTGGTGCCACCCACAGTTGAATCAAGAACTAAACCATTCACCGTCCCAATCTTAACTG
+TTGAGGAAATGTCTAATTCAAGATTCCCCATTCCTTTGGAAAAGTTATACACGGGTCCCAGCAGTGCTTT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGATGGCGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTCACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGCGTGCTCACCCAAACTACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTTCAATACACCACTGACACAAGCAATG
+ATTTTCAAACTGGCCAAAACACGAAATTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCAACAATGGGTACTCCCAAATTACTCAGGCAGAACTGGTCATAATGTGCACCTAGCTCCTGCC
+GTTGCCCCCACTTTTCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGATGTAGCGGGTATC
+CCAACATGAATCTGGATTGCCTACTCCCCCAGGAATGGGTGCAGCACTTCTACCAAGAAGCAGCTCCAGC
+GCAATCTGATGTGGCTCTGCTGAGATTTGTGAATCCAGATACAGGTAGGGTTCTGTTTGAGTGTAAGCTC
+CATAAATCAGGTTATGTCACAGTGGCTCACACTGGCCCGTATGATTTGGTTATCCCCCCCAATGGTTACT
+TTAGATTTGATTCCTGGGTCAACCAGTTCTACACACTTGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230960|gb|AY532116.1| Norovirus Dresden245/1997/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGACACCTGTAGCGGGCCAACAAAATGT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATTTGAACCCCTACCTTTCTCATTTGGCCA
+GAATGTACAATGGTTATGCAGGTGGTTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTTACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAATTGGAACCTGTGTTGATTCCCTTACCTGATGTTAGGAATA
+ACTTTTACCATTATAATCAATCAAATGATTCTACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGGGTCCTCACGAGACCATCCCCCGATTTT
+GATTTCATATTCTTGGTGCCACCCACAGTTGAATCAAGAACTAAACCATTCACCGTCCCAATCTTGACTG
+TTGAGGAAATGTCCAATTCAAGATTCCCCATTCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+TGTTGTCCAACCACAAAATGGCAGATGCACGACTGATGGCGTGCTCCTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACTTTCAGAGGGGATGTCACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGCATGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTTCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGCCAAAACACGAAGTTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCAACAATGGGTACTCCCAAATTACTCAGGCAGGACTGGACATAATGTGCACCTAGCTCCTGCC
+GTTGCCCCCACTTTCCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACCATGCCCGGATGCAGCGGGTATC
+CCAACATGAATCTGGATTGCCTACTCCCCCAGGAATGGGTGCAGCACTTCTACCAAGAGGCAGCTCCAGC
+ACAATCTGATGTGGCTCTACTGAGATTTGTGAACCCAGATACAGGTAGGGTTCTGTTTGAGTGTAAGCTC
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TTAGATTTGATTCCTGGGTCAACCAGTTCTACACACTCGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230958|gb|AY532115.1| Norovirus Dresden153/1997/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATGT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTGTCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATTTGAACCCCTACCTTTCCCATTTGGCCA
+GAATGTACAATGGTTATGCAGGTGGTTTTGATGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTCACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAATTGGAACCTGTGTTGATCCCCTTACCTGATGTTAGGAACA
+ATTTTTACCATTACAATCAATCAAATGATTCTACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCCAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGAGTCCTCACGAGGCCATCCCCCGATTTT
+GATTTCATATTCTTGGTGCCACCCACAGTTGAATCAAGAACTAAACCATTCACCGTCCCAATCTTAACTG
+TTGAGGAAATGTCCAATTCAAGATTCCCCATTCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGATGGTGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTCACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGCATGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTCCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGCCAAAACACGAAATTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCAACAATGGGTGCTCCCAAATTACTCAGGTAGAACTGGTCATAATGTGCACCTAGCCCCTGCC
+GTTGCCCCCACTTTCCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGATGTAGCGGGTATC
+CCAACATGAATCTGGATTGCCTACTCCCCCAGGAATGGGTGCAGCACTTCTACCAAGAAGCAGCTCCAGC
+ACAATCTGATGTGGCTCTGCTGAGATTTGTGAATCCAGACACAGGTAGGGTTCTGTTTGAGTGCAAGCTC
+CATAAATCAGGCTATGTCACAGTGGCTCATACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TTAGATTTGATTCTTGGGTCAACCAGTTTTACACACTTGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230956|gb|AY532114.1| Norovirus Erlangen195/1997/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATGT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAATTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATTTGAACCCCTACCTTTCTCATTTGGCCA
+GAATGTACAATGGCTATGCAGGTGGTTTTGAAGTGCAGGTAATTCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTTACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAATTGGAACCTGTGTTGATCCCCTTACCTGATGTTAGGAATA
+ATTTCTACCATTATAATCAATCAAATGATTCTACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGAGTCCTCACGAGGCCATCCCCCGATTTT
+GATTTCATATTCTTGGTGCCACCCACAGTTGAATCAAGAACTAAACCATTCACCGTCCCAATCTTAACTG
+TTGAGGAAATGTCCAATTCAAGATTCCCCATTCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGATGGCGTGCTCCTAGGCACCACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTCACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGCATGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTTCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGCCAAAACACGAAATTCACCCCAGTCGGCGTCATCCAGGATGGTAATAACCATCAAAA
+TGAACCCCACCAATGGGTACTCCCAAATTACTCAGGTAGAACTGGTCACAATGTGCACCTAGCTCCTGCC
+GTTGCCCCCACTTTTCCGGGTGAGCAGCTTCTTTTCTTTAGATCCACTATGCCCGGATGTAGCGGGTATC
+CCAACATGAATCTGGATTGCCTACTCCCCCAGGAATGGGTGCAGCACTTCTACCAAGAAGCAGCTCCAGC
+ACAATCCGATGTGGCTCTGCTGAGATTTGTGAATCCAGATACAGGTAGGGTTCTGTTTGAGTGCAAGCTC
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGACTTGGTTATCCCCCCCAATGGTTACT
+TTAGATTTGATTCCTGGGTCAACCAGTTCTACACACTTGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230954|gb|AY532113.1| Norovirus Freiburg253/1998/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATAT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGTCCTGATTTGAACCCCTACCTTTCTCATTTGGCCA
+GAATGTACAATGGTTATGCAGGTGGTTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTTACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAATTGGAACCTGTGTTGATCCCCTTACCTGATGTTAGGAACA
+ATTTCTATCATTACAATCAGTCAAATGATTCTACCATTAAATTGATAGCAATGCTGTATACACCACTCAG
+GGCTAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGAGTCCTCACGAGGCCATCCCCCGATTTT
+GATTTCATATTCTTGGTGCCACCCACAGTTGAATCAAGAACTAAACCATTCACCGTCCCAATCTTAACTG
+TTGAGGAAATGTCCAATTCAAGATTCCCCATTCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGATGGCGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTTACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTTGT
+GGGAAAGATCCAAGGTATGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTTCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGCCAAAACACGAAGTTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCACCAATGGGTACTCCCAAATTACTCAGGCAGAACTGGTCATAATGTGCACCTAGCTCCTGCC
+GTTGCCCCCACTTTTCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGATGTAGCGGGTATC
+CCAACATGAATCTGGATTGCCTACTCCCCCAGGAATGGGTGCAGCACTTCTACCAAGAAGCGGCTCCAGC
+ACAATCTGATGTGGCCCTGCTGAGATTCGTGAATCCAGATACAGGTAGGGTTCTGTTTGAGTGCAAGCTC
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TTAGATTTGATTCCTGGGTCAACCAGTTCTACACACTTGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230952|gb|AY532112.1| Norovirus Freiburg024/1997/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATAT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGGGCCCTGATTTGAACCCCTACCTTTCTCATTTGGCCA
+GAATGTACAATGGTTATGCAGGTGGTTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCCGG
+GAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTTACTATG
+TTCCCCCATATAATAGTAGATGTTAGGCAATTGGAACCTGTGTTGATCCCCTTACCTGATGTTAGGAACA
+ATTTCTATCATTACAATCAATCAAATGATTCTACCATTAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGAGTCCTCACGAGGCCATCCCCCGATTTT
+GATTTCATATTCTTGGTGCCACCCACAGTTGAATCAAGAACTAAACCATTCACCGCCCCAATCTTAACTG
+TTGAGGAAATGTCCAATTCAAGATTCCCCATTCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGATGGCGTGCTCTTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTTACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGTATGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTTCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGCCAAAACACGAAGTTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCAACAATGGGTACTCCCAAATTACTCAGGCAGAACTGGTCATAATGTGCACCTAGCTCCTGCC
+GTTGCCCCCACTTTTCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGATGTAGCGGGTATC
+CCAACATGAATCTGGATTGCCTACTCCCCCAGGAATGGGTGCAGCACTTCTACCAAGAAGCAGCTCCAGC
+ACAATCTGATGTGGCTCTGCTGAGATTCGTGAATCCAGATACAGGTAGGGTTCTGTTTGAGTGCAAGCTC
+CATAAATCAGGCTATGTCACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TTAGATTTGATTCCTGGGTCAACCAGTTCTACACACTTGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
+>gi|47230950|gb|AY532111.1| Norovirus Freiburg057/1997/GE capsid protein gene, partial cds
+ATGAAGATGGCGTCGAATGACGCCAACCCATCTGATGGGTCCACAGCCAACCTCGTCCCAGAGGTCAACA
+ATGAGGTTATGGCTTTGGAGCCCGTTGTTGGTGCCGCTATTGCGGCACCTGTAGCGGGCCAACAAAATGT
+AATTGACCCCTGGATTAGAAATAATTTTGTACAAGCCCCTGGTGGAGAGTTTACAGTATCCCCTAGAAAC
+GCTCCGGGTGAGATACTATGGAGCGCGCCCTTGAGCCCTGATTTGAACCCCTACCTTTCTCATTTGGCCA
+GAATGTACAATGGTTATGCAGGTGGTTTTGAAGTGCAGGTAATCCTCGCGGGGAACGCGTTCACCGCGGG
+GAAAATCATATTTGCAGCAGTCCCACCAAATTTTCCAACTGAAGGCTTGAGCCCCAGCCAGGTTACTATG
+TTTCCCCATATAATAGTAGATGTTAGGCAATTGGAACCTGTGTTGATTCCCTTACCTGATGTTAGGAACA
+ATTTCTACCATTACAATCAATCAAATGATTCTACCATCAAATTGATAGCAATGCTGTATACACCACTTAG
+GGCTAATAATGCTGGGGATGATGTCTTCACAGTCTCTTGTCGAGTCCTCACGAGGCCATCCCCCGATTTT
+GATTTCATATTCTTGGTGCCACCCACAGTTGAATCAAGAACTAAACCATTCACCGTCCCAATCTTAACTG
+TTGAGGAAATGTCCAATTCAAGATTCCCCATTCCTTTGGAAAAGTTGTACACGGGTCCCAGCAGTGCTTT
+TGTTGTCCAACCACAAAATGGCAGGTGCACGACTGATGGCGTGCTCCTAGGCACTACCCAGCTGTCTGCT
+GTCAACATCTGCACCTTCAGAGGGGATGTCACCCACATTGCAGGCAGTCATGATTATACAATGAATTTGG
+CTTCTCAAAATTGGAACAATTATGACCCAACAGAAGAAATCCCAGCCCCTCTGGGAACTCCAGATTTCGT
+GGGAAAGATCCAAGGCATGCTCACCCAAACCACAAGAGAGGATGGCTCGACCCGCGCCCACAAAGCTACA
+GTGAGCACTGGGAGTGTCCACTTTACTCCAAAGCTGGGCAGTGTTCAATACACCACTGACACAAACAATG
+ATTTTCAAACTGGCCAAAACACGAAGTTCACCCCAGTCGGCGTCATCCAGGACGGTAATAACCATCAAAA
+TGAACCCCAACAATGGGTACTCCCAAATTACTCAGGCAGAACTGGTCATAATGTGCACCTAGCTCCTGCC
+GTTGCCCCCACTTTTCCGGGTGAGCAACTTCTTTTCTTTAGGTCCACTATGCCCGGATGTAGCGGGTATC
+CCAACATGAATCTGGATTGCCTACTCCCCCAGGAATGGGTACAGCACTTCTACCAAGAAGCAGCTCCAGC
+ACAATCTGATGTGGCTCTGCTAAGATTTGTGAATCCAGATACAGGTAGGGTTCTGTTTGAGTGTAAGCTC
+CATAAATCAGGCTATGTTACAGTGGCTCACACTGGCCCGCATGATTTGGTTATCCCCCCCAATGGTTACT
+TTAGATTTGATTCCTGGGTCAACCAGGTTTACACACTTGCCCCCATGGGAAATGGAGCGGGGCGTAGACG
+TGCATTA
+
diff --git a/rana.fasta b/rana.fasta
new file mode 100644
index 0000000..b0b0d82
--- /dev/null
+++ b/rana.fasta
@@ -0,0 +1,152 @@
+>gi|6561846|gb|AF205094.1|AF205094 Rana amurensis cytochrome b (cytb) gene, complete cds; mitochondrial gene for mitochondrial product
+ATGACGCCCACAATACGTAAATTCCACCCCCTCCTCAAATTTATTAACTACTCATTTATCGATCTCCCAA
+CCCCCTCTAATATCTCTGCCTCATGAAACTTCGGGTCACTTCTAGGCTTATGTTTAATTGCCCAAATCGC
+CACCGGACTATTCCTAGCCATACATTATACAGCTGATACTTCTTTAGCATTTTCTTCTATTGCTCACATC
+TGTCGAGATGTCAATAATGGATGACTTCTTCGCAACCTTCACGCAAACGGCGCATCATTCTTTTTTATCT
+GCATCTACTTCCATATTGGACGGGGTCTTTATTATGGCTCCTACCTTTACAAAGAAACGTGAAACATTGG
+AGTTATTCTATTATTTCTACTGATAGCCACAGCCTTCGTCGGGTACGTTCTCCCATGAGGTCAAATATCA
+TTTTGGGGCGCCACAGTAATTACTAACCTTCTTTCAGCCGCCCCCTACATCGGCTCTAACCTTGTCCAAT
+GGATCTGAGGAGGCTTCTCAGTAGACAACGCTACCCTCACCCGATTTTTTACATTTCACTTCATTCTCCC
+ATTTATTATTACCGCTGTTAGTCTAATTCACCTCCTATTTTTACATCAAACAGGATCATCTAACCCCACA
+GGACTAAACTCCAACTTAGACAAAGTCTCTTTTCACCCTTACTTCTCCTACAAGGACCTCCTCGGGTTTG
+TTATTATGTTAGGCGCCCTAGCCTCTCTCTCCACCTTCGCCCCTAACCTACTTGGAGACCCAGACAATTT
+TACACCAGCTAACCCACTCGTTACACCCCCTCACATTAAGCCAGAATGGTATTTGCTTTTCGCCTACGCC
+ATCCTTCGCTCAATCCCAAACAAATTAGGAGGTGTCCTGGCCGTCGTTCTCTCAATTATAGTCCTCTTCC
+TGATGCCTATTATTCACACATCTAAACTGCGCTCCCTTATGTTTCGCCCAATCGCAAAAACCTTCTTCTG
+AGCACTAATTGCCAATACAGCTATTCTCACATGGATCGGAGGACAACCAGTTGAGGATCCCTTTATTACA
+ATTGGTCAAATCGCCTCCGGACTCTACTTTCTTATCTTTGTCCTTCTTATCCCATCACTAGGACTCCTGG
+AAAACAAGCTCCTAAAAATTTAA
+
+>gi|6561844|gb|AF205093.1|AF205093 Rana rugosa from Yongdok South Korea cytochrome b (cytb) gene, complete cds; mitochondrial gene for mitochondrial product
+ATGGCCCCAACAATCCGAAAATCTCACCCCCTCCTGAAAATCATCAACGTCTCCTTCATTGACCTCCCAA
+CCCCAACTAACATCTCCTCTTGATGAAATTTTGGCTCACTGCTACCAGTATGCCTAATTGCCCAAATCGC
+TACCGGCCTATTTTTAGCTATGCACTATACAGCTGACACTTCCCTCGCATTCTCATCAGTTGCTCACATT
+TGTCGAGACGTCAACAACGGCTGATTACTCCGCAATCTCCATGCCAACGGTGCCTCTTTCTTTTTTATCT
+GCATCTACTTCCACATCGGACGAGGACTTTACTATGGCTCCTACCTTTACAAAGAAACATGAAATATCGG
+AGTAATCCTCCTTCTTCTAGTTATAGCCACAGCCTTTGTAGGCTACGTTCTCCCCTGGGGCCAAATATCA
+TTCTGAGGGGCCACTGTTATCACAAACCTCCTCTCAGCTGCCCCCTACATTGGCTCCGACCTCGTCCAAT
+GAATCTGAGGCGGATTTTCCGTAGACAACGCCACTCTTACCCGATTCTTCACATTCGACTTTATCCTCCT
+ATTTATTATTGCAGCCACAAGCCTAATCCACCTGTTATTCCTCCACCAAACTGGATCCTCCAACCCAACG
+GGCCTAAACTCCAACCTAGATAAAGTCTCCTTCCACCCTTACTTTTCCTTCAAGGACCTCTTAGGCTTTA
+TTATTTTACTAGGAGCCCTCGCAATCTTATCAACCTTCGCACCAAACCTCCTAGGTGACCCAGACAACTT
+TACACCTGCAACCCCGCTCTCCACCCCTCCACATATTAAGCCGGAGTGGTATTTGCTATTTGCCTACGCC
+ATTCTCCGCTCAATTCTAAATAAACTAGGAGGAGTCCTTGCCCTACTACTCTCAATTATAGTTCTCTTCC
+TTATACCTATTACCCACACCTCTAAACTACGCTCATTAATATTCCGCCCTACCGCTAAAGCTTTCTTCTG
+AGCACTCATTGCCAACACGATTATCCTAACCTGAATTGGAGGCCAACCAGTTGAAGACCCGTTTATTTCA
+ATCGGCCAAATTGCCTCCGGACTGTACTTTTTAATCTTCGTCCTTATTATCCCCACACTAGGCCTCCTTG
+AGAACAAACTTCTTAAAATCTAG
+
+>gi|6561842|gb|AF205092.1|AF205092 Rana rugosa from Nonsan South Korea cytochrome b (cytb) gene, complete cds; mitochondrial gene for mitochondrial product
+ATGGCACCTACAATACGTAAATCTCACCCCCTCCTGAAAATCATCAACGTCTCCTTCATTGACCTCCCAA
+CCCCAACTAACATCTCCTCTTGATGAAACTTCGGCTCACTACTAGGAGTATGCCTAATTGCCCAAATCGC
+TACCGGCCTATTTCTAGCCATACACTACACAGCTGACACTTCCCTCGCATTCTCATCAGTCGCTCATATT
+TGTCGAGACGTCAACAACGGCTGATTACTCCGCAACCTCCATGCCAACGGCGCCTCTTTCTTTTTTATCT
+GCATCTATTTCCACATCGGACGAGGACTTTACTACGGCTCCTACCTTTACAAAGAAACATGAAATATCGG
+AGTGATCCTCCTACTCCTAGTCATAGCCACAGCCTTTGTTGGCTACGTTCTCCCCTGAGGCCAAATATCG
+TTCTGAGGGGCCACTGTCATCACGAACCTCCTCTCAGCTGCCCCCTATATTGGTTCTGACCTCGTCCAAT
+GGATCTGAGGCGGATTTTCCGTAGACAACGCCACCCTCACCCGATTCTTCACATTCCACTTTATCCTCCC
+CTTTATTATTGCAGCCACAAGCCTAATCCACCTACTGTTCCTCCACCAAACTGGATCCTCCAACCCAACG
+GGCCTAAATTCTAACTTAGACAAAGTCTCTTTTCACCCCTACTTCTCATACAAGGACCTCCTCGGATTTG
+TTATTATGTTAGGTGCCCTAGCCTCTCTCTCCACCTTCGCCCCTAACCTGCTTGGGGACCCAGACAATTT
+TACACCAGCTAACCCACTCGTCACACCCCCACACATTAAGCCGGAGTGGTATTTCCTTTTCGCCTACGCC
+ATCCTTCGCTCAATCCCAAACAAACTAGGAGGAGTCCTTGCCCTACTACTCTCAATTATAGTTCTCTTCC
+TTATACCTATTATTCACACCTCTAAACTACGCTCATTAATATTCCGCCCTACCGCTAAAGCTTTCTTCTG
+AGCACTCATTGCCAACACGATTATCCTAACCTGAATTGGAGGCCAACCAGTTGAAGACCCGTTTATTTCA
+ATCGGCCAAATTGCCTCCGGACTGTACTTTTTAATCTTCGTCCTTATTATCCCCACACTAGGCCTCCTTG
+AGAACAAACTTCTTAAAATCTAG
+
+>gi|6561840|gb|AF205091.1|AF205091 Rana dybowskii from Tonghae South Korea cytochrome b (cytb) gene, complete cds; mitochondrial gene for mitochondrial product
+ATGGCACCTACAATACGTAAATCTCACCCCCTCCTTAAGATTATTAACGGCTCATTCATTGACCTCCCGA
+CCCCAGCCAACATCTCTGCATGATGAAACTTTGGGTGACTCTTAGGGGTGTGTGTAATTGTCCAAATCGC
+CACCGGATTATTTTTAGCTATACACTACACGGCCGATACTTCCCTAGCATTCTCATCTATCGCCCATATC
+TGCCGGGATGTAAACAACGGCTGACTACTTCGTAACCTTCACGCCAACGGTGCATCATTTTTCTTCATTT
+GTATTTACTTCCACATCGGACGGGGCCTTTATTATGGCTCCTACCTATACAAAGAGACGTGAAACATCGG
+AGTAATCCTCCTATTTTTGGTGATAGCTACAGCTTTTGTCGGCTATGTGTTACCATGAGGCCAAATATCC
+TTCTGAGGTGCTACAGTCATTACTAACCTCCTCTCGGCCGCCCCTTACATCGGGCCTGATTTGGTCCAAT
+GAATCTGAGGGGGCTTCTCCGTAGACAACGCTACTCTCACCCGATTCTTTACATTCCACTTTATTCTTCC
+GTTTATTATCGCAGCTATAAGTATAATCCATCTCCTGTTTCTCCACCAAACAGGCTCATCCAACCCCACA
+GGACTAAACTCCAACCTAGACAAAGTCTCCTTCCACCCTTACTTTTCCTTCAAGGACCTCCTAGGGTTTA
+TTATTTTACTAGGCGCCCTAGCAATCTTATCAACCTTCGCACCAAACCTACTTGGTGACCCAGACAACTT
+TACACCAGCAAACCCACTCGTTACACCCCCTCACATTAAGCCAGAATGGTATTTCCTTTTCGCCTACGCC
+ATCCTTCGCTCAATCCCAAACAAACTAGGAGGTGTCCTGGCCCTCCTTCTTTCAATTATAGTCCTCTTCC
+TAATGCCTATTATTCACACATCTAAACTGCGTTCCCTAATATTCCGCCCCGCTGCGAAAGCTTTCTTCTG
+AGCGCTCATTGCCAACACGATTATCCTAACCTGAATTGGGGGCCAACCAGTTGAAGACCCATTTATTTCA
+ATTGGCCAAATTGCCTCCGGACTGTACTTTTTAATCTTTGTCCTTATTATTCCCACACTTGGCCTCCTTG
+AGAACAAACTTCTTAAAATCTAG
+
+>gi|6561838|gb|AF205090.1|AF205090 Rana dybowskii from Nonsan South Korea cytochrome b (cytb) gene, complete cds; mitochondrial gene for mitochondrial product
+ATGGCACCTACAATACGTAAATCTCACCCCCTCCTTAAAATCATCAATGGCTCATTCATTGACCTCCCTA
+CCCCCTCCAATATTTCAGCCTGATGAAATTTTGGGTCACTCCTAGGCGTATGTCTTATTGCTCAAATTGC
+CACTGGCCTATTTCTAGCCATGCACTACACAGCTGACACTTCCCTAGCGTTTTCATCTATCGCTCACATC
+TCCCGAGACGTAAACAATGGCTGACTTCTTCGCAACCTTCACGCCAATGGCGCATCATTCTTCTTCATCT
+GCATCTATCTCCATATCGGACGGGGTCTTTATTATGGCTCCTACCTCTATAAAGAGACGTGAAACATTGG
+GGTGATCCTCCTGTTTTTAGTAATAGCTACAGCTTTTGTAGGCTATGTTTTACCATGAGGCCAAATGTCT
+TTCTGAGGCGCTACAGTAATTACTAACCTCCTCTCAGCTGCTCCCTACATCGGCTTTGACTTAGTCCAAT
+GAATCTGAGGCGGCTTCTCGGTAGACAATGCTACCCTCACCCGATTCTTTACATTCCACTTCATCCTCCC
+GTTCATTATCGCAGCTCTAAGTATAATTCACCTTCTATTCCTCCACCAAACAGGCTCATCCAACCCCACA
+GGCCTAAACTCCAATTTAGACAAAGTCTCTTTTCACCCTTACTTCTCCTACAAAGACCTCCTCGGGTTTG
+TTATTATGTTGGGCGCCCTAGCCTCTCTCTCCACCTTCGCCCCTAACCTACTTGGAGACCCAGACAATTT
+TACACCAGCAAACCCACTCGTTACACCCCCTCACATTAAGCCAGAATGGTATTTCCTTTTCGCCTACGCC
+ATCCTTCGCTCAATCCCAAACAAATTAGGAGGTGTCCTGGCCCTCCTTCTTTCAATTATAGTCCTCTTCC
+TAATGCCTATTACCCACCCATCTAAACTGCGCTCCCTTATGTTTCGTCCCATCGCAAAAACCTTCTTCTG
+GGCACTAATTGCCAACACAGCCATTGTCACATGGATTGGAGGACAATCGGTTGAAGACCCCTTTATTACC
+ATTGGTCAAATCGCCTCCGGACTCTACTTTCTTATCTTTGTCCTTCTTATTCCATCACTAGGACTCCTGG
+AAAACAAGCTCCTAAAAATTTAA
+
+>gi|6561836|gb|AF205089.1|AF205089 Rana catesbeiana cytochrome b (cytb) gene, complete cds; mitochondrial gene for mitochondrial product
+ATGGCACCCACAATACGAAAATCTCACCCCCTTCTTAAAATTATTAACGGCTCATTTATTGACCTCCCCT
+CCCCCGCCAACCTCTGAGCCTGATGAAACTTTGGCTCACTCCTCGGAGTTTGCCTTGTTGCCCAAATCGT
+CACTGGCTTATTCCTAGCCATACACTATACAGCTGACACTTCCCTTGCATTCTCATCTATTGCTCACATC
+TGCCGTGATGTTAATAACGGCTGACTCCTACGAAATCTCCATGCCAACGGAGCATCATTCTTTTTTATCT
+GTATTTATTTTCACATCGGCCGAGGGCTCTACTACGGCTCCTACCTTTATAAAGAAACATGAAATATCGG
+TGTAATTCTACTGTTTTTAGTAATAGCTACAGCTTTTGTAGGTTACGTTCTACCATGGGGCCAAATATCA
+TTCTGAGGCGCCACAGTAATTACTAACCTTCTCTCAGCCGCCCCATACATCGGTTCTGACCTTGTTCAAT
+GAATTTGAGGGGGTTTTTCAGTAGACAACGCCACCCTCACCCGATTCTTTACTTTTCACTTCATCCTCCC
+GTTTATTATCGCAGCAGCAAGTATGATCCACCTGCTTTTCCTCCATCAAACTGGCTCATCCAACCCAACA
+GGACTAAATTCTAACTTAGACAAAGTCTCTTTTCACCCTTACTTCTCCTACAAAGACCTCTTCGGGTTTG
+TTATTATGCTGGGCGCCCTGGCCTCTCTCTCCACCTTCGCCCCTAACCTGCTTGGAGACCCAGACAATTT
+TACACCAGCAAACCCACTCGTTACACCCCCTCACATTAAGCCAGAATGGTATTTCCTTTTCGCCTACGCC
+ATCCTTCGCTCAATTCCAAACAAATTAGGAGGTGTCCTGGCCCTCCTTCTCTCAATTATAGTCCTCTTCC
+GGATGCCTATTATTCACACATCTAAACTGCGCTCCCTTATATTTCGCCCCATCGCAAAAACCTTCTTCTG
+AGCACTAATTGCCAATACAGCTATTCTCACATGGATCGGAGGACAACCAGGCGAGGACCCCTTTATCACC
+ATTGGTCAAATCGCCTCCGGACTCTACTTTCTTATCTTTGTCCTTCTTATCCCATCACTAGGACTCCTGG
+AAAATAAGCTCCTAAAAATTTAA
+
+>gi|6561834|gb|AF205088.1|AF205088 Rana plancyi cytochrome b (cytb) gene, complete cds; mitochondrial gene for mitochondrial product
+ATGGCCCCCACAATCCGAAAATCTCACCCCCTTCTCAAAATCATCAATGGCTCCTTCATTGACCTTCCTT
+CCCCAGCCAACATCTCTGCATGATGAAACTTCGGCTCACTACTCGGAGTGTGCTTAATTGCCCAAATCGC
+CACCGGCTTATTCCTAGCCATGCATCATACAGCCGATACATCCCTTGCGTTCTCATCTATTGCTCACATC
+TGCCGAGATGTCAATAACGGCTGACTCCTACGAAACCTTCACGCCAACGGCGCATCTTTTTTCTTTATCT
+GCATCTACTTCCACATTGGCCGGGGTCTTTACTATGGCTCCTACCTCTACAAAGAAACCTGAAACATTGG
+CGTCATCCTGTTGTTCCTAGTCATAGCCACCGCCTTTGTAGGCTATGTCCTCCCTTGAGGACAAATATCT
+TTCTGAGGCGCCACAGTCATTACCAATCTCCTATCAGCCGCCCCCTACATCGGCCCAGACCTAGTTCAAT
+GAATCTGAGGAGGCTTCTCAGTAGACAACGCTACCCTCACCCGTTTCTTTACATTTCACTTCATTCTCCC
+CTTTATTATTGCAGCAGCAAGTATGATTAACCTACTCTTTCTTCACCAAACTGGGTCCTCTAACCCAACA
+GGACTAAATTCTAACTTAGACAAAGTCTCTTTTCACCCCTACTTCTCATACAAGGACCTCCTCGGATTTG
+TTATTATGTTAGGTGCCCTAGCCTCTCTCTCCACCTTCGCCCCTAACCTGCTTGGGGACCCAGACAATTT
+TACACCAGCTAACCCACTCGTCACACCCCCTCACATTAAGCCAGAATGATACTTCCTTTTCGCCTACGCC
+ATCCTTCGCTCAATCCCAAACAAATTAGGAGGTGTCCTGGCCCTCCTTCTCTCAATCATAATCCTCTTTC
+TGATGCCTATTATTCACACATCTAAACTGCGCTCCCTTATATTTCGCCCAATCGCAAAAACCTTCTTCTG
+AGCACTAATTGCCAATACAGCCATTCTCACATGGATCGGAGGACAACCAGTTGAGGATCCCTTTATTACC
+ATTGGTCAAATCGCCTCCGGACTCTACTTTCTTATCTTTGTCCTTCTTATCCCATCACTAGGACTCCTGG
+AAAACAAGCTCCTAAAAATTTAA
+
+>gi|6561832|gb|AF205087.1|AF205087 Rana nigromaculata cytochrome b (cytb) gene, complete cds; mitochondrial gene for mitochondrial product
+ATGGCCCCAACAATCCGAAAATCTCACCCCCTTCTCAAAATCATCAACGGCTCCTTCATTGACCTCCCGA
+CCCCAGCCAACATCTCTGCATGATGAAACTTCGGCTCCCTCCTCGGAGTGTGCTTAATTGCCCAAATCGC
+CACCGGCTTATTCCTAGCCATGCATTACACAGCCGATACATCCCTTGCGTTCTCATCTGTCGCTCACATC
+TGCCGAGACGTTAACAACGGCTGACTCCTACGTAACCTCCATGCTAACGGCGCATCTTTTTTCTTTATCT
+GCATCTACTTCCACATTGGCCGAGGTCTTTACTATGGCTCCTACCTCTATAAAGAAACCTGAAACATTGG
+CGTCATTCTATTGTTCCTAGTTATAGCCACCGCCTTTGTAGGCTATGTTCTCCCTTGAGGCCAAATATCC
+TTCTGAGGCGCCACAGTCATCACTAACCTCCTATCAGCTGCCCCCTACATCGGCCCAGACCTAGTTCAAT
+GAATCTGAGGAGGCTTCTCAGTAGATAACTCCACCCTCACCCGTTTCTTTACATTTCACTTCATTCTCCC
+CTTTATTATTGCAGCAGCAAGCATAATCCACCTCCTGTTTCTTCACCAAACCGGATCCTCTAACCCAACA
+GGACTAAACTCCAATCTAGACAAAGTCTCTTTTCACCCTTACTTCTCCTACAAAGACCTCCTCGGGTTTG
+TTATTATGTTGGGCGCCCTGGCCTCTCTCTCTACCTTCGCCCCTAACCTACTTGGAGACCCAGACAATTT
+TACACCAGCAAACCCACTCGTTACACCCCCTCACATTAAGCCAGAATGGTATTTCCTTTTCGCCTACGCC
+ATCCTTCGCTCAATCCCAAACAAACTAGGAGGTGTCCTGGCCCTCCTTCTTTCAATTATAGTCCTCTTCC
+TAATGCCCATTATTCACACATCTAAACTGCGCTCCCTAATGTTTCGTCCCATCGCAAAAACCTTCTTCTG
+GGCCCTAATTGCCAACACAGCTATTCTCACATGAATCGGCGGTCAACCAGTTGAAGACCCCTTTATCACC
+ATCGGTCAAATCGCCTCCGGACTTTACTTTCTTATCTTTGTCCTTCTTATTCCATCACTAGGACTCCTGG
+AAAATAAGCTCCTAAAAATTTAA
+
diff --git a/src/Makefile b/src/Makefile
new file mode 100755
index 0000000..d3343bd
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,35 @@
+# compiler
+#CXX = /opt/ibmcmp/vac/6.0/bin/xlc
+CXX = gcc
+CXXFLAGS = -O3 -Wall
+
+# target macros
+PhiOBJ = normal.o stats.o maxChi.o main.o queue.o graphCode.o fasta.o phylip.o mem.o misc.o pairScore.o seqManip.o global.o
+ProfOBJ = normal.o stats.o fasta.o phylip.o mem.o misc.o pairScore.o seqManip.o global.o profile.o
+
+# targets
+default : Phi Profile
+
+# implicit construction rule
+%.o : %.c
+ $(CXX) -c $(CXXFLAGS) $< -o $@
+
+
+Phi: $(PhiOBJ)
+ $(CXX) $(CXXFLAGS) -o Phi $(PhiOBJ) -lm
+ cp Phi ../
+ cd ppma_2_bmp && ${MAKE}
+ cp ppma_2_bmp/ppma_2_bmp ../
+
+
+Profile: $(ProfOBJ)
+ $(CXX) $(CXXFLAGS) -o Profile $(ProfOBJ) -lm $(MYLIB)
+ cp Profile ../
+clean : FORCE
+ rm -f *.o
+ rm -f Phi
+ rm -f Profile
+FORCE:
+
+
+
diff --git a/src/fasta.c b/src/fasta.c
new file mode 100644
index 0000000..1bf58bc
--- /dev/null
+++ b/src/fasta.c
@@ -0,0 +1,250 @@
+
+/*
+ Copyright (c)2005, Trevor Bruen
+ All rights reserved.
+
+ Any feedback is very welcome.
+ email: trevor at mcb.mcgill.ca
+*/
+
+#include "global.h"
+#include "mem.h"
+#include "fasta.h"
+#include "misc.h"
+
+
+/* Read fasta sequence name. in_file should point to beginning of line */
+/* Format:
+ >TAXA_NAME COMMENT
+*/
+void read_sequence_name(FILE *in_file,char *name, int capacity)
+{
+ int i=0;
+ char ch='\0';
+
+ ch=fgetc(in_file);
+ if(ch != '>')
+ error("Sequence name should begin with >\n");
+
+ ch=fgetc(in_file);
+
+
+ while((i<capacity) && (ch!=EOF) && (ch!= '\n'))
+ {
+ name[i++]=ch;
+ ch=fgetc(in_file);
+ }
+
+ if(ch == '\n')
+ ungetc(ch,in_file);
+ if(i==capacity)
+ error("Taxa names too large for this routine\n");
+
+ if(ch==EOF)
+ error("Taxa name appears to be cut off\n");
+
+ /* Insert many null chars to be safe */
+ for(;i<=capacity;i++)
+ name[i]='\0';
+ // fprintf(stdout,"Read %s\n",name);
+ //fflush(stdout);
+}
+
+
+void write_fasta(FILE* cur_stream, char **taxa_names,align_type **alignment, int num_taxa,int num_sites)
+{
+ int i;
+ int j;
+
+ for(i=0;i<num_taxa;i++)
+ {
+ fprintf(cur_stream,">%s \n",taxa_names[i]);
+
+ for(j=0;j<num_sites;j++)
+ {
+/* if((int)alignment[i][j] <=MAX_STATE ) */
+ fprintf(cur_stream,"%c",((char)(alignment[i][j] + CHAR_START)));
+/* else if((int)alignment[i][j] == MISSING_STATE) */
+/* fprintf(cur_stream,"%c",MISSING); */
+/* else if((int)alignment[i][j]== GAP_STATE) */
+/* fprintf(cur_stream,"%c",GAP); */
+
+ }
+ fprintf(cur_stream,"\n");
+ }
+
+
+}
+
+
+char read_seq_part(FILE *in_file, int base_limit, align_type*** alignment, int index, int *num_bases)
+{
+ int bases_read=0;
+ int new_limit;
+ char ch;
+ char s[250];
+
+ ch=fgetc(in_file);
+
+
+ while(ch != EOF && ch != '>')
+ {
+
+ if(!isspace(ch))
+ {
+ /* Re allocate memory */
+ if(bases_read == base_limit)
+ {
+ // fprintf(stderr,"Read %d bases - reallocating\n",bases_read);
+ new_limit=base_limit+base_limit;
+ (*alignment)[index]=(align_type *)mrealloc((*alignment)[index],(base_limit) * sizeof(align_type),new_limit*sizeof(align_type) );
+ base_limit=new_limit;
+ }
+/* if(ch == MISSING) */
+/* { */
+/* (*alignment)[index][bases_read]=(align_type)MISSING_STATE; */
+/* } */
+/* else if(ch == GAP) */
+/* { */
+/* (*alignment)[index][bases_read]=(align_type)GAP_STATE; */
+/* } */
+/* else */
+/* { */
+ if((ch < CHAR_START) || (ch > CHAR_END))
+ {
+ sprintf(s,"Illegal state encountered: %c\n",ch);
+ error(s);
+ }
+ else
+ {
+ (*alignment)[index][bases_read]=(align_type)(toupper(ch)-CHAR_START);
+ }
+ /* } */
+ bases_read++;
+ }
+ else
+ {
+ ch=skip_all_space(in_file);
+ }
+ ch=fgetc(in_file);
+ }
+ if(ch != EOF)
+ ungetc(ch,in_file);
+
+
+ num_bases[index]=bases_read;
+ // fprintf(stderr,"Final tally is %d\n",bases_read);
+ (*alignment)[index]=(align_type *)mrealloc((*alignment)[index],(base_limit) * sizeof(align_type),bases_read*sizeof(align_type) );
+ base_limit=bases_read;
+ return ch;
+
+}
+
+
+
+/* In: file_name - name of fasta file with sequences
+ Out: taxa_name - name of all the taxa
+ alignment - ordered by taxa
+ num_taxa
+ num_sites
+*/
+
+
+void read_fasta(const char* file_name, char ***taxa_names, align_type ***alignment, int *num_taxa, int *num_sites)
+{
+ char s[250];
+ FILE *in_file;
+
+ /* Keep track of how many bases in each sequence... */
+ int *seq_counter;
+ int i;
+
+ char ch;
+
+ int cur_seqs;
+ int num_seqs=1,new_num;
+ int length=99;
+
+ in_file=fopen(file_name,"r");
+ if(in_file == NULL)
+ {
+ sprintf(s,"Could not open file %s",file_name);
+ error(s);
+ }
+
+
+
+ /* Allocate space for sequence and names - 1 at a time*/
+ (*taxa_names)=(char **)mcalloc(num_seqs , sizeof(char *) );
+
+ (*alignment)=(align_type **)mcalloc(num_seqs , sizeof(align_type *) );
+ seq_counter=(int *)mmalloc((num_seqs * sizeof(int) ));
+
+
+ for(i=0;i<(num_seqs);i++)
+ {
+ (*taxa_names)[i]=(char *)mcalloc((MAX_SIZE+1) , sizeof(char) );
+ (*alignment)[i]=(align_type *)mcalloc(length , sizeof(align_type) );
+ seq_counter[i]=0;
+ }
+
+
+
+ ch=skip_non_newline_space(in_file);
+ cur_seqs=0;
+ while(ch != EOF)
+ {
+ if(cur_seqs==num_seqs)
+ {
+ new_num=num_seqs+1;
+ (*taxa_names)=(char **)mrealloc(*taxa_names,num_seqs *sizeof(char *),new_num*sizeof(char *) );
+ (*alignment)=(align_type **)mrealloc(*alignment,num_seqs * sizeof(align_type *),new_num*sizeof(align_type *));
+ seq_counter=(int *)mrealloc(seq_counter,(num_seqs * sizeof(int) ),new_num*sizeof(int));
+
+ for(i=num_seqs;i<(new_num);i++)
+ {
+ (*taxa_names)[i]=(char *)mcalloc((MAX_SIZE+1) , sizeof(char) );
+ (*alignment)[i]=(align_type *)mcalloc(length , sizeof(align_type) );
+ seq_counter[i]=0;
+ }
+
+ num_seqs=new_num;
+
+ }
+ ch=skip_all_space(in_file);
+ read_sequence_name(in_file,(*taxa_names)[cur_seqs],MAX_SIZE);
+ /* Might have comment - remove */
+ ch=skip_non_newline(in_file);
+ /* Advance to sequence */
+ ch=skip_newlines(in_file);
+ /* Read sequence */
+ ch=read_seq_part(in_file, length,alignment, cur_seqs, seq_counter);
+
+ cur_seqs++;
+
+ }
+
+
+ *num_taxa=cur_seqs;
+ new_num=cur_seqs;
+
+
+
+/* /\* Fix allocated size *\/ */
+/* (*taxa_names)=(char **)mrealloc(*taxa_names,num_seqs *sizeof(char *),new_num*sizeof(char *) ); */
+/* (*alignment)=(align_type **)mrealloc(*alignment,num_seqs * sizeof(align_type *),new_num*sizeof(align_type *)); */
+/* seq_counter=(int *)mrealloc(seq_counter,(num_seqs * sizeof(int) ),new_num*sizeof(int)); */
+
+ /* Assume all have equal length - use first taxa */
+ *num_sites=seq_counter[0];
+ /* Check size of sequences */
+ for(i=0;i<(*num_taxa);i++)
+ if(seq_counter[i] != *num_sites)
+ {
+ sprintf(s,"Number of sites read does not match number of sites expected for seq %s",(*taxa_names)[i]);
+ error(s);
+ }
+ fprintf(stdout,"Found %d sequences of length %d\n",*num_taxa,*num_sites);
+ free(seq_counter);
+}
+
diff --git a/src/fasta.h b/src/fasta.h
new file mode 100644
index 0000000..2b4abbb
--- /dev/null
+++ b/src/fasta.h
@@ -0,0 +1,8 @@
+#ifndef FASTA
+#define FASTA
+
+void write_fasta(FILE* cur_stream, char **taxa_names,align_type **alignment, int num_taxa,int num_sites);
+
+void read_fasta(const char* file_name, char ***taxa_names, align_type ***alignment, int *num_taxa, int *num_sites);
+
+#endif
diff --git a/src/global.c b/src/global.c
new file mode 100644
index 0000000..d4f091b
--- /dev/null
+++ b/src/global.c
@@ -0,0 +1,79 @@
+#include "global.h"
+const char DNA_ALPHA[] = {'A','C','G','T'};
+const int DNA_ALPHA_SIZE=4;
+
+const char DNA_MISSING[] = {'X','N','?'};
+const int DNA_MISSING_SIZE=3;
+
+const char DNA_AMBIG[] = {'R','Y','M','K','S','W','H','B','V','D'};
+const int DNA_AMBIG_SIZE = 10;
+
+const char AA_ALPHA[] = {'A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y'};
+const int AA_ALPHA_SIZE=20;
+
+const char AA_MISSING[] ={'X','?'};
+const int AA_MISSING_SIZE =2;
+
+const char AA_AMBIG[] = {'B','Z'};
+const int AA_AMBIG_SIZE =2;
+
+const char GAP[] = {'-'};
+const int GAP_SIZE=2;
+
+cbool memberOf(const char *set, const int num, char ch)
+{
+ int i;
+
+ for(i=0;i<num;i++)
+ if(ch == (set[i]-CHAR_START))
+ return TRUE;
+ return FALSE;
+}
+
+cbool validState(alignmentClass alignKind, char ch)
+{
+
+ switch(alignKind)
+ {
+ case DNA:
+ // fprintf(stdout,"checking based %c -have %d\n",ch,memberOf(DNA_ALPHA,DNA_ALPHA_SIZE,ch));
+ return memberOf(DNA_ALPHA,DNA_ALPHA_SIZE,ch);
+ break;
+ case AA:
+ return memberOf(AA_ALPHA,AA_ALPHA_SIZE,ch);
+ break;
+ case OTHER:
+ if((ch != (GLOBAL_GAP-CHAR_START)) && (ch != (GLOBAL_MISSING-CHAR_START)))
+ return TRUE;
+ else
+ return FALSE;
+
+ }
+
+ return FALSE;
+}
+
+cbool valid_gap(alignmentClass alignKind, char ch)
+{
+ return (memberOf(GAP,GAP_SIZE,ch));
+}
+cbool missing_ambig_State(alignmentClass alignKind, char ch)
+{
+
+ switch(alignKind)
+ {
+ case DNA:
+ return (memberOf(DNA_MISSING,DNA_MISSING_SIZE,ch) || memberOf(DNA_AMBIG,DNA_AMBIG_SIZE,ch));
+ break;
+ case AA:
+ return (memberOf(AA_MISSING,AA_MISSING_SIZE,ch) || memberOf(AA_AMBIG,AA_AMBIG_SIZE,ch));
+ break;
+ case OTHER:
+ if(ch == GLOBAL_MISSING)
+ return TRUE;
+ else
+ return FALSE;
+ }
+
+ return FALSE;
+}
diff --git a/src/global.h b/src/global.h
new file mode 100644
index 0000000..7c7babe
--- /dev/null
+++ b/src/global.h
@@ -0,0 +1,80 @@
+
+#ifndef GLOBAL
+#define GLOBAL
+
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include<ctype.h>
+#include<math.h>
+
+#define PHYLIP_SIZE 10
+#define MAX_SIZE 1000
+
+/* For reading in data... */
+#define CHAR_START 33
+#define CHAR_END 126
+//#define MAX_STATES 94
+
+#define MAX_STATE 100
+
+
+/* Two ways to treating missing data - either as no data or as an extra state */
+#define GLOBAL_GAP '-'
+
+#define GLOBAL_MISSING '?'
+#define MISSING_STATE 95
+
+#define IGNORE_STATE 101
+extern const char DNA_ALPHA[];
+extern const int DNA_ALPHA_SIZE;
+
+extern const char DNA_MISSING[];
+extern const int DNA_MISSING_SIZE;
+
+extern const char DNA_AMBIG[];
+extern const int DNA_AMBIG_SIZE;
+
+extern const char AA_ALPHA[] ;
+extern const int AA_ALPHA_SIZE ;
+extern const char AA_MISSING[];
+extern const int AA_MISSING_SIZE;
+extern const char AA_AMBIG[];
+extern const int AA_AMBIG_SIZE;
+
+
+
+//#define MISSING_STATE 101
+
+
+typedef enum {DNA,AA,OTHER} alignmentClass;
+
+typedef enum {FALSE, TRUE} cbool;
+typedef enum {constant, polymorphic} polystatus;
+typedef enum {uninformative, informative} infstatus;
+typedef enum {nongapped,gapped} gapstatus;
+
+typedef enum {strict,relaxed,fasta} fileType;
+
+typedef struct {
+ polystatus poly;
+ infstatus inf;
+ gapstatus gap;
+ int orig_index;
+ int num_states;
+ int num_missing;
+} site;
+
+
+typedef int inc_type;
+typedef char align_type;
+
+
+cbool memberOf(const char *set, const int num, char ch);
+
+cbool validState(alignmentClass alignKind, char ch);
+
+cbool missing_ambig_State(alignmentClass alignKind, char ch);
+
+cbool valid_gap(alignmentClass alignKind, char ch);
+#endif
diff --git a/src/graphCode.c b/src/graphCode.c
new file mode 100644
index 0000000..c9744f7
--- /dev/null
+++ b/src/graphCode.c
@@ -0,0 +1,443 @@
+/*
+ Copyright (c)2005, Trevor Bruen
+ All rights reserved.
+
+ Any feedback is very welcome.
+ email: trevor at mcb.mcgill.ca
+*/
+
+#include <stdlib.h>
+#include "global.h"
+#include "mem.h"
+#include "math.h"
+
+
+#define RED 0
+#define BLUE 1
+#define GREEN 2
+
+
+#define MIN(a,b) ((a<b) ? (a):(b))
+
+typedef unsigned char image_type;
+/* Convert a color from hue/saturation/value space to rgb space */
+/* hsv between 0 (red) and (360) */
+void hsv2rgb(double hsv_h, double hsv_s,double hsv_v, double **rgb_col, int index)
+{
+
+ if (hsv_h < 120)
+ {
+ rgb_col[index][RED] = (120 - hsv_h) / 60.0;
+ rgb_col[index][GREEN] = hsv_h / 60.0;
+ rgb_col[index][BLUE] = 0;
+ }
+ else if (hsv_h < 240)
+ {
+ rgb_col[index][RED] = 0;
+ rgb_col[index][GREEN] = (240 - hsv_h) / 60.0;
+ rgb_col[index][BLUE] = (hsv_h - 120) / 60.0;
+ }
+ else
+ {
+
+ rgb_col[index][RED] = (hsv_h - 240) / 60.0;
+ rgb_col[index][GREEN] = 0;
+ rgb_col[index][BLUE] = (360 - hsv_h) / 60.0;
+ }
+ rgb_col[index][RED] = MIN(rgb_col[index][RED],1);
+ rgb_col[index][GREEN] = MIN(rgb_col[index][GREEN],1);
+ rgb_col[index][BLUE] = MIN(rgb_col[index][BLUE],1);
+
+ rgb_col[index][RED] = 255*(1 - hsv_s + hsv_s * rgb_col[index][RED]) * hsv_v;
+ rgb_col[index][GREEN] = 255*(1 - hsv_s + hsv_s * rgb_col[index][GREEN]) * hsv_v;
+ rgb_col[index][BLUE] = 255*(1 - hsv_s + hsv_s * rgb_col[index][BLUE]) * hsv_v;
+}
+
+
+void write_PPM(FILE *out_file,image_type **r_array, image_type **g_array, image_type **b_array,int y_size,int x_size)
+{
+ int i, j;
+ fprintf(out_file,"P3\n%d %d\n255\n",x_size,y_size);
+
+ for(i=0;i<y_size;i++)
+ {
+ for(j=0;j<x_size;j++)
+ {
+ fprintf(out_file,"%d %d %d",r_array[i][j],g_array[i][j],b_array[i][j]);
+ if( ((j+1)% 4 == 0))
+ fprintf(out_file,"\n");
+ else
+ fprintf(out_file," ");
+ }
+ fprintf(out_file,"\n");
+ }
+}
+
+
+void draw_line(image_type ***r_array,image_type ***g_array,image_type ***b_array,int y0,int y1,int x0,int x1,int r_0,int g_0, int b_0)
+{
+ cbool steep=FALSE;
+ int deltax,deltay,deltaerr,x,y,xstep=-1,ystep=-1,temp,error=0;
+
+ if(abs(y1-y0) > abs (x1 -x0))
+ {
+ steep=TRUE;
+ /* Swap x0 and y0 */
+ temp=x0;
+ x0=y0;
+ y0=temp;
+ /* Swap x1 and y1 */
+ temp=x1;
+ x1=y1;
+ y1=temp;
+ }
+
+ deltax=abs(x1-x0);
+ deltay=abs(y1-y0);
+ deltaerr=deltay;
+ x=x0;
+ y=y0;
+ if(x0 < x1)
+ xstep=1;
+ if(y0 < y1)
+ ystep=1;
+
+
+ if(steep==TRUE)
+ {
+ (*r_array)[x][y]=r_0;
+ (*g_array)[x][y]=g_0;
+ (*b_array)[x][y]=b_0;
+
+ }
+ else
+ {
+ (*r_array)[y][x]=r_0;
+ (*g_array)[y][x]=g_0;
+ (*b_array)[y][x]=b_0;
+ }
+
+ while(x != x1)
+ {
+ x=x+xstep;
+ error=error+deltaerr;
+ if(2*error >= deltax)
+ {
+ y=y+ystep;
+ error=error - deltax;
+ }
+
+ if(steep==TRUE)
+ {
+ (*r_array)[x][y]=r_0;
+ (*g_array)[x][y]=g_0;
+ (*b_array)[x][y]=b_0;
+
+ }
+ else
+ {
+ (*r_array)[y][x]=r_0;
+ (*g_array)[y][x]=g_0;
+ (*b_array)[y][x]=b_0;
+ }
+
+ }
+
+}
+
+
+
+void draw_box(image_type ***r_array,image_type ***g_array,image_type ***b_array,int y1,int y2,int x1,int x2,int r_0,int g_0, int b_0)
+{
+ int i,j;
+
+ for(i=y1;i<y2;i++)
+ for(j=x1;j<x2;j++)
+ {
+ (*r_array)[i][j]=r_0;
+ (*g_array)[i][j]=g_0;
+ (*b_array)[i][j]=b_0;
+ }
+}
+
+
+void create_profile_pic(int num_sites,int k,int num_inf, double *break_values,site *site_desc)
+{
+ FILE *out_file;
+ int cur_value,next_value;
+ int i,j,temp;
+ double max_value=0,ratio;
+ double peak_in=6.63;
+ /* Size of graph - total number of states available */
+
+ int header=100,margin=100;
+ int height=400+2*header,width=num_sites+2*margin;
+
+ /* Array of actual image */
+ image_type **r_array,**g_array,**b_array;
+
+ r_array = (image_type **)mmalloc(height * sizeof(int *));
+ g_array = (image_type **)mmalloc(height * sizeof(int *));
+ b_array = (image_type **)mmalloc(height * sizeof(int *));
+
+ for(i=0;i<height;i++)
+ {
+ r_array[i] = (image_type *)mmalloc(width * sizeof(int));
+ g_array[i] = (image_type *)mmalloc(width * sizeof(int));
+ b_array[i] = (image_type *)mmalloc(width * sizeof(int));
+ }
+ for(i=0;i<height;i++)
+ {
+ for(j=0;j<width;j++)
+ {
+ r_array[i][j] = 255;
+ g_array[i][j] = 255;
+ b_array[i][j] = 255;
+ }
+ }
+ for(i=0;i<num_inf;i++)
+ {
+ if(break_values[i]> max_value)
+ max_value=break_values[i];
+ }
+
+ temp=(int)(max_value/10) + 1;
+ ratio=40.0/((double)temp);
+ /* Draw borders */
+ draw_line(&r_array,&g_array,&b_array,height-header+1,height-header+1,0+margin,num_sites+margin,0,0,0);
+
+ draw_line(&r_array,&g_array,&b_array,height-header+1,header,margin-1,margin-1,0,0,0);
+
+ /* Draw ticks */
+ /* First height ticks */
+
+ for(i=1;i<2*temp;i++)
+ {
+ cur_value=(ratio*5*i);
+ draw_line(&r_array,&g_array,&b_array,height-((int)cur_value+header),height-((int)cur_value+header),margin-11,margin-1,0,0,0);
+ }
+ /* Draw line at sig <0.01 */
+ cur_value=(ratio*peak_in);
+ draw_line(&r_array,&g_array,&b_array,height-((int)cur_value+header),height-((int)cur_value+header),margin,margin+num_sites,255,0,0);
+
+ /* Next draw site ticks */
+ for(i=1;i<num_sites;i++)
+ {
+ if(i % 500 == 0)
+ {
+ draw_line(&r_array,&g_array,&b_array,height-header+1,height-header+21,margin+i,margin+i,0,0,0);
+ }
+ else if(i % 100 == 0)
+ {
+ draw_line(&r_array,&g_array,&b_array,height-header+1,height-header+11,margin+i,margin+i,0,0,0);
+ }
+ }
+ /* Add profile */
+ draw_line(&r_array,&g_array,&b_array,height-header,height-header,0+margin,site_desc[k].orig_index+margin,0,0,255);
+ for(i=0;i<(num_inf-2*k);i++)
+ {
+ cur_value=(ratio*break_values[i]);
+ next_value=(ratio*break_values[i+1]);
+
+ draw_line(&r_array,&g_array,&b_array,height-((int)cur_value+header),height-((int)next_value+header),site_desc[i+k].orig_index+margin,site_desc[i+1+k].orig_index+margin,0,0,255);
+
+
+ }
+ draw_line(&r_array,&g_array,&b_array,height-header,height-header,margin+site_desc[i+k].orig_index,num_sites+margin,0,0,255);
+
+ /* Print image */
+ out_file=fopen("profile.ppm","w");
+ write_PPM(out_file,r_array,g_array,b_array,height,width);
+
+}
+
+void create_incompat_pic(int num_states,int max_inc,inc_type **inc_matrix, cbool embellish, int num_chars)
+{
+
+ FILE *out_file;
+ double hue, saturation, value;
+
+ int i,j,i2,j2,cur;
+
+ /* Size of graph - total number of states available */
+ int size;
+
+ /* Embellish sizes */
+
+ int tick_height_small=12;
+ int freq_small_tick=10;
+ int freq_big_tick=50;
+
+ int tick_height_big=24;
+ int tick_width_small=1,tick_width_large=3;
+
+ int header=tick_height_big+5;
+ int block=5;
+ int spacer=1;
+ int b_size=block+spacer;
+ int border=5;
+ int offset=header+border;
+ int cur_a,cur_b;
+
+ /* 60 degrees - i.e. yellow */
+ int start_color = 60;
+
+ /* 0 degrees - i.e. red */
+ int end_color = 0;
+
+ double ratio=0.5;
+ /* Array of actual image */
+ image_type **r_array,**g_array,**b_array;
+
+
+ /* Map to colors */
+ double **palette;
+
+ /* Size of graph */
+ if(embellish)
+ size=(num_chars)*(b_size) - spacer+2*offset;
+ else
+ size=num_chars;
+
+ /* Allocate memory */
+ palette = (double **)mmalloc(max_inc * sizeof(double *));
+
+ for(i=0;i<max_inc;i++)
+ palette[i]=(double *)mmalloc( 3 * sizeof(double));
+
+ r_array = (image_type **)mmalloc(size * sizeof(int *));
+ g_array = (image_type **)mmalloc(size * sizeof(int *));
+ b_array = (image_type **)mmalloc(size * sizeof(int *));
+
+ for(i=0;i<size;i++)
+ {
+ r_array[i] = (image_type *)mmalloc(size * sizeof(image_type));
+ g_array[i] = (image_type *)mmalloc(size * sizeof(image_type));
+ b_array[i] = (image_type *)mmalloc(size * sizeof(image_type));
+ }
+
+
+ for(i=0;i<size;i++)
+ for(j=0;j<size;j++)
+ {
+ r_array[i][j] = 32;
+ g_array[i][j] = 32;
+ b_array[i][j] = 32;
+ }
+
+ /* Create colors */
+ for(i=0;i<max_inc;i++)
+ {
+ saturation =1.0;
+ value=1.0;
+ hue=end_color-((double)(end_color - start_color)) * pow(ratio,i);
+
+ hsv2rgb(hue,saturation,value,palette,i);
+ }
+ /* Add border if embellish */
+ if(embellish)
+ {
+ /* Fill background with white */
+ for(i=0;i<size;i++)
+ for(j=0;j<size;j++)
+ {
+ if((i<offset) || (i>= (size-offset)) || (j<offset) || (j>= (size-offset)))
+ {
+ r_array[i][j] = 255;
+ g_array[i][j] = 255;
+ b_array[i][j] = 255;
+ }
+ }
+
+ /* Add borders */
+ draw_box(&r_array,&g_array,&b_array,header,offset,offset,size-offset,0,0,0);
+ draw_box(&r_array,&g_array,&b_array,size-offset,size-header,offset,size-offset,0,0,0);
+ draw_box(&r_array,&g_array,&b_array,header,size-header,header,offset,0,0,0);
+ draw_box(&r_array,&g_array,&b_array,header,size-header,size-offset,size-header,0,0,0);
+
+ /* Add ticks */
+ for(i=0;i<(num_chars-1);i++)
+ {
+ /* Draw big tick */
+ if((i+1) % freq_big_tick == 0)
+ {
+ draw_box(&r_array,&g_array,&b_array,offset+b_size*i+(block-tick_width_large)/2,offset+b_size*i+(block+tick_width_large)/2,header-tick_height_big,header,0,0,0);
+ draw_box(&r_array,&g_array,&b_array,header-tick_height_big,header,offset+b_size*i+(block-tick_width_large)/2,offset+b_size*i+(block+tick_width_large)/2,0,0,0);
+ draw_box(&r_array,&g_array,&b_array,offset+b_size*i+(block-tick_width_large)/2,offset+b_size*i+(block+tick_width_large)/2,size-header,size-header+tick_height_big,0,0,0);
+ draw_box(&r_array,&g_array,&b_array,size-header,size-header+tick_height_big,offset+b_size*i+(block-tick_width_large)/2,offset+b_size*i+(block+tick_width_large)/2,0,0,0);
+
+
+ }
+ else if ((i+1) % freq_small_tick == 0)
+ {
+ draw_box(&r_array,&g_array,&b_array,offset+b_size*i+(block-tick_width_small)/2,offset+b_size*i+(block+tick_width_small)/2,header-tick_height_small,header,0,0,0);
+
+ draw_box(&r_array,&g_array,&b_array,header-tick_height_small,header,offset+b_size*i+(block-tick_width_small)/2,offset+b_size*i+(block+tick_width_small)/2,0,0,0);
+ draw_box(&r_array,&g_array,&b_array,offset+b_size*i+(block-tick_width_small)/2,offset+b_size*i+(block+tick_width_small)/2,size-header,size-header+tick_height_small,0,0,0);
+ draw_box(&r_array,&g_array,&b_array,size-header,size-header+tick_height_small,offset+b_size*i+(block-tick_width_small)/2,offset+b_size*i+(block+tick_width_small)/2,0,0,0);
+
+ }
+
+ }
+ }
+ /* Fill image with values from matrix */
+ if(embellish)
+ {
+ for(i=0;i<num_chars;i++)
+ {
+ for(i2=0;i2<block;i2++)
+ {
+ cur_a=b_size*i+offset+i2;
+
+ for(j=0;j<num_chars;j++)
+ {
+ for(j2=0;j2<block;j2++)
+ {
+ cur_b=b_size*j+offset+j2;
+ cur=inc_matrix[i][j];
+
+ r_array[cur_a][cur_b] = (image_type)palette[cur][RED];
+ g_array[cur_a][cur_b] = (image_type)palette[cur][GREEN];
+ b_array[cur_a][cur_b] = (image_type)palette[cur][BLUE];
+
+
+ /* Black down diagonal except every x times */
+ if(i==j)
+ {
+
+ if((i+1) % freq_small_tick == 0)
+ {
+ r_array[cur_a][cur_b] = 255;
+ g_array[cur_a][cur_b] = 255;
+ b_array[cur_a][cur_b] = 255;
+ }
+
+ else
+ {
+ r_array[cur_a][cur_b] = 32;
+ g_array[cur_a][cur_b] = 32;
+ b_array[cur_a][cur_b] = 32;
+ }
+
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ for(i=0;i<size;i++)
+ for(j=0;j<size;j++)
+ {
+ cur=inc_matrix[i][j];
+ r_array[i][j]= (image_type)palette[cur][RED];
+ g_array[i][j]= (image_type)palette[cur][GREEN];
+ b_array[i][j]= (image_type)palette[cur][BLUE];
+ }
+ }
+
+ /* Print image */
+ out_file=fopen("matrix.ppm","w");
+ write_PPM(out_file,r_array,g_array,b_array,size,size);
+}
diff --git a/src/graphCode.h b/src/graphCode.h
new file mode 100644
index 0000000..46bbb1f
--- /dev/null
+++ b/src/graphCode.h
@@ -0,0 +1,8 @@
+#ifndef GRAPH
+#define GRAPH
+
+void create_incompat_pic(int num_states,int max_inc,inc_type **inc_matrix, cbool embellish, int num_chars);
+
+void create_profile_pic(int num_sites,int k,int num_inf, double *break_values,site *site_desc);
+
+#endif
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..8d2a183
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,652 @@
+/*
+ Copyright (c)2005, Trevor Bruen
+ All rights reserved.
+
+ Any feedback is very welcome.
+ email: trevor at mcb.mcgill.ca
+*/
+
+#include <time.h>
+
+#include "global.h"
+#include "options.h"
+#include "misc.h"
+#include "pairScore.h"
+
+
+#include "normal.h"
+#include "stats.h"
+#include "mem.h"
+#include "phylip.h"
+#include "fasta.h"
+#include "seqManip.h"
+#include "maxChi.h"
+#include "graphCode.h"
+
+
+void print_usage()
+{
+
+ fprintf(stderr, "Input file not specified!!! (use -f|-r|-s)\n");
+
+ fprintf(stderr, "Usage: Phi [-f|-s|-r] Filename [-t] AlignmentType\n");
+ fprintf(stderr, " [-p [#]] [-o] [-v] [-g [#]] [-b [#]]\n\n");
+
+
+ fprintf(stderr, "Options:\n");
+ fprintf(stderr, " -f: Filename = FASTA format\n");
+ fprintf(stderr, " -s: Filename = Strict phylip file\n");
+ fprintf(stderr, " -r: Filename = Relaxed phylip file\n");
+ fprintf(stderr, " -t: AlignmentType = D|A|O where D=DNA\n");
+ fprintf(stderr, " A=AA and O=OTHER [default DNA]\n");
+
+ fprintf(stderr, " -p: [#] = PHI permutation test [default = FALSE, #=1000]\n");
+ fprintf(stderr, " -w: # = Change default window size [default w = 100]\n");
+
+
+ fprintf(stderr, " -o: Report other statistics (NSS and Max Chi^2) [default = FALSE]\n");
+
+ fprintf(stderr, " -v: Verbose [default = FALSE]\n");
+
+ fprintf(stderr, " -g: [i] = Print color (scaled) incompatibility matrix (graph.ppm)\n");
+ fprintf(stderr, " i - Image only (no ticks...) [default = FALSE]\n");
+
+}
+
+
+void get_params(int argc, char**argv, options *opt)
+{
+ char *cur,ch,nextch;
+ char temp[MAX_SIZE+1];
+ int i;
+ cbool inFileFound=FALSE;
+
+ opt->otherStats=FALSE;
+ opt->doPerm=FALSE;
+ opt->winSize=100;
+ opt->k=0;
+ opt->ntrials=1000;
+ opt->alignKind=DNA;
+ opt->printMatrix=FALSE;
+ opt->graphType=4;
+
+ opt->printBreakpoints=FALSE;
+ opt->breakWindow=100;
+ opt->embellish=TRUE;
+
+ opt->verbose=FALSE;
+
+ if(argc < 3)
+ {
+ print_usage();
+ exit(1);
+ }
+
+
+ for(i=1;i<argc;i++)
+ {
+ cur=argv[i];
+ ch=cur[0];
+
+ //cout<<"Have "<<cur<<" and "<<ch<<endl;
+ if(ch == '-')
+ {
+ ch=toupper(cur[1]);
+ switch(ch)
+ {
+ /* Print other stats */
+ case 'O':
+ opt->otherStats=TRUE;
+ break;
+
+ /* Type of sequence */
+ case 'T':
+ i++;
+ cur=argv[i];
+ nextch=toupper(cur[0]);
+ if(nextch == 'D')
+ opt->alignKind=DNA;
+ else if(nextch == 'A')
+ opt->alignKind=AA;
+ else if(nextch == 'O')
+ opt->alignKind=OTHER;
+ else
+ opt->alignKind=OTHER;
+ //Error
+ break;
+
+ /* Fasta file */
+ case 'F':
+ if(!inFileFound)
+ {
+ inFileFound=TRUE;
+ opt->inFile=fasta;
+ i++;
+ strsub(opt->seqFile,argv[i],0);
+ break;
+
+ }
+ else
+ {
+ //Error
+ }
+ break;
+
+ /* Strict phylip */
+ case 'S':
+ if(!inFileFound)
+ {
+ inFileFound=TRUE;
+ opt->inFile=strict;
+ i++;
+ strsub(opt->seqFile,argv[i],0);
+ break;
+
+ }
+ else
+ {
+ //Error
+ }
+ break;
+
+ /* Relaxed phylip */
+ case 'R':
+ if(!inFileFound)
+ {
+ inFileFound=TRUE;
+ opt->inFile=relaxed;
+ i++;
+ strsub(opt->seqFile,argv[i],0);
+ break;
+
+ }
+ else
+ {
+ //Error
+ }
+ break;
+
+ case 'V':
+ opt->verbose=TRUE;
+ break;
+
+
+
+ /* Or window size */
+ case 'W':
+ i++;
+ strsub(temp,argv[i],0);
+ opt->winSize=atof(temp);
+ break;
+
+ /* Do permutations ? */
+ case 'P':
+ opt->doPerm=TRUE;
+ i++;
+ if(i<argc && argv[i][0] != '-')
+ {
+ strsub(temp,argv[i],0);
+ opt->ntrials=atoi(temp);
+ }
+ else
+ i--;
+
+ break;
+
+ case 'G':
+ opt->printMatrix=TRUE;
+ i++;
+ if(i<argc && argv[i][0] == 'i')
+ opt->embellish=FALSE;
+ else
+ i--;
+ break;
+
+ case 'B':
+ opt->printBreakpoints=TRUE;
+ i++;
+ if(i<argc && argv[i][0] != '-')
+ {
+ strsub(temp,argv[i],0);
+ opt->breakWindow=atoi(temp);
+
+ }
+ else
+ i--;
+ break;
+
+ }
+ }
+ else
+ {
+ //Error
+ }
+ }
+ // Error if no file
+ if(!(inFileFound))
+ {
+ print_usage();
+ exit(1);
+ }
+
+}
+void print_vals(FILE *logfile,cbool print_val_a,cbool print_val_b,double val_a, double val_b)
+{
+ if(print_val_a)
+ {
+ fprintf(stdout,"%4.2le ",val_a);
+ fprintf(logfile,"%4.2le ",val_a);
+ }
+ else
+ {
+ fprintf(stdout," -- ");
+ fprintf(logfile," -- ");
+ }
+ if(print_val_b)
+ {
+ fprintf(stdout,"%4.2le\n",val_b);
+ fprintf(logfile,"%4.2le\n",val_b);
+ }
+ else
+ {
+ fprintf(stdout,"--\n");
+ fprintf(logfile,"--\n");
+ }
+
+}
+
+
+int main(int argc, char* argv[])
+{
+ align_type **alignment;
+ char **taxa_names;
+ int num_taxa,num_sites;
+ int num_inf;
+ int pair_inc;
+ double divg,val;
+
+ /*Parameters */
+ options opt;
+
+ /* Number of states at each character and description of each site */
+ int *site_states;
+ site *site_desc;
+
+ /* Counts of incompatibilities */
+ int *counts,max_state,max_inc;
+
+ /* Alignment for informative states */
+ align_type **inf_alignment;
+ int *inf_states;
+ site *inf_site_desc;
+
+ /* Alignment by characters */
+ align_type **char_alignment;
+
+ /* Matrix of incompatibilities */
+ int i,j;
+ inc_type **inc_matrix;
+
+ /* Log file */
+ FILE *alignfile,*logfile;
+
+
+ /* Values of statistics */
+ cbool valid_normal_approx;
+ double orig_PHI,orig_NSS, cur_PHI, cur_NSS;
+ double sum_PHI=0,sum_sq_PHI=0,obs_mean=0,obs_varnce=0;
+ double mean=0.0,variance=0.0;
+ double difference,normal_p_val=0.0;
+ int emp_PHI=0,emp_NSS=0, emp_MAXCHI=0;
+
+ int *permutation;
+
+ /* For maxChi */
+ double windowScale= 2/3;
+
+ /* Seed random number generator */
+ srand(time(NULL));
+
+ get_params(argc,argv,&opt);
+
+ /* Open log file */
+
+ logfile=ffopen("Phi.log","w");
+
+ fprintf(stdout,"Reading sequence file %s\n",opt.seqFile);
+ fprintf(logfile,"Reading sequence file %s\n",opt.seqFile);
+
+ switch(opt.inFile)
+ {
+ case strict:
+ read_phylip(opt.seqFile,TRUE, &taxa_names,&alignment,&num_taxa,&num_sites);
+ break;
+ case relaxed:
+ read_phylip(opt.seqFile,FALSE, &taxa_names,&alignment,&num_taxa,&num_sites);
+ break;
+ case fasta:
+ read_fasta(opt.seqFile, &taxa_names,&alignment,&num_taxa,&num_sites );
+ break;
+ }
+
+ fprintf(logfile,"Allocating space for %d taxa and %d sites\n",num_taxa,num_sites);
+
+ if(num_taxa<=0 || num_sites<=0)
+ error("No sequences or sitesin alignment");
+
+
+ /* Validate alignment type */
+ validate_alignment(alignment,opt.alignKind,num_taxa,num_sites);
+ fprintf(stdout,"Alignment looks like a valid ");
+ fprintf(logfile,"Alignment looks like a valid ");
+ switch(opt.alignKind)
+ {
+ case DNA:
+ fprintf(stdout,"DNA alignment.\n");
+ fprintf(logfile,"DNA alignment.\n");
+ break;
+ case AA:
+ fprintf(stdout,"AA alignment.\n");
+ fprintf(logfile,"AA alignment.\n");
+ break;
+ case OTHER:
+ fprintf(stdout,"OTHER alignment.\n");
+ fprintf(logfile,"OTHER alignment.\n");
+ break;
+ }
+
+ /* FIX - Add complete deletion ? */
+
+ get_seq_div(alignment, opt.alignKind, num_taxa, num_sites, &divg);
+ fprintf(stdout,"Estimated diversity is (pairwise deletion - ignoring missing/ambig): %4.1lf%%\n",(divg*100.0));
+ fprintf(logfile,"Estimated diversity is (pairwise deletion - ignoring missing/ambig): %4.1lf%%\n",(divg*100.0));
+
+ /* Get informative sites */
+ find_states(alignment, opt.alignKind,FALSE,num_taxa, num_sites, &site_desc, &site_states);
+
+ get_informative(alignment, site_desc, site_states, num_taxa, num_sites, &num_inf, &inf_alignment, &inf_states, &inf_site_desc);
+
+ fprintf(stdout,"Found %d informative sites.\n",num_inf);
+ fprintf(logfile,"Found %d informative sites.\n",num_inf);
+
+ /* Open seq file */
+
+ alignfile=ffopen("Phi.inf.sites","w");
+
+ fprintf(stdout ,"Writing alignment of informative sites to: Phi.inf.sites\n");
+ fprintf(logfile,"Writing alignment of informative sites to: Phi.inf.sites\n");
+
+
+ switch(opt.inFile)
+ {
+ case strict:
+ write_phylip(alignfile,TRUE, taxa_names,inf_alignment,num_taxa,num_inf);
+ break;
+ case relaxed:
+ write_phylip(alignfile,FALSE, taxa_names,inf_alignment,num_taxa,num_inf);
+ break;
+ case fasta:
+ write_fasta(alignfile, taxa_names,inf_alignment,num_taxa,num_inf );
+ break;
+ }
+ fclose(alignfile);
+
+ /* Write where those sites occured */
+ alignfile=ffopen("Phi.inf.list","w");
+
+ fprintf(stdout ,"Writing list of informative sites to: Phi.inf.list\n");
+ fprintf(logfile, "Writing list of informative sites to: Phi.inf.list\n");
+ for(i=0;i<num_inf;i++)
+ fprintf(alignfile,"%4d %4d\n",i+1,(inf_site_desc[i]).orig_index);
+
+ fclose(alignfile);
+
+ /* Allocate possibly sparsely - big matrix sequential stride */
+ inc_matrix=(inc_type **)mcalloc(num_inf , sizeof(inc_type *) );
+ for(i=0;i<num_inf;i++)
+ inc_matrix[i]=(inc_type *)mcalloc( num_inf , sizeof(inc_type));
+
+ /* Reorder by character */
+ reorder_chars(inf_alignment, opt.alignKind,FALSE,num_inf, num_taxa, &char_alignment);
+
+
+ switch(opt.alignKind)
+ {
+ case DNA:
+ max_state=4;
+ break;
+ case AA:
+ max_state=20;
+ break;
+ case OTHER:
+ max_state=MAX_STATE;
+ break;
+ default:
+ max_state=0;
+ }
+ max_inc=max_state*max_state-2*max_state+1;
+
+ fprintf(stdout,"Calculating all pairwise incompatibilities...\n");
+ /* Now get incompatibilities between all pairs... */
+ for(i=0;i<num_inf;i++)
+ {
+ /* Fix / remove this... */
+ if(i % 100 == 0)
+ {
+ if(i != 0)
+ fprintf(stdout,"\b\b\b\b\b\b");
+ else
+ fprintf(stdout,"Done: ");
+
+ val=((double)i)*((double)num_inf)-((double)i)*((double)(i+1))/2.0;
+ val=val/(((double)num_inf)*((double)num_inf-1)/2);
+ val=val*100.0;
+ fprintf(stdout,"%5.1f%%",val);
+
+ fflush(stdout);
+ }
+
+ for(j=i;j<num_inf;j++)
+ {
+ if(i == j)
+ inc_matrix[i][j]=(inc_type)0;
+ else
+ {
+ pair_inc=pair_score(char_alignment, inf_states,i, j, num_inf, num_taxa);
+
+
+ inc_matrix[i][j]=(inc_type)pair_inc;
+ inc_matrix[j][i]=(inc_type)pair_inc;
+ }
+ }
+ }
+
+ fprintf(stdout,"\b\b\b\b\b\b");
+ fprintf(stdout,"%5.1f%%",100.0);
+ fflush(stdout);
+ fprintf(stdout,"\n\n");
+
+ inc_stats(max_inc,num_inf,opt.verbose,inc_matrix,&counts,logfile);
+
+ if(opt.k == 0)
+ {
+ val=((double)num_inf)/((double)num_sites);
+ val=val*opt.winSize;
+
+ opt.k=(int)(val+0.5);
+
+ if(opt.k == 0)
+ opt.k++;
+ }
+ else
+ {
+ val=((double)num_sites)/((double)num_inf);
+ val=val*opt.k;
+ opt.winSize=val;
+ }
+
+ fprintf(stdout, "Using a window size of %3.0lf with k as %d\n",opt.winSize,opt.k);
+ fprintf(logfile, "Using a window size of %3.0lf with k as %d\n",opt.winSize,opt.k);
+
+
+ permutation=(int *)mmalloc(num_inf * sizeof(int));
+ identity_permutation(permutation,num_inf);
+ orig_PHI=PHI(inc_matrix,inf_states,permutation,num_inf,opt.k);
+
+ if(num_inf <= 2*opt.k)
+ {
+ valid_normal_approx=FALSE;
+ fprintf(stdout, "Too few informative sites to use normal approximation.\nTry doing a permutation test or increasing alignment length\nCan also try decreasing windowsize.\n\n");
+ fprintf(logfile, "Too few informative sites to use normal approximation.\nTry doing a permutation test or increasing alignment length\nCan also try decreasing windowsize.\n\n");
+ }
+ else
+ {
+ valid_normal_approx=TRUE;
+ fprintf(stdout,"\nCalculating analytical mean and variance\n");
+ fprintf(logfile,"\nCalculating analytical mean and variance\n");
+
+ /* Fix argument with 1 */
+ analytic_mean_variance(inc_matrix,inf_states,num_inf,opt.k,&mean,&variance);
+
+ difference=mean-orig_PHI;
+ normal_p_val=normal_01_cdf((-difference)/sqrt(variance));
+ }
+
+ if(opt.doPerm)
+ {
+ if(opt.k >= num_inf)
+ {
+ error("Too few informative sites to test significance. Try decreasing windowsize or increasing alignment length\n\n");
+ }
+ fprintf(stdout,"\nDoing permutation test for PHI\n");
+ fprintf(logfile,"\nDoing permutation test for PHI\n");
+ for(i=0;i<opt.ntrials;i++)
+ {
+ sample_permutation(permutation,num_inf);
+ cur_PHI=PHI(inc_matrix,inf_states,permutation,num_inf,opt.k);
+ if(cur_PHI <= orig_PHI)
+ emp_PHI++;
+ sum_PHI=sum_PHI+cur_PHI;
+ sum_sq_PHI=sum_sq_PHI+cur_PHI*cur_PHI;
+
+ }
+ obs_mean=sum_PHI/((double)opt.ntrials);
+ obs_varnce=(sum_sq_PHI-opt.ntrials*obs_mean*obs_mean)/(opt.ntrials-1);
+
+ }
+
+ if(opt.otherStats)
+ {
+ /* For NSS */
+ fprintf(stdout,"\nDoing permutation test for NSS\n");
+ fprintf(logfile,"\nDoing permutation test for NSS\n");
+
+ identity_permutation(permutation,num_inf);
+
+ orig_NSS=NSS(inc_matrix,permutation,num_inf);
+ if(opt.verbose)
+ {
+ fprintf(stdout,"\nThe Neighbour Similarity score is %6.4le\n",orig_NSS);
+ fprintf(logfile,"\nThe Neighbour Similarity score is %6.4le\n",orig_NSS);
+ }
+
+ for(i=0;i<opt.ntrials;i++)
+ {
+ sample_permutation(permutation,num_inf);
+ cur_NSS=NSS(inc_matrix,permutation,num_inf);
+ if(cur_NSS >= orig_NSS)
+ emp_NSS++;
+ }
+
+ /* For Max Chi^2 */
+ windowScale=2.0/3.0;
+ maxchi(windowScale,opt.verbose,logfile,opt.inFile,alignment,site_desc,site_states,taxa_names,num_taxa,num_sites,opt.ntrials,&emp_MAXCHI);
+
+ }
+
+ if(opt.verbose)
+ {
+ fprintf(stdout,"\n PHI Values\n");
+ fprintf(stdout," ----------\n");
+
+ fprintf(logfile,"\n PHI Values\n");
+ fprintf(logfile," ----------\n");
+
+ if(!opt.doPerm)
+ i=0;
+ else
+ i=opt.ntrials;
+
+ fprintf(stdout," Analytical (%d) Permutations\n\n",i);
+ fprintf(logfile," Analytical (%d) Permutations\n\n",i);
+
+ fprintf(stdout,"Mean: ");
+ fprintf(logfile,"Mean: ");
+
+ print_vals(logfile,valid_normal_approx,opt.doPerm,mean,obs_mean);
+
+ fprintf(stdout,"Variance: ");
+ fprintf(logfile,"Variance: ");
+
+ print_vals(logfile,valid_normal_approx,opt.doPerm,variance,obs_varnce);
+
+ fprintf(stdout,"Observed: %4.2le %4.2le \n\n",orig_PHI,orig_PHI);
+ fprintf(logfile,"Observed: %4.2le %4.2le \n\n",orig_PHI,orig_PHI);
+ }
+
+ if(opt.printMatrix)
+ {
+ fprintf(stdout, "\nOutputting incompatibility matrix to file matrix.ppm\n");
+ fprintf(logfile, "\nOutputting incompatibility matrix to file matrix.ppm\n");
+
+ create_incompat_pic(max_state,max_inc,inc_matrix,opt.embellish,num_inf);
+
+
+ }
+
+ fprintf(stdout,"\n **p-Value(s)** \n");
+ fprintf(stdout," ----------\n\n");
+
+
+ fprintf(logfile,"\n p-Value(s)\n");
+ fprintf(logfile," ----------\n\n");
+
+
+ if(opt.otherStats)
+ {
+ val=((double)emp_NSS)/((double)(opt.ntrials));
+
+ fprintf(stdout,"NSS: %4.2le (%d permutations)\n",val,opt.ntrials);
+ fprintf(logfile,"NSS: %4.2le (%d permutations)\n",val,opt.ntrials);
+
+ val=((double)emp_MAXCHI)/((double)(opt.ntrials));
+
+ fprintf(stdout,"Max Chi^2: %4.2le (%d permutations)\n",val,opt.ntrials);
+ fprintf(logfile,"Max Chi^2: %4.2le (%d permutations)\n",val,opt.ntrials);
+
+ }
+ if(opt.doPerm)
+ {
+ val=((double)emp_PHI)/((double)(opt.ntrials));
+ fprintf(stdout,"PHI (Permutation): %4.2le (%d permutations)\n",val,opt.ntrials);
+ fprintf(logfile,"PHI (Permutation): %4.2le (%d permutations)\n",val,opt.ntrials);
+ }
+
+ if(valid_normal_approx)
+ {
+ fprintf(stdout,"PHI (Normal): %4.2le\n",normal_p_val);
+ fprintf(logfile,"PHI (Normal): %4.2le\n",normal_p_val);
+ }
+ else
+ {
+ fprintf(stdout,"PHI (Normal): --\n");
+ fprintf(logfile,"PHI (Normal): --\n");
+ }
+
+
+ fprintf(stdout,"\n");
+ fprintf(logfile,"\n");
+ fclose(logfile);
+ return 0;
+
+}
diff --git a/src/maxChi.c b/src/maxChi.c
new file mode 100644
index 0000000..5eafa87
--- /dev/null
+++ b/src/maxChi.c
@@ -0,0 +1,212 @@
+/*
+ Copyright (c)2005, Trevor Bruen
+ All rights reserved.
+
+ Any feedback is very welcome.
+ email: trevor at mcb.mcgill.ca
+*/
+
+#include "global.h"
+#include "mem.h"
+
+#include "seqManip.h"
+//#include "misc.h"
+#include "stats.h"
+#include "phylip.h"
+#include "fasta.h"
+#include "queue.h"
+#include "maxChi.h"
+
+
+
+/* Calculate best breakpoint considering all pairs of sequences*/
+void all_pairs_maxchi( align_type **alignment, int num_taxa, int num_sites, int windowsize, int *permutation, site *site_desc,double *maxvalue,char **taxa_names,cbool report_breakpoint,FILE *logfile)
+{
+ int i,j,l;
+ queue all_poly;
+
+ int n=windowsize;
+ int k=(int)(n/2);
+
+ int r,s;
+ queue_elem diff;
+
+ double best_val=0,cur_val=0;
+
+ /* Remove ? */
+ /* Sequences and breakpoint */
+ int best_i=0;
+ int best_j=0;
+ int best_l=0;
+
+ int best_s=0;
+ int best_r=0;
+
+ /* For efficient calculation use queue */
+ all_poly.max_size=n;
+
+ init_queue(&all_poly);
+
+ for(i=0;i<(num_taxa-1);i++)
+ {
+ for(j=(i+1);j<num_taxa;j++)
+ {
+ /* Set up scan */
+ s=0;
+ r=0;
+ clear_queue(&all_poly);
+
+ /* First initialize values queue */
+ for(l=0;l<n;l++)
+ {
+ if(alignment[i][permutation[l]] == alignment[j][permutation[l]])
+ diff=0;
+ else
+ {
+ diff=1;
+ }
+ s=s+(int)diff;
+ enqueue(&all_poly,diff);
+
+ if(l<k)
+ {
+ r=r+(int)diff;
+ }
+ }
+
+ cur_val=((double)n*(k*s-n*r)*(k*s-n*r))/((double)(k*s)*(n-k)*(n-s));
+ if(cur_val > best_val)
+ {
+ best_s=s;
+ best_r=r;
+
+ best_i=i;
+ best_j=j;
+ best_l=l;
+ best_val=cur_val;
+ }
+ // fprintf(stdout,"i and j are %d and %d. r and s are %d and %d. val is %lf\n",i,j,r,s,cur_val);
+ for(;l<num_sites;l++)
+ {
+ dequeue_front(&all_poly,&diff);
+ s=s-(int)diff;
+ r=r-(int)diff;
+
+ if(alignment[i][permutation[l]] == alignment[j][permutation[l]])
+ diff=0;
+ else
+ diff=1;
+
+ s=s+(int)diff;
+ enqueue(&all_poly,diff);
+
+ /* Update value of r as well */
+ element_at(&all_poly,&diff,(k-1));
+ r=r+(int)diff;
+ cur_val=((double)n*(k*s-n*r)*(k*s-n*r))/((double)(k*s)*(n-k)*(n-s));
+ if(cur_val > best_val)
+ {
+ best_s=s;
+ best_r=r;
+ best_i=i;
+ best_j=j;
+ best_l=l;
+ best_val=cur_val;
+ }
+ }
+ }
+ }
+
+
+ if(report_breakpoint)
+ {
+
+
+ fprintf(stdout,"\nBest breakpoint for Max Chi found with sequences %s and %s. r and s are %d and %d\n",taxa_names[best_i],taxa_names[best_j],best_r,best_s);
+ fprintf(logfile,"\nBest breakpoint for Max Chi found with sequences %s and %s.r and s are %d and %d\n",taxa_names[best_i],taxa_names[best_j],best_r,best_s);
+
+ fprintf(stdout,"Value of maximum breakpoint is: %3.1lf\n\n",best_val);
+ fprintf(logfile,"Value of maximum breakpoint is: %3.1lf\n\n",best_val);
+
+
+ fprintf(stdout,"Coordinates of breakpoint with only polymorphic sites (start,breakpoint,end) = (%d, %d, %d)\n",best_l-n,best_l-k,best_l);
+ fprintf(stdout,"Coordinates of breakpoint with all sites (start,breakpoint,end)=(%d, %d, %d)\n",site_desc[best_l-n].orig_index,site_desc[best_l-k].orig_index,site_desc[best_l].orig_index);
+
+ fprintf(logfile,"Coordinates of breakpoint with only polymorphic sites (start,breakpoint,end) = (%d, %d, %d)\n",best_l-n,best_l-k,best_l);
+ fprintf(logfile,"Coordinates of breakpoint with all sites (start,breakpoint,end)=(%d, %d, %d)\n",site_desc[best_l-n].orig_index,site_desc[best_l-k].orig_index,site_desc[best_l].orig_index);
+
+ }
+
+ *maxvalue=best_val;
+}
+
+void maxchi(double windowScale,cbool verbose,FILE *logfile,fileType inFile,align_type **alignment, site *site_desc, int *site_states, char **taxa_names,int num_taxa, int num_sites, int num_trials, int *emp_MAXCHI)
+{
+ int i;
+ double orig_MAXCHI,cur_MAXCHI;
+ int maxChiWindow;
+ int *permutation;
+ int num_poly,num_poly_unambig;
+ align_type **poly_alignment,**poly_alignment_unambig;
+ int *poly_sites,*poly_sites_unambig;
+ site*poly_site_desc,*poly_site_desc_unambig;
+ FILE *alignfile;
+ fprintf(stdout,"\nDoing Permutation test for MAXCHI\n\n");
+ fprintf(logfile,"\nDoing Permutation test for MAXCHI\n\n");
+
+ get_polymorphic( alignment, site_desc, site_states, num_taxa, num_sites, &num_poly, &poly_alignment, &poly_sites, &poly_site_desc);
+
+ get_unambig( poly_alignment, poly_site_desc,poly_sites, num_taxa, num_poly, &num_poly_unambig, &poly_alignment_unambig, &poly_sites_unambig, &poly_site_desc_unambig);
+
+ if(verbose)
+ {
+ fprintf(stdout, "Number of umabiguous polymorphic sites is %d\n",num_poly_unambig);
+ fprintf(logfile,"Number of umabiguous polymorphic sites is %d\n",num_poly_unambig);
+ }
+
+ alignfile=ffopen("Phi.poly.unambig.sites","w");
+
+ fprintf(stdout ,"Writing alignment of polymorphic unambig sites to: Phi.poly.sites\n");
+ fprintf(logfile," Writing alignment of polymorphic unambig sites to: Phi.poly.sites\n");
+
+ switch(inFile)
+ {
+ case strict:
+ write_phylip(alignfile,TRUE, taxa_names,poly_alignment_unambig,num_taxa,num_poly_unambig);
+ break;
+ case relaxed:
+ write_phylip(alignfile,FALSE, taxa_names,poly_alignment_unambig,num_taxa,num_poly_unambig);
+ break;
+ case fasta:
+ write_fasta(alignfile, taxa_names,poly_alignment_unambig,num_taxa,num_poly_unambig );
+ break;
+ }
+ fclose(alignfile);
+
+ permutation=(int *)mmalloc(num_poly_unambig * sizeof(int));
+ identity_permutation(permutation,num_poly_unambig);
+
+ maxChiWindow=(int)(((double)num_poly_unambig) * windowScale);
+ fprintf(stdout,"Window size is %d polymorphic sites\n",maxChiWindow);
+ fprintf(logfile,"Window size is %d polymorphic sites\n",maxChiWindow);
+
+ if(verbose)
+ {
+ all_pairs_maxchi(poly_alignment_unambig, num_taxa, num_poly_unambig,maxChiWindow,permutation,poly_site_desc_unambig,&orig_MAXCHI,taxa_names,TRUE,logfile);
+ }
+ else
+ {
+ all_pairs_maxchi(poly_alignment_unambig, num_taxa, num_poly_unambig,maxChiWindow,permutation,poly_site_desc_unambig,&orig_MAXCHI,taxa_names,
+FALSE,logfile);
+ }
+ *emp_MAXCHI=0;
+
+ for(i=0;i<num_trials;i++)
+ {
+ sample_permutation(permutation,num_poly_unambig);
+ all_pairs_maxchi(poly_alignment_unambig, num_taxa, num_poly_unambig,maxChiWindow,permutation,poly_site_desc_unambig,&cur_MAXCHI,taxa_names,FALSE,logfile);
+ if(cur_MAXCHI >= orig_MAXCHI)
+ (*emp_MAXCHI)++;
+ }
+ return;
+}
diff --git a/src/maxChi.h b/src/maxChi.h
new file mode 100644
index 0000000..f96ca53
--- /dev/null
+++ b/src/maxChi.h
@@ -0,0 +1,9 @@
+#include "global.h"
+#ifndef MAXCHI
+#define MAXCHI
+
+void maxchi(double windowScale,cbool verbose,FILE *logfile,fileType inFile,align_type **alignment, site *site_desc, int *site_states, char **taxa_names,int num_taxa, int num_sites, int num_trials, int *emp_MAXCHI);
+
+void all_pairs_maxchi( align_type **alignment, int num_taxa, int num_sites, int windowsize, int *permutation, site *site_desc,double *maxvalue,char **taxa_names,cbool report_breakpoint,FILE *logfile);
+
+#endif
diff --git a/src/mem.c b/src/mem.c
new file mode 100644
index 0000000..cd1f640
--- /dev/null
+++ b/src/mem.c
@@ -0,0 +1,96 @@
+#include "global.h"
+#include "mem.h"
+
+static size_t allocated=0;
+static int files_open=0;
+
+size_t alloc_size()
+{
+ return allocated;
+}
+
+
+void *mcalloc(size_t num, size_t size)
+{
+ void *value = calloc (num,size);
+ if (value == NULL)
+ {
+ error("Memory Exhausted");
+ }
+ else
+ {
+ /*allocated=allocated+num*size; */
+ }
+ return value;
+}
+
+
+
+void *mmalloc(size_t size)
+{
+ void *value = malloc (size);
+ if (value == NULL)
+ {
+ error("Memory Exhausted");
+ }
+ else
+ {
+ /* allocated=allocated+size; */
+ }
+ return value;
+}
+
+void mfree(void *ptr, size_t size)
+{
+ free(ptr);
+
+ /* allocated=allocated-size; */
+
+}
+
+void *mrealloc(void *ptr, size_t old_size,size_t new_size)
+{
+ void *value = realloc (ptr,new_size);
+ if (value == NULL)
+ {
+ error("Memory Exhausted");
+ }
+ else
+ {
+ /*allocated=allocated + new_size-old_size */
+ }
+ return value;
+}
+
+
+FILE *ffopen(char *name,char *mod)
+{
+ char s[MAX_SIZE+1];
+ FILE *f;
+ f=fopen(name,mod);
+
+ if(f == NULL)
+ {
+ sprintf(s,"Could not open file %s",name);
+ error(s);
+ }
+ files_open++;
+ return f;
+}
+
+char ffclose(FILE *handle)
+{
+ char f;
+ char s[MAX_SIZE+1];
+
+ f=fclose(handle);
+
+ if(f == EOF)
+ {
+ sprintf(s,"Could not close file hanlde ");
+ error(s);
+ }
+ files_open--;
+ return f;
+}
+
diff --git a/src/mem.h b/src/mem.h
new file mode 100644
index 0000000..8fccfe1
--- /dev/null
+++ b/src/mem.h
@@ -0,0 +1,25 @@
+
+#ifndef MEM
+#define MEM
+
+
+size_t alloc_size();
+
+void *mcalloc(size_t num, size_t size);
+
+void *mmalloc(size_t size);
+
+
+void *mrealloc(void *ptr, size_t old_size,size_t new_size);
+
+void mfree(void *ptr, size_t size);
+
+void error(const char * message);
+
+
+char ffclose(FILE *handle);
+
+
+FILE *ffopen(char *name,char *mod);
+
+#endif
diff --git a/src/misc.c b/src/misc.c
new file mode 100644
index 0000000..acb563c
--- /dev/null
+++ b/src/misc.c
@@ -0,0 +1,87 @@
+#include "misc.h"
+#include <ctype.h>
+
+
+void error(const char * message)
+{
+ fprintf(stderr,"\nERROR: %s\n",message);
+ fprintf(stderr,"Exiting...\n");
+
+ exit(1);
+
+}
+
+
+char *strsub(char *s1, const char *s2, int start)
+{
+ char *p;
+ p=s1;
+ s2=s2+start;
+ while( *s2 != '\0')
+ {
+ *p=*s2;
+ p++;
+ s2++;
+ }
+ *p='\0';
+ return p;
+
+}
+
+char skip_all_space(FILE *in_file)
+{
+ char ch;
+
+ ch=fgetc(in_file);
+ while((ch != EOF) && isspace(ch))
+ ch=fgetc(in_file);
+
+ if(ch!=EOF)
+ ungetc(ch,in_file);
+
+ return ch;
+}
+
+
+char skip_newlines(FILE *in_file)
+{
+ char ch;
+
+ ch=fgetc(in_file);
+ while((ch != EOF) && (ch == '\n'))
+ ch=fgetc(in_file);
+
+ if(ch!=EOF)
+ ungetc(ch,in_file);
+
+ return ch;
+
+}
+
+char skip_non_newline(FILE *in_file)
+{
+ char ch;
+
+ ch=fgetc(in_file);
+ while((ch != EOF) && (ch != '\n'))
+ ch=fgetc(in_file);
+
+ if(ch!=EOF)
+ ungetc(ch,in_file);
+
+ return ch;
+}
+
+char skip_non_newline_space(FILE *in_file)
+{
+ char ch;
+
+ ch=fgetc(in_file);
+ while((ch != EOF) && (ch != '\n') && isspace(ch))
+ ch=fgetc(in_file);
+
+ if(ch!=EOF)
+ ungetc(ch,in_file);
+
+ return ch;
+}
diff --git a/src/misc.h b/src/misc.h
new file mode 100644
index 0000000..e313fbb
--- /dev/null
+++ b/src/misc.h
@@ -0,0 +1,17 @@
+#include<stdlib.h>
+#include<stdio.h>
+#ifndef MISC
+#define MISC
+
+char *strsub(char *s1, const char *s2, int start);
+
+char skip_all_space(FILE *in_file);
+
+char skip_non_newline(FILE *in_file);
+
+
+char skip_newlines(FILE *in_file);
+
+char skip_non_newline_space(FILE *in_file);
+
+#endif
diff --git a/src/normal.c b/src/normal.c
new file mode 100644
index 0000000..cac2385
--- /dev/null
+++ b/src/normal.c
@@ -0,0 +1,101 @@
+#include "global.h"
+#include "math.h"
+double normal_01_cdf ( double x )
+
+//******************************************************************************
+//
+// Purpose:
+//
+// NORMAL_01_CDF evaluates the Normal 01 CDF.
+//
+// Modified:
+//
+// 10 February 1999
+//
+// Author:
+//
+// John Burkardt
+//
+// Reference:
+//
+// A G Adams,
+// Areas Under the Normal Curve,
+// Algorithm 39,
+// Computer j.,
+// Volume 12, pages 197-198, 1969.
+//
+// Parameters:
+//
+// Input, double X, the argument of the CDF.
+//
+// Output, double CDF, the value of the CDF.
+//
+{
+ double a1 = 0.398942280444E+00;
+ double a2 = 0.399903438504E+00;
+ double a3 = 5.75885480458E+00;
+ double a4 = 29.8213557808E+00;
+ double a5 = 2.62433121679E+00;
+ double a6 = 48.6959930692E+00;
+ double a7 = 5.92885724438E+00;
+ double b0 = 0.398942280385E+00;
+ double b1 = 3.8052E-08;
+ double b2 = 1.00000615302E+00;
+ double b3 = 3.98064794E-04;
+ double b4 = 1.98615381364E+00;
+ double b5 = 0.151679116635E+00;
+ double b6 = 5.29330324926E+00;
+ double b7 = 4.8385912808E+00;
+ double b8 = 15.1508972451E+00;
+ double b9 = 0.742380924027E+00;
+ double b10 = 30.789933034E+00;
+ double b11 = 3.99019417011E+00;
+ double cdf;
+ double q;
+ double y;
+//
+// |X| <= 1.28.
+//
+ if ( fabs ( x ) <= 1.28 )
+ {
+ y = 0.5 * x * x;
+
+ q = 0.5 - fabs ( x ) * ( a1 - a2 * y / ( y + a3 - a4 / ( y + a5
+ + a6 / ( y + a7 ) ) ) );
+//
+// 1.28 < |X| <= 12.7
+//
+ }
+ else if ( fabs ( x ) <= 12.7 )
+ {
+ y = 0.5 * x * x;
+
+ q = exp ( - y ) * b0 / ( fabs ( x ) - b1
+ + b2 / ( fabs ( x ) + b3
+ + b4 / ( fabs ( x ) - b5
+ + b6 / ( fabs ( x ) + b7
+ - b8 / ( fabs ( x ) + b9
+ + b10 / ( fabs ( x ) + b11 ) ) ) ) ) );
+//
+// 12.7 < |X|
+//
+ }
+ else
+ {
+ q = 0.0;
+ }
+//
+// Take account of negative X.
+//
+ if ( x < 0.0 )
+ {
+ cdf = q;
+ }
+ else
+ {
+ cdf = 1.0 - q;
+ }
+
+ return cdf;
+}
+//**********************************************************************
diff --git a/src/normal.h b/src/normal.h
new file mode 100644
index 0000000..53cefc9
--- /dev/null
+++ b/src/normal.h
@@ -0,0 +1,5 @@
+#ifndef NORM
+#define NORMAL
+double normal_01_cdf ( double x );
+
+#endif
diff --git a/src/options.h b/src/options.h
new file mode 100644
index 0000000..87dc7c6
--- /dev/null
+++ b/src/options.h
@@ -0,0 +1,33 @@
+#ifndef OPTIONS
+#define OPTIONS
+
+typedef struct{
+
+
+ alignmentClass alignKind;
+ fileType inFile;
+
+ char seqFile[MAX_SIZE+1];
+
+ cbool doPerm;
+ int ntrials;
+ cbool otherStats;
+
+ double winSize;
+ int k;
+
+ cbool verbose;
+
+ cbool printMatrix;
+ int graphType;
+ cbool embellish;
+
+ cbool printBreakpoints;
+ int breakWindow;
+
+
+
+} options;
+
+
+#endif
diff --git a/src/pairScore.c b/src/pairScore.c
new file mode 100644
index 0000000..de7afca
--- /dev/null
+++ b/src/pairScore.c
@@ -0,0 +1,207 @@
+/*
+ Copyright (c)2005, Trevor Bruen
+ All rights reserved.
+
+ Any feedback is very welcome.
+ email: trevor at mcb.mcgill.ca
+*/
+
+#include "global.h"
+#include "mem.h"
+struct node_struct{
+
+ int neighbourindex;
+ struct node_struct *next;
+};
+
+typedef struct node_struct node;
+
+
+
+/* Input: alignment - ordered by site (each site [0,k] + negative for gap)
+ site_states - number of states at each state
+ char_a - a site index
+ char_b - another site index
+ num_sites - total number of sites
+ num_taxa - number of taxa
+ Output:
+ incompatibility - (pars_score - #states)+2
+ */
+int pair_score( align_type **alignment, int *site_states,int char_a, int char_b, int num_sites, int num_taxa)
+{
+ /* Keep both list & matrix - one for quick adding, other for quick DFS */
+ node **adjacency_list;
+ cbool **adjacency_matrix;
+ node *cur_node,*new_node,*next_node;
+ int char_a_states = site_states[char_a];
+ int char_b_states = site_states[char_b];
+ int total_states = char_a_states+char_b_states;
+ int char_a_val,char_b_val,i,j,edge_count;
+
+ /* For DFS */
+ node **DFS_adjacency;
+ int* array_stack;
+ cbool* marked;
+ int potential_neighbour;
+ cbool has_valid_neighbour;
+ int comp_count;
+ int top=0,cur_vertex=0;
+
+ /* For score */
+
+ int inc_score=-1;
+
+
+ /* Initialize list and matrix */
+ adjacency_list=(node **)mmalloc(total_states * sizeof(node *));
+ for(i=0;i<total_states;i++)
+ adjacency_list[i]=NULL;
+
+ adjacency_matrix=(cbool **)mmalloc(total_states * sizeof(cbool *) );
+ for(i=0;i<total_states;i++)
+ {
+ adjacency_matrix[i]=(cbool *)mmalloc(total_states * sizeof(cbool));
+ }
+
+ for(i=0;i<total_states;i++)
+ {
+ for(j=0;j<total_states;j++)
+ {
+ adjacency_matrix[i][j]=FALSE;
+ }
+ }
+
+
+ /* Initialize stuff for DFS... */
+ DFS_adjacency=(node **)mmalloc(total_states * sizeof(node *) );
+ array_stack=(int *)mmalloc( (total_states) * sizeof(int));
+ marked=(cbool *)mmalloc(total_states * sizeof(cbool) );
+
+
+ /* Build adjacency list */
+ edge_count=0;
+
+
+ for(i=0;i<num_taxa;i++)
+ {
+ char_a_val=(int)(alignment[char_a][i]);
+ /* Number vertices [0...char_a_states-1] then [char_a_states..total_states] */
+ char_b_val=(int)(alignment[char_b][i]);
+
+ /* Add the edge - if necessary */
+
+ if((char_a_val <= MAX_STATE) && (char_b_val <= MAX_STATE))
+ {
+ /* Increase index to "global index" */
+ char_b_val=char_b_val+char_a_states;
+
+
+ if(adjacency_matrix[char_a_val][char_b_val]==FALSE)
+ {
+
+ /* Update symmetric adjacency matrix (undirected graph)*/
+ adjacency_matrix[char_a_val][char_b_val]=TRUE;
+ adjacency_matrix[char_b_val][char_a_val]=TRUE;
+ edge_count++;
+
+ /* Add to adjacency lists */
+ cur_node=adjacency_list[char_a_val];
+ new_node=(node *)mmalloc(sizeof(node) );
+ new_node->neighbourindex=char_b_val;
+ new_node->next=cur_node;
+ adjacency_list[char_a_val]=new_node;
+
+ /* And other list */
+ cur_node=adjacency_list[char_b_val];
+ new_node=(node *)mmalloc(sizeof(node) );
+ new_node->neighbourindex=char_a_val;
+ new_node->next=cur_node;
+ adjacency_list[char_b_val]=new_node;
+
+
+ }
+ }
+ }
+ /* Now do DFS to count components */
+
+ for(i=0;i<total_states;i++)
+ {
+ marked[i]=FALSE;
+ DFS_adjacency[i]=adjacency_list[i];
+ }
+
+ top=-1;
+
+ comp_count=0;
+
+ for(i=0;i<total_states;i++)
+ {
+ if(!marked[i])
+ {
+
+ comp_count++;
+ /* "push" index onto stack */
+ array_stack[++top]=i;
+
+ while(top >= 0)
+ {
+ cur_vertex=array_stack[top];
+ marked[cur_vertex]=TRUE;
+ has_valid_neighbour=FALSE;
+ while((DFS_adjacency[cur_vertex] != NULL) && (has_valid_neighbour == FALSE))
+ {
+ potential_neighbour=(DFS_adjacency[cur_vertex])->neighbourindex;
+ if(marked[potential_neighbour]==FALSE)
+ {
+
+ array_stack[++top]=potential_neighbour;
+ has_valid_neighbour=TRUE;
+ }
+ else
+ {
+ DFS_adjacency[cur_vertex]=DFS_adjacency[cur_vertex]->next;
+ }
+ }
+
+ if(has_valid_neighbour == FALSE)
+ {
+ top--;
+ }
+
+ }
+ }
+ }
+
+
+ /* De allocate adjacency list */
+ for(i=0;i<total_states;i++)
+ {
+
+ cur_node=adjacency_list[i];
+
+ while(cur_node!=NULL)
+ {
+ next_node=cur_node->next;
+ free(cur_node);
+ cur_node=next_node;
+ }
+ /* free(cur_node); ? */
+ free(adjacency_matrix[i]);
+ }
+
+ free(adjacency_list);
+ free(DFS_adjacency);
+ free(adjacency_matrix);
+
+ free(marked);
+ free(array_stack);
+
+ /* For the pairwise incompatibility */
+
+ inc_score=edge_count-total_states+comp_count;
+
+ return inc_score;
+}
+
+
+
diff --git a/src/pairScore.h b/src/pairScore.h
new file mode 100644
index 0000000..6ae938e
--- /dev/null
+++ b/src/pairScore.h
@@ -0,0 +1,6 @@
+#ifndef PAIRSCORE
+#define PAIRSCORE
+
+int pair_score( align_type **alignment, int *site_states,int char_a, int char_b, int num_sites, int num_taxa);
+
+#endif
diff --git a/src/phylip.c b/src/phylip.c
new file mode 100644
index 0000000..3ed7024
--- /dev/null
+++ b/src/phylip.c
@@ -0,0 +1,280 @@
+/*
+ Copyright (c)2005, Trevor Bruen
+ All rights reserved.
+
+ Any feedback is very welcome.
+ email: trevor at mcb.mcgill.ca
+*/
+
+#include "global.h"
+#include "mem.h"
+#include "phylip.h"
+#include "misc.h"
+
+/* Read strict phylip name. in_file should point to beginning of line */
+void read_strict_name(FILE *in_file,char *name, int capacity)
+{
+ int i;
+ char ch='\0';
+ for(i=0;(i<PHYLIP_SIZE) && (ch!=EOF);i++)
+ {
+ ch=fgetc(in_file);
+ name[i]=ch;
+ }
+
+ if(ch==EOF)
+ error("Taxa name appears to be cut off\n");
+
+ /* Insert many null chars to be safe */
+ for(;i<=capacity;i++)
+ name[i]='\0';
+
+}
+
+
+/* Read relaxed phylip name. in_file should point to beginning of line */
+void read_relaxed_name(FILE *in_file,char *name, int capacity)
+{
+ int i=0;
+ char ch='\0',next_ch;
+ cbool double_space=FALSE;
+
+ while((i<capacity) && (ch!=EOF) && (double_space == FALSE))
+ {
+ ch=fgetc(in_file);
+
+ /* Check for end of string.. messy */
+ if(isspace(ch))
+ {
+
+ next_ch=fgetc(in_file);
+ if(next_ch != EOF)
+ {
+ if(isspace(next_ch))
+ double_space=TRUE;
+ else if(next_ch != EOF)
+ ungetc(next_ch,in_file);
+ }
+ }
+ if(double_space==FALSE)
+ name[i++]=ch;
+ }
+
+
+
+ if(ch==EOF)
+ error("Taxa name appears to be cut off\n");
+
+ /* Insert many null chars to be safe */
+ for(;i<=capacity;i++)
+ name[i]='\0';
+
+}
+
+
+void write_phylip(FILE* cur_stream, cbool strict, char **taxa_names,align_type **alignment, int num_taxa,int num_sites)
+{
+ int i;
+ int j;
+
+ fprintf(cur_stream,"%d %d\n",num_taxa,num_sites);
+ for(i=0;i<num_taxa;i++)
+ {
+ if(strict == TRUE)
+ {
+ for(j=0;j<10;j++)
+ {
+ if(taxa_names[i][j] != '\0')
+ fprintf(cur_stream,"%c",taxa_names[i][j]);
+ else
+ fprintf(cur_stream," ");
+ }
+ fprintf(cur_stream," ");
+ }
+ else
+ fprintf(cur_stream,"%s\n",taxa_names[i]);
+
+ for(j=0;j<num_sites;j++)
+ {
+/* if((int)alignment[i][j] <=MAX_STATE ) */
+ fprintf(cur_stream,"%c",((char)(alignment[i][j] + CHAR_START)));
+/* else if((int)alignment[i][j] == MISSING_STATE) */
+/* fprintf(cur_stream,"%c",MISSING); */
+/* else if((int)alignment[i][j]== GAP_STATE) */
+/* fprintf(cur_stream,"%c",GAP); */
+
+ }
+ fprintf(cur_stream,"\n");
+ }
+
+
+}
+
+
+int read_seq_bit(FILE *in_file, int base_limit, align_type* states, int index, int *num_bases)
+{
+ int bases_read=num_bases[index];
+ char ch;
+ char s[250];
+
+ ch=fgetc(in_file);
+
+
+ while(ch != EOF && ch != '\n' && bases_read<base_limit)
+ {
+ if(!isspace(ch))
+ {
+ /* if(ch == MISSING) */
+/* { */
+/* states[bases_read]=(align_type)MISSING_STATE; */
+/* } */
+/* else if(ch == GAP) */
+/* { */
+/* states[bases_read]=(align_type)GAP_STATE; */
+/* } */
+/* else */
+/* { */
+ if((ch < CHAR_START) || (ch > CHAR_END))
+ {
+ sprintf(s,"Illegal state encountered: %c\n",ch);
+ error(s);
+ }
+ else
+ {
+ states[bases_read]=(align_type)(toupper(ch)-CHAR_START);
+ }
+ /* }*/
+ bases_read++;
+ }
+ else
+ {
+ ch=skip_non_newline_space(in_file);
+ }
+ ch=fgetc(in_file);
+ }
+
+ if(bases_read >= base_limit)
+ {
+
+ if((ch != EOF) && !isspace(ch))
+ {
+
+ sprintf(s,"Seems like too many bases in seq %d.\nMake sure file is in Phylip file format.\nTry also using the strict and relaxed options (-s and -r)",(index+1));
+ error(s);
+ }
+
+ }
+
+ num_bases[index]=bases_read;
+ return ch;
+
+}
+
+/* In: file_name - name of file with sequences
+ strict - taxa names are either 10 chars or 1--MAX_SIZE chars
+ in first case first 10 chars name
+ in second case first x chars without 2 spaces are name
+ (cannot be longer than MAX_SIZE)
+ Out: taxa_name - name of all the taxa
+ alignment - ordered by taxa
+ num_taxa
+ num_sites
+
+ Note: Line with
+ 10 200
+ seq1234567 ADSFS
+
+ is treated same as:
+ 10 2000
+ [spaces]seq1234567 ADSFS
+*/
+
+
+void read_phylip(const char* file_name, cbool strict, char ***taxa_names, align_type ***alignment, int *num_taxa, int *num_sites)
+{
+ char s[250];
+ FILE *in_file;
+ /* Keep track of how far we are in each sequence... */
+ int *seq_counter;
+ int i;
+ int cur_seq=0;
+ char ch;
+
+ in_file=fopen(file_name,"r");
+ if(in_file == NULL)
+ {
+ sprintf(s,"Could not open file %s",file_name);
+ error(s);
+ }
+
+
+
+ if(fscanf(in_file,"%d%d",num_taxa,num_sites)==EOF)
+ error("Could not read number of taxa and/or number of sites. Make sure file is in phylip format\n");
+
+ fprintf(stdout,"Allocating space for %d taxa and %d sites\n",*num_taxa,*num_sites);
+
+ /* Allocate space for sequence and names*/
+ (*taxa_names)=(char **)mcalloc((*num_taxa) , sizeof(char *) );
+
+ (*alignment)=(align_type **)mcalloc((*num_taxa) , sizeof(align_type *) );
+ seq_counter=(int *)mmalloc((*num_taxa) * sizeof(int) );
+
+
+ for(i=0;i<(*num_taxa);i++)
+ {
+ (*taxa_names)[i]=(char *)mcalloc((MAX_SIZE+1) , sizeof(char) );
+ (*alignment)[i]=(align_type *)mcalloc((*num_sites) , sizeof(align_type) );
+ seq_counter[i]=0;
+ }
+
+
+ /* Read in name + first part of sequence */
+ for(i=0;i<(*num_taxa);i++)
+ {
+ /* Advance to first non--space */
+ if(skip_non_newline_space(in_file)== EOF)
+ error("Cannot read sequences. Make sure file is in phylip format\n");
+ if(skip_newlines(in_file)== EOF)
+ error("Cannot read sequences. Make sure file is in phylip format\n");
+
+ if(strict == TRUE)
+ {
+ read_strict_name(in_file, (*taxa_names)[i],MAX_SIZE);
+ }
+ else
+ {
+ read_relaxed_name(in_file,(*taxa_names)[i],MAX_SIZE);
+ }
+
+ /*fprintf(stderr,"Read taxa:%s.\n",(*taxa_names)[i]);*/
+ ch=skip_all_space(in_file);
+
+ read_seq_bit(in_file, (*num_sites), (*alignment)[i],i,seq_counter);
+
+ }
+
+ /*fprintf(stderr,"Checking for more...\n");*/
+ /* For interleaved format ... */
+ ch=skip_all_space(in_file);
+ while(ch!= EOF)
+ {
+
+ read_seq_bit(in_file, (*num_sites),(*alignment)[cur_seq],cur_seq,seq_counter);
+
+ cur_seq++;
+ cur_seq=cur_seq % (*num_taxa);
+ ch=skip_all_space(in_file);
+
+ }
+
+ /* Check size of sequences */
+ for(i=0;i<(*num_taxa);i++)
+ if(seq_counter[i] != (*num_sites))
+ {
+ sprintf(s,"Number of sites read does not match number of sites expected for seq %s",(*taxa_names)[cur_seq]);
+ }
+
+ free(seq_counter);
+}
+
diff --git a/src/phylip.h b/src/phylip.h
new file mode 100644
index 0000000..2a59aac
--- /dev/null
+++ b/src/phylip.h
@@ -0,0 +1,28 @@
+#ifndef PHYLIP
+#define PHYLIP
+
+/* char skip_all_space(FILE *in_file); */
+
+
+/* char skip_newlines(FILE *in_file); */
+
+/* char skip_non_newline_space(FILE *in_file); */
+
+
+
+/* void read_strict_name(FILE *in_file,char *name, int capacity); */
+
+
+
+
+/* void read_relaxed_name(FILE *in_file,char *name, int capacity); */
+
+/* int read_seq_bit(FILE *in_file, int base_limit, align_type* states,int index, int *num_bases); */
+
+
+
+void read_phylip(const char* file_name, cbool strict, char ***taxa_names, align_type ***alignment, int *num_taxa, int *num_sites);
+
+void write_phylip(FILE* cur_stream, cbool strict, char **taxa_names,align_type **alignment, int num_taxa,int num_sites);
+
+#endif
diff --git a/src/ppma_2_bmp/Makefile b/src/ppma_2_bmp/Makefile
new file mode 100755
index 0000000..08f7fb8
--- /dev/null
+++ b/src/ppma_2_bmp/Makefile
@@ -0,0 +1,18 @@
+# compiler
+CXX = g++
+CXXFLAGS = -O3
+
+# targets
+default : ppma_2_bmp
+
+ppma_2_bmp:
+ $(CXX) $(CXXFLAGS) -o ppma_2_bmp ppma_io.C bmp_io.C ppma_2_bmp.C -lm
+
+clean : FORCE
+ rm -f *.o
+ rm -f Phi
+
+FORCE:
+
+
+
diff --git a/src/ppma_2_bmp/bmp_io.C b/src/ppma_2_bmp/bmp_io.C
new file mode 100644
index 0000000..1a56cba
--- /dev/null
+++ b/src/ppma_2_bmp/bmp_io.C
@@ -0,0 +1,2848 @@
+# include <cstdlib>
+# include <iostream>
+# include <iomanip>
+# include <fstream>
+
+using namespace std;
+
+# include "bmp_io.H"
+
+//
+// BMP_BYTE_SWAP controls how the program assumes that the bytes in
+// multi-byte data are ordered.
+//
+// "true" is the correct value to use when running on a little-endian machine,
+// and "false" is for big-endian.
+//
+
+static bool bmp_byte_swap = true;
+
+//****************************************************************************
+
+bool bmp_byte_swap_get ( void )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_BYTE_SWAP_GET returns the internal value of BMP_BYTE_SWAP.
+//
+// Modified:
+//
+// 26 February 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Output, bool BMP_BYTE_SWAP_GET, the internal value of BMP_BYTE_SWAP.
+//
+{
+ return bmp_byte_swap;
+}
+//****************************************************************************
+
+void bmp_byte_swap_set ( bool value )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_BYTE_SWAP_SET sets the internal value of BMP_BYTE_SWAP.
+//
+// Modified:
+//
+// 26 February 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Input, bool VALUE, the new value of BMP_BYTE_SWAP.
+//
+{
+ bmp_byte_swap = value;
+
+ return;
+}
+//****************************************************************************
+
+bool bmp_08_data_read ( ifstream &file_in, unsigned long int width, long int height,
+ unsigned char *rarray )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_08_DATA_READ reads 8 bit image data of the BMP file.
+//
+// Discussion:
+//
+// On output, the RGB information in the file has been copied into the
+// R, G and B arrays.
+//
+// Thanks to Peter Kionga-Kamau for pointing out an error in the
+// previous implementation.
+//
+// The standard ">>" operator cannot be used to transfer data, because
+// it will be deceived by characters that "look like" new lines.
+//
+// Thanks to Kelly Anderson for pointing out that the program did not handle
+// monochrome images, but could easily be modified to do so.
+//
+// Modified:
+//
+// 01 April 2005
+//
+// Author:
+//
+// Kelly Anderson
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, ifstream &FILE_IN, a reference to the input file.
+//
+// Input, unsigned long int WIDTH, the X dimension of the image.
+//
+// Input, long int HEIGHT, the Y dimension of the image.
+//
+// Input, unsigned char *RARRAY, a pointer to the red color arrays.
+//
+// Output, bool BMP_08_DATA_READ, is true if an error occurred.
+//
+{
+ char c;
+ bool error;
+ int i;
+ unsigned char *indexr;
+ int j;
+ int numbyte;
+ int padding;
+//
+// Set the padding.
+//
+ padding = ( 4 - ( ( 1 * width ) % 4 ) ) % 4;
+
+ indexr = rarray;
+ numbyte = 0;
+
+ for ( j = 0; j < abs ( height ); j++ )
+ {
+ for ( i = 0; i < width; i++ )
+ {
+ file_in.read ( &c, 1 );
+
+ error = file_in.eof();
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_08_DATA_READ: Fatal error!\n";
+ cout << " Failed reading R for pixel (" << i << "," << j << ").\n";
+ return error;
+ }
+
+ *indexr = ( unsigned char ) c;
+ numbyte = numbyte + 1;
+ indexr = indexr + 1;
+ }
+//
+// If necessary, read a few padding characters.
+//
+ for ( i = 0; i < padding; i++ )
+ {
+
+ file_in.read ( &c, 1 );
+
+ error = file_in.eof();
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_08_DATA_READ - Warning!\n";
+ cout << " Failed while reading padding character " << i << "\n";
+ cout << " of total " << padding << " characters\n";
+ cout << " at the end of line " << j << "\n";
+ cout << "\n";
+ cout << " This is a minor error.\n";
+ return false;
+ }
+ }
+ }
+
+ return false;
+}
+//****************************************************************************
+
+void bmp_08_data_write ( ofstream &file_out, unsigned long int width,
+ long int height, unsigned char *rarray )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_08_DATA_WRITE writes 8 bit image data to a BMP file.
+//
+// Discussion:
+//
+// This routine does not seem to be performing properly. The monochrome
+// images it creates cannot be read by the XV program, which says that
+// they seem to have been prematurely truncated.
+//
+// The BMP format requires that each horizontal line be a multiple of 4 bytes.
+// If the data itself does not have a WIDTH that is a multiple of 4, then
+// the file must be padded with a few extra bytes so that each line has the
+// appropriate length. This information, and the corresponding corrective
+// code, was supplied by Lee Mulcahy.
+//
+// Modified:
+//
+// 02 April 2005
+//
+// Author:
+//
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, ofstream &FILE_OUT, a reference to the output file.
+//
+// Input, unsigned long int WIDTH, the X dimension of the image in bytes.
+//
+// Input, long int HEIGHT, the Y dimension of the image in bytes.
+//
+// Input, unsigned char *RARRAY, pointer to the red color array.
+//
+{
+ int i;
+ unsigned char *indexr;
+ int j;
+ int padding;
+//
+// Set the padding.
+//
+ padding = ( 4 - ( ( 1 * width ) % 4 ) ) % 4;
+
+ indexr = rarray;
+
+ for ( j = 0; j < abs ( height ); j++ )
+ {
+ for ( i = 0; i < width; i++ )
+ {
+ file_out << *indexr;
+ indexr = indexr + 1;
+ }
+
+ for ( i = 0; i < padding; i++ )
+ {
+ file_out << 0;
+ }
+ }
+
+ return;
+}
+//****************************************************************************
+
+bool bmp_24_data_read ( ifstream &file_in, unsigned long int width, long int height,
+ unsigned char *rarray, unsigned char *garray, unsigned char *barray )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_24_DATA_READ reads 24 bit image data of the BMP file.
+//
+// Discussion:
+//
+// On output, the RGB information in the file has been copied into the
+// R, G and B arrays.
+//
+// Thanks to Peter Kionga-Kamau for pointing out an error in the
+// previous implementation.
+//
+// The standard ">>" operator cannot be used to transfer data, because
+// it will be deceived by characters that "look like" new lines.
+//
+// Modified:
+//
+// 11 December 2004
+//
+// Author:
+//
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, ifstream &FILE_IN, a reference to the input file.
+//
+// Input, unsigned long int WIDTH, the X dimension of the image.
+//
+// Input, long int HEIGHT, the Y dimension of the image.
+//
+// Input, unsigned char *RARRAY, *GARRAY, *BARRAY, pointers to the
+// red, green and blue color arrays.
+//
+// Output, bool BMP_24_DATA_READ, is true if an error occurred.
+//
+{
+ char c;
+ bool error;
+ int i;
+ unsigned char *indexb;
+ unsigned char *indexg;
+ unsigned char *indexr;
+ int j;
+ int numbyte;
+ int padding;
+//
+// Set the padding.
+//
+ padding = ( 4 - ( ( 3 * width ) % 4 ) ) % 4;
+
+ indexr = rarray;
+ indexg = garray;
+ indexb = barray;
+ numbyte = 0;
+
+ for ( j = 0; j < abs ( height ); j++ )
+ {
+ for ( i = 0; i < width; i++ )
+ {
+
+ file_in.read ( &c, 1 );
+
+ error = file_in.eof();
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_24_DATA_READ: Fatal error!\n";
+ cout << " Failed reading B for pixel (" << i << "," << j << ").\n";
+ return error;
+ }
+
+ *indexb = ( unsigned char ) c;
+ numbyte = numbyte + 1;
+ indexb = indexb + 1;
+
+ file_in.read ( &c, 1 );
+
+ error = file_in.eof();
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_24_DATA_READ: Fatal error!\n";
+ cout << " Failed reading G for pixel (" << i << "," << j << ").\n";
+ return error;
+ }
+
+ *indexg = ( unsigned char ) c;
+ numbyte = numbyte + 1;
+ indexg = indexg + 1;
+
+ file_in.read ( &c, 1 );
+
+ error = file_in.eof();
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_24_DATA_READ: Fatal error!\n";
+ cout << " Failed reading R for pixel (" << i << "," << j << ").\n";
+ return error;
+ }
+
+ *indexr = ( unsigned char ) c;
+ numbyte = numbyte + 1;
+ indexr = indexr + 1;
+ }
+//
+// If necessary, read a few padding characters.
+//
+ for ( i = 0; i < padding; i++ )
+ {
+
+ file_in.read ( &c, 1 );
+
+ error = file_in.eof();
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_24_DATA_READ - Warning!\n";
+ cout << " Failed while reading padding character " << i << "\n";
+ cout << " of total " << padding << " characters\n";
+ cout << " at the end of line " << j << "\n";
+ cout << "\n";
+ cout << " This is a minor error.\n";
+ return false;
+ }
+ }
+ }
+
+ return false;
+}
+//****************************************************************************
+
+void bmp_24_data_write ( ofstream &file_out, unsigned long int width,
+ long int height, unsigned char *rarray, unsigned char *garray,
+ unsigned char *barray )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_24_DATA_WRITE writes 24 bit image data to the BMP file.
+//
+// Discussion:
+//
+// The BMP format requires that each horizontal line be a multiple of 4 bytes.
+// If the data itself does not have a WIDTH that is a multiple of 4, then
+// the file must be padded with a few extra bytes so that each line has the
+// appropriate length. This information, and the corresponding corrective
+// code, was supplied by Lee Mulcahy.
+//
+// Modified:
+//
+// 11 December 2004
+//
+// Author:
+//
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, ofstream &FILE_OUT, a reference to the output file.
+//
+// Input, unsigned long int WIDTH, the X dimension of the image in bytes.
+//
+// Input, long int HEIGHT, the Y dimension of the image in bytes.
+//
+// Input, unsigned char *RARRAY, *GARRAY, *BARRAY, pointers to the red, green
+// and blue color arrays.
+//
+{
+ int i;
+ unsigned char *indexb;
+ unsigned char *indexg;
+ unsigned char *indexr;
+ int j;
+ int padding;
+//
+// Set the padding.
+//
+ padding = ( 4 - ( ( 3 * width ) % 4 ) ) % 4;
+
+ indexr = rarray;
+ indexg = garray;
+ indexb = barray;
+
+ for ( j = 0; j < abs ( height ); j++ )
+ {
+ for ( i = 0; i < width; i++ )
+ {
+ file_out << *indexb;
+ file_out << *indexg;
+ file_out << *indexr;
+
+ indexb = indexb + 1;
+ indexg = indexg + 1;
+ indexr = indexr + 1;
+ }
+
+ for ( i = 0; i < padding; i++ )
+ {
+ file_out << 0;
+ }
+ }
+
+ return;
+}
+//****************************************************************************
+
+void bmp_header1_print ( unsigned short int filetype,
+ unsigned long int filesize, unsigned short int reserved1,
+ unsigned short int reserved2, unsigned long int bitmapoffset )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_HEADER1_PRINT prints the header information of a BMP file.
+//
+// Discussion:
+//
+// The header comprises 14 bytes:
+//
+// 2 bytes FILETYPE; Magic number: "BM",
+// 4 bytes FILESIZE; Size of file in 32 byte integers,
+// 2 bytes RESERVED1; Always 0,
+// 2 bytes RESERVED2; Always 0,
+// 4 bytes BITMAPOFFSET. Starting position of image data, in bytes.
+//
+// Modified:
+//
+// 05 March 2004
+//
+// Author:
+//
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, unsigned short int FILETYPE, the file type.
+//
+// Input, unsigned long int FILESIZE, the file size.
+//
+// Input, unsigned short int RESERVED1, a reserved value.
+//
+// Input, unsigned short int RESERVED2, a reserved value.
+//
+// Input, unsigned long int BITMAPOFFSET, the bitmap offset.
+//
+{
+ cout << "\n";
+ cout << " Contents of BMP file header:\n";
+ cout << "\n";
+ cout << " FILETYPE = " << filetype << "\n";
+ cout << " FILESIZE = " << filesize << "\n";
+ cout << " RESERVED1 = " << reserved1 << "\n";
+ cout << " RESERVED2 = " << reserved2 << "\n";
+ cout << " BITMAPOFFSET = " << bitmapoffset << "\n";
+
+ return;
+}
+//****************************************************************************
+
+bool bmp_header1_read ( ifstream &file_in, unsigned short int *filetype,
+ unsigned long int *filesize, unsigned short int *reserved1,
+ unsigned short int *reserved2, unsigned long int *bitmapoffset )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_HEADER1_READ reads the header information of a BMP file.
+//
+// Discussion:
+//
+// The header comprises 14 bytes:
+//
+// 2 bytes FILETYPE; Magic number: "BM",
+// 4 bytes FILESIZE; Size of file in 32 byte integers,
+// 2 bytes RESERVED1; Always 0,
+// 2 bytes RESERVED2; Always 0,
+// 4 bytes BITMAPOFFSET. Starting position of image data, in bytes.
+//
+// Modified:
+//
+// 15 December 2004
+//
+// Author:
+//
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, ifstream &FILE_IN, a reference to the input file.
+//
+// Output, unsigned short int *FILETYPE, the file type.
+//
+// Output, unsigned long int *FILESIZE, the file size.
+//
+// Output, unsigned short int *RESERVED1, a reserved value.
+//
+// Output, unsigned short int *RESERVED2, a reserved value.
+//
+// Output, unsigned long int *BITMAPOFFSET, the bitmap offset.
+//
+{
+ bool error;
+ char i1;
+ char i2;
+//
+// Read FILETYPE.
+//
+ error = u_short_int_read ( filetype, file_in );
+
+ if ( error )
+ {
+ return error;
+ }
+//
+// If you are doing swapping, you have to reunswap the filetype, I think, JVB 15 December 2004.
+//
+ if ( bmp_byte_swap )
+ {
+ i1 = ( char ) ( *filetype / 256 );
+ i2 = ( char ) ( *filetype % 256 );
+ *filetype = i2 * 256 + i1;
+ }
+//
+// Read FILESIZE.
+//
+ error = u_long_int_read ( filesize, file_in );
+ if ( error )
+ {
+ return error;
+ }
+//
+// Read RESERVED1.
+//
+ error = u_short_int_read ( reserved1, file_in );
+ if ( error )
+ {
+ return error;
+ }
+//
+// Read RESERVED2.
+//
+ error = u_short_int_read ( reserved2, file_in );
+ if ( error )
+ {
+ return error;
+ }
+//
+// Read BITMAPOFFSET.
+//
+ error = u_long_int_read ( bitmapoffset, file_in );
+ if ( error )
+ {
+ return error;
+ }
+
+ error = false;
+ return error;
+}
+//****************************************************************************
+
+void bmp_header1_write ( ofstream &file_out, unsigned short int filetype,
+ unsigned long int filesize, unsigned short int reserved1,
+ unsigned short int reserved2, unsigned long int bitmapoffset )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_HEADER1_WRITE writes the header information to a BMP file.
+//
+// Discussion:
+//
+// The header comprises 14 bytes:
+//
+// 2 bytes FILETYPE; Magic number: "BM",
+// 4 bytes FILESIZE; Size of file in 32 byte integers,
+// 2 bytes RESERVED1; Always 0,
+// 2 bytes RESERVED2; Always 0,
+// 4 bytes BITMAPOFFSET. Starting position of image data, in bytes.
+//
+// Modified:
+//
+// 04 March 2004
+//
+// Author:
+//
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, ofstream &FILE_OUT, a reference to the output file.
+//
+// Input, unsigned short int FILETYPE, the file type.
+//
+// Input, unsigned long int FILESIZE, the file size.
+//
+// Input, unsigned short int RESERVED1, a reserved value.
+//
+// Input, unsigned short int RESERVED2, a reserved value.
+//
+// Input, unsigned long int BITMAPOFFSET, the bitmap offset.
+//
+{
+ u_short_int_write ( filetype, file_out );
+ u_long_int_write ( filesize, file_out );
+ u_short_int_write ( reserved1, file_out );
+ u_short_int_write ( reserved2, file_out );
+ u_long_int_write ( bitmapoffset, file_out );
+
+ return;
+}
+//****************************************************************************
+
+void bmp_header2_print ( unsigned long int size, unsigned long int width,
+ long int height,
+ unsigned short int planes, unsigned short int bitsperpixel,
+ unsigned long int compression, unsigned long int sizeofbitmap,
+ unsigned long int horzresolution, unsigned long int vertresolution,
+ unsigned long int colorsused, unsigned long int colorsimportant )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_HEADER2_PRINT prints the bitmap header information of a BMP file.
+//
+// Discussion:
+//
+// The bitmap header is 40 bytes long:
+//
+// 4 bytes SIZE; Size of this header ( = 40 bytes).
+// 4 bytes WIDTH; Image width, in pixels.
+// 4 bytes HEIGHT; Image height, in pixels.
+// (Pos/Neg, origin at bottom, top)
+// 2 bytes PLANES; Number of color planes (always 1).
+// 2 bytes BITSPERPIXEL; 1 to 24. 1, 4, 8, 16, 24 or 32.
+// 4 bytes COMPRESSION; 0, uncompressed; 1, 8 bit RLE;
+// 2, 4 bit RLE; 3, bitfields.
+// 4 bytes SIZEOFBITMAP; Size of bitmap in bytes. (0 if uncompressed).
+// 4 bytes HORZRESOLUTION; Pixels per meter. (Can be zero)
+// 4 bytes VERTRESOLUTION; Pixels per meter. (Can be zero)
+// 4 bytes COLORSUSED; Number of colors in palette. (Can be zero).
+// 4 bytes COLORSIMPORTANT. Minimum number of important colors. (Can be zero).
+//
+// Modified:
+//
+// 06 March 2004
+//
+// Author:
+//
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, unsigned short int SIZE, the size of this header in bytes.
+//
+// Input, unsigned long int WIDTH, the X dimension of the image.
+//
+// Input, long int HEIGHT, the Y dimension of the image.
+//
+// Input, unsigned short int PLANES, the number of color planes.
+//
+// Input, unsigned short int BITSPERPIXEL, color bits per pixel.
+//
+// Input, unsigned long int COMPRESSION, the compression option.
+//
+// Input, unsigned long int SIZEOFBITMAP, the size of the bitmap.
+//
+// Input, unsigned long int HORZRESOLUTION, the horizontal resolution.
+//
+// Input, unsigned long int VERTRESOLUTION, the vertical resolution.
+//
+// Input, unsigned long int COLORSUSED, the number of colors in the palette.
+//
+// Input, unsigned long int COLORSIMPORTANT, the minimum number of colors.
+//
+{
+ cout << "\n";
+ cout << " Contents of BMP file bitmap header:\n";
+ cout << "\n";
+ cout << " SIZE = " << size << "\n";
+ cout << " WIDTH = " << width << "\n";
+ cout << " HEIGHT = " << height << "\n";
+ cout << " PLANES = " << planes << "\n";
+ cout << " BITSPERPIXEL = " << bitsperpixel << "\n";
+ cout << " COMPRESSION = " << compression << "\n";
+ cout << " SIZEOFBITMAP = " << sizeofbitmap << "\n";
+ cout << " HORZRESOLUTION = " << horzresolution << "\n";
+ cout << " VERTRESOLUTION = " << vertresolution << "\n";
+ cout << " COLORSUSED = " << colorsused << "\n";
+ cout << " COLORSIMPORTANT = " << colorsimportant << "\n";
+
+ return;
+}
+//****************************************************************************
+
+bool bmp_header2_read ( ifstream &file_in, unsigned long int *size,
+ unsigned long int *width, long int *height,
+ unsigned short int *planes, unsigned short int *bitsperpixel,
+ unsigned long int *compression, unsigned long int *sizeofbitmap,
+ unsigned long int *horzresolution, unsigned long int *vertresolution,
+ unsigned long int *colorsused, unsigned long int *colorsimportant )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_HEADER2_READ reads the bitmap header information of a BMP file.
+//
+// Discussion:
+//
+// The bitmap header is 40 bytes long:
+//
+// 4 bytes SIZE; Size of this header, in bytes.
+// 4 bytes WIDTH; Image width, in pixels.
+// 4 bytes HEIGHT; Image height, in pixels.
+// (Pos/Neg, origin at bottom, top)
+// 2 bytes PLANES; Number of color planes (always 1).
+// 2 bytes BITSPERPIXEL; 1 to 24. 1, 4, 8, 16, 24 or 32.
+// 4 bytes COMPRESSION; 0, uncompressed; 1, 8 bit RLE;
+// 2, 4 bit RLE; 3, bitfields.
+// 4 bytes SIZEOFBITMAP; Size of bitmap in bytes. (0 if uncompressed).
+// 4 bytes HORZRESOLUTION; Pixels per meter. (Can be zero)
+// 4 bytes VERTRESOLUTION; Pixels per meter. (Can be zero)
+// 4 bytes COLORSUSED; Number of colors in palette. (Can be zero).
+// 4 bytes COLORSIMPORTANT. Minimum number of important colors. (Can be zero).
+//
+// Modified:
+//
+// 03 March 2004
+//
+// Author:
+//
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, ifstream &FILE_IN, a reference to the input file.
+//
+// Output, unsigned long int *SIZE, the size of this header in bytes.
+//
+// Output, unsigned long int *WIDTH, the X dimension of the image.
+//
+// Output, long int *HEIGHT, the Y dimension of the image.
+//
+// Output, unsigned short int *PLANES, the number of color planes.
+//
+// Output, unsigned short int *BITSPERPIXEL, color bits per pixel.
+//
+// Output, unsigned long int *COMPRESSION, the compression option.
+//
+// Output, unsigned long int *SIZEOFBITMAP, the size of the bitmap.
+//
+// Output, unsigned long int *HORZRESOLUTION, the horizontal resolution.
+//
+// Output, unsigned long int *VERTRESOLUTION, the vertical resolution.
+//
+// Output, unsigned long int *COLORSUSED, the number of colors in the palette.
+//
+// Output, unsigned long int *COLORSIMPORTANT, the minimum number of colors.
+//
+// Output, bool BMP_HEADER2_READ, is true if an error occurred.
+//
+{
+ unsigned char c1;
+ unsigned char c2;
+ bool error;
+//
+// Read SIZE, the size of the header in bytes.
+//
+ error = u_long_int_read ( size, file_in );
+ if ( error )
+ {
+ return error;
+ }
+//
+// Read WIDTH, the image width in pixels.
+//
+ error = u_long_int_read ( width, file_in );
+ if ( error )
+ {
+ return error;
+ }
+//
+// Read HEIGHT, the image height in pixels.
+//
+ error = long_int_read ( height, file_in );
+ if ( error )
+ {
+ return error;
+ }
+//
+// Read PLANES, the number of color planes.
+//
+ error = u_short_int_read ( planes, file_in );
+ if ( error )
+ {
+ return error;
+ }
+//
+// Read BITSPERPIXEL.
+//
+ error = u_short_int_read ( bitsperpixel, file_in );
+ if ( error )
+ {
+ return error;
+ }
+//
+// Read COMPRESSION.
+//
+ error = u_long_int_read ( compression, file_in );
+ if ( error )
+ {
+ return error;
+ }
+//
+// Read SIZEOFBITMAP.
+//
+ error = u_long_int_read ( sizeofbitmap, file_in );
+ if ( error )
+ {
+ return error;
+ }
+//
+// Read HORZRESOLUTION.
+//
+ error = u_long_int_read ( horzresolution, file_in );
+ if ( error )
+ {
+ return error;
+ }
+//
+// Read VERTRESOLUTION.
+//
+ error = u_long_int_read ( vertresolution, file_in );
+ if ( error )
+ {
+ return error;
+ }
+//
+// Read COLORSUSED.
+//
+ error = u_long_int_read ( colorsused, file_in );
+ if ( error )
+ {
+ return error;
+ }
+//
+// Read COLORSIMPORTANT.
+//
+ error = u_long_int_read ( colorsimportant, file_in );
+ if ( error )
+ {
+ return error;
+ }
+
+ error = false;
+ return error;
+}
+//****************************************************************************
+
+void bmp_header2_write ( ofstream &file_out, unsigned long int size,
+ unsigned long int width, long int height,
+ unsigned short int planes, unsigned short int bitsperpixel,
+ unsigned long int compression, unsigned long int sizeofbitmap,
+ unsigned long int horzresolution, unsigned long int vertresolution,
+ unsigned long int colorsused, unsigned long int colorsimportant )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_HEADER2_WRITE writes the bitmap header information to a BMP file.
+//
+// Discussion:
+//
+// Thanks to Mark Cave-Ayland, mca198 at ecs.soton.ac.uk, for pointing out an
+// error which caused the code to write one too many long ints, 19 May 2001.
+//
+// The bitmap header is 40 bytes long:
+//
+// 4 bytes SIZE; Size of this header, in bytes.
+// 4 bytes WIDTH; Image width, in pixels.
+// 4 bytes HEIGHT; Image height, in pixels.
+// (Pos/Neg, origin at bottom, top)
+// 2 bytes PLANES; Number of color planes (always 1).
+// 2 bytes BITSPERPIXEL; 1 to 24. 1, 4, 8, 16, 24 or 32.
+// 4 bytes COMPRESSION; 0, uncompressed; 1, 8 bit RLE;
+// 2, 4 bit RLE; 3, bitfields.
+// 4 bytes SIZEOFBITMAP; Size of bitmap in bytes. (0 if uncompressed).
+// 4 bytes HORZRESOLUTION; Pixels per meter. (Can be zero)
+// 4 bytes VERTRESOLUTION; Pixels per meter. (Can be zero)
+// 4 bytes COLORSUSED; Number of colors in palette. (Can be zero).
+// 4 bytes COLORSIMPORTANT. Minimum number of important colors. (Can be zero).
+//
+// Modified:
+//
+// 03 March 2004
+//
+// Author:
+//
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, ofstream &FILE_OUT, a reference to the output file.
+//
+// Input, unsigned long int SIZE, the size of this header in bytes.
+//
+// Input, unsigned long int WIDTH, the X dimensions of the image.
+//
+// Input, long int HEIGHT, the Y dimensions of the image.
+//
+// Input, unsigned short int PLANES, the number of color planes.
+//
+// Input, unsigned short int BITSPERPIXEL, color bits per pixel.
+//
+// Input, unsigned long int COMPRESSION, the compression option.
+//
+// Input, unsigned long int SIZEOFBITMAP, the size of the bitmap.
+//
+// Input, unsigned long int HORZRESOLUTION, the horizontal resolution.
+//
+// Input, unsigned long int VERTRESOLUTION, the vertical resolution.
+//
+// Input, unsigned long int COLORSUSED, the number of colors in the palette.
+//
+// Input, unsigned long int COLORSIMPORTANT, the minimum number of colors.
+//
+{
+ u_long_int_write ( size, file_out );
+ u_long_int_write ( width, file_out );
+ long_int_write ( height, file_out );
+ u_short_int_write ( planes, file_out );
+ u_short_int_write ( bitsperpixel, file_out );
+ u_long_int_write ( compression, file_out );
+ u_long_int_write ( sizeofbitmap, file_out );
+ u_long_int_write ( horzresolution, file_out );
+ u_long_int_write ( vertresolution, file_out );
+ u_long_int_write ( colorsused, file_out );
+ u_long_int_write ( colorsimportant, file_out );
+
+ return;
+}
+//****************************************************************************
+
+void bmp_palette_print ( unsigned long int colorsused,
+ unsigned char *rparray, unsigned char *gparray, unsigned char *bparray,
+ unsigned char *aparray )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_PALETTE_PRINT prints the palette data in a BMP file.
+//
+// Modified:
+//
+// 05 March 2004
+//
+// Author:
+//
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, unsigned long int COLORSUSED, the number of colors in the palette.
+//
+// Input, unsigned char *RPARRAY, *GPARRAY, *BPARRAY, *APARRAY, pointers to the
+// red, green, blue and transparency palette arrays.
+//
+{
+ int i;
+ unsigned char *indexa;
+ unsigned char *indexb;
+ unsigned char *indexg;
+ unsigned char *indexr;
+
+ cout << "\n";
+ cout << " Palette information from BMP file:\n";
+ cout << "\n";
+
+ if ( colorsused < 1 )
+ {
+ cout << " There are NO colors defined for the palette.\n";
+ return;
+ }
+
+ indexr = rparray;
+ indexg = gparray;
+ indexb = bparray;
+ indexa = aparray;
+
+ cout << "\n";
+ cout << " Color Blue Green Red Trans\n";
+ cout << "\n";
+
+ for ( i = 0; i < colorsused; i++ )
+ {
+ cout << setw(6) << i << " "
+ << setw(6) << *indexb << " "
+ << setw(6) << *indexg << " "
+ << setw(6) << *indexr << " "
+ << setw(6) << *indexa << "\n";
+
+ indexb = indexb + 1;
+ indexg = indexg + 1;
+ indexr = indexr + 1;
+ indexa = indexa + 1;
+
+ }
+
+ return;
+}
+//****************************************************************************
+
+bool bmp_palette_read ( ifstream &file_in, unsigned long int colorsused,
+ unsigned char *rparray, unsigned char *gparray, unsigned char *bparray,
+ unsigned char *aparray )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_PALETTE_READ reads the palette information of a BMP file.
+//
+// Discussion:
+//
+// There are COLORSUSED colors listed. For each color, the values of
+// (B,G,R,A) are listed, where A is a quantity reserved for future use.
+//
+// Modified:
+//
+// 05 March 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, ifstream &FILE_IN, a reference to the input file.
+//
+// Input, unsigned long int COLORSUSED, the number of colors in the palette.
+//
+// Input, unsigned char *RPARRAY, *GPARRAY, *BPARRAY, *APARRAY pointers to the
+// red, green, blue and transparency palette arrays.
+//
+// Output, bool BMP_PALETTE_READ, is true if an error occurred.
+//
+{
+ char c;
+ bool error;
+ int i;
+ unsigned char *indexa;
+ unsigned char *indexb;
+ unsigned char *indexg;
+ unsigned char *indexr;
+
+ indexr = rparray;
+ indexg = gparray;
+ indexb = bparray;
+ indexa = aparray;
+
+ for ( i = 0; i < colorsused; i++ )
+ {
+
+ file_in.read ( &c, 1 );
+
+ error = file_in.eof();
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_PALETTE_READ: Fatal error!\n";
+ cout << " Failed reading B for palette color " << i << ".\n";
+ return error;
+ }
+
+ *indexb = ( unsigned char ) c;
+ indexb = indexb + 1;
+
+ file_in.read ( &c, 1 );
+
+ error = file_in.eof();
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_PALETTE_READ: Fatal error!\n";
+ cout << " Failed reading G for palette color " << i << ".\n";
+ return error;
+ }
+
+ *indexg = ( unsigned char ) c;
+ indexg = indexg + 1;
+
+ file_in.read ( &c, 1 );
+
+ error = file_in.eof();
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_PALETTE_READ: Fatal error!\n";
+ cout << " Failed reading R for palette color " << i << ".\n";
+ return error;
+ }
+
+ *indexr = ( unsigned char ) c;
+ indexr = indexr + 1;
+
+ file_in.read ( &c, 1 );
+
+ error = file_in.eof();
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_PALETTE_READ: Fatal error!\n";
+ cout << " Failed reading A for palette color " << i << ".\n";
+ return error;
+ }
+
+ *indexa = ( unsigned char ) c;
+ indexa = indexa + 1;
+ }
+
+ error = false;
+ return error;
+}
+//****************************************************************************
+
+void bmp_palette_write ( ofstream &file_out, unsigned long int colorsused,
+ unsigned char *rparray, unsigned char *gparray, unsigned char *bparray,
+ unsigned char *aparray )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_PALETTE_WRITE writes the palette data to the BMP file.
+//
+// Modified:
+//
+// 04 March 2004
+//
+// Author:
+//
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, ofstream &FILE_OUT, a reference to the output file.
+//
+// Input, unsigned long int COLORSUSED, the number of colors in the palette.
+//
+// Input, unsigned char *RPARRAY, *GPARRAY, *BPARRAY, *APARRAY, pointers to the
+// red, green, blue and transparency palette arrays.
+//
+{
+ int i;
+ unsigned char *indexa;
+ unsigned char *indexb;
+ unsigned char *indexg;
+ unsigned char *indexr;
+
+ indexr = rparray;
+ indexg = gparray;
+ indexb = bparray;
+ indexa = aparray;
+
+ for ( i = 0; i < colorsused; i++ )
+ {
+ file_out << *indexb;
+ file_out << *indexg;
+ file_out << *indexr;
+ file_out << *indexa;
+
+ indexb = indexb + 1;
+ indexg = indexg + 1;
+ indexr = indexr + 1;
+ indexa = indexa + 1;
+ }
+
+ return;
+}
+//****************************************************************************
+
+bool bmp_print_test ( char *file_in_name )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_PRINT_TEST tests the BMP print routines.
+//
+// Discussion:
+//
+// Thanks to Tak Fung for suggesting that BMP files should be opened with
+// the binary option.
+//
+// Modified:
+//
+// 15 December 2004
+//
+// Author:
+//
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, char *FILE_IN_NAME, the name of the input file.
+//
+// Output, bool BMP_PRINT_TEST, is true if an error occurred.
+//
+{
+# define VERBOSE false
+
+ unsigned char *aparray;
+ unsigned char *barray;
+ unsigned char *bparray;
+ unsigned long int bitmapoffset;
+ unsigned short int bitsperpixel;
+ unsigned long int colorsimportant;
+ unsigned long int colorsused;
+ unsigned long int compression;
+ bool error;
+ ifstream file_in;
+ unsigned long int filesize;
+ unsigned short int filetype;
+ unsigned char *garray;
+ unsigned char *gparray;
+ long int height;
+ unsigned long int horzresolution;
+ unsigned short int magic;
+ int numbytes;
+ unsigned short int planes;
+ unsigned char *rarray;
+ unsigned char *rparray;
+ unsigned short int reserved1;
+ unsigned short int reserved2;
+ unsigned long int size;
+ unsigned long int sizeofbitmap;
+ unsigned long int vertresolution;
+ unsigned long int width;
+//
+// Open the input file.
+//
+ file_in.open ( file_in_name, ios::in | ios::binary );
+
+ if ( !file_in )
+ {
+ error = true;
+ cout << "\n";
+ cout << "BMP_PRINT_TEST - Fatal error!\n";
+ cout << " Could not open the input file.\n";
+ return error;
+ }
+ cout << "\n";
+ cout << "BMP_PRINT_TEST:\n";
+ cout << " Contents of BMP file \"" << file_in_name << "\"\n";
+//
+// Read header 1.
+//
+ error = bmp_header1_read ( file_in, &filetype, &filesize, &reserved1,
+ &reserved2, &bitmapoffset );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_PRINT_TEST: Fatal error!\n";
+ cout << " BMP_HEADER1_READ failed.\n";
+ return error;
+ }
+
+ bmp_header1_print ( filetype, filesize, reserved1, reserved2, bitmapoffset );
+//
+// Read header 2.
+//
+ error = bmp_header2_read ( file_in, &size, &width, &height, &planes,
+ &bitsperpixel, &compression, &sizeofbitmap, &horzresolution,
+ &vertresolution, &colorsused, &colorsimportant );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_PRINT_TEST: Fatal error!\n";
+ cout << " BMP_HEADER2_READ failed.\n";
+ return error;
+ }
+
+ bmp_header2_print ( size, width, height, planes, bitsperpixel,
+ compression, sizeofbitmap, horzresolution, vertresolution,
+ colorsused, colorsimportant );
+//
+// Read the palette.
+//
+//if ( 0 < colorsused )
+//{
+ rparray = new unsigned char[colorsused];
+ gparray = new unsigned char[colorsused];
+ bparray = new unsigned char[colorsused];
+ aparray = new unsigned char[colorsused];
+
+ error = bmp_palette_read ( file_in, colorsused, rparray, gparray,
+ bparray, aparray );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_PRINT_TEST: Fatal error!\n";
+ cout << " BMP_PALETTE_READ failed.\n";
+ return error;
+ }
+
+ bmp_palette_print ( colorsused, rparray, gparray, bparray, aparray );
+
+ delete [] rparray;
+ delete [] gparray;
+ delete [] bparray;
+ delete [] aparray;
+//}
+//
+// Allocate storage.
+//
+ numbytes = width * abs ( height ) * sizeof ( unsigned char );
+
+ rarray = new unsigned char[numbytes];
+ garray = new unsigned char[numbytes];
+ barray = new unsigned char[numbytes];
+//
+// Read the data.
+//
+ if ( bitsperpixel == 8 )
+ {
+ error = bmp_08_data_read ( file_in, width, height, rarray );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_PRINT_TEST: Fatal error!\n";
+ cout << " BMP_08_DATA_READ failed.\n";
+ return error;
+ }
+
+ *garray = *rarray;
+ *barray = *rarray;
+ }
+ else if ( bitsperpixel == 24 )
+ {
+ error = bmp_24_data_read ( file_in, width, height, rarray, garray,
+ barray );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_PRINT_TEST: Fatal error!\n";
+ cout << " BMP_24_DATA_READ failed.\n";
+ return error;
+ }
+ }
+ else
+ {
+ cout << "\n";
+ cout << "BMP_PRINT_TEST: Fatal error!\n";
+ cout << " Unrecognized value of BITSPERPIXEL = " << bitsperpixel << "\n";
+ return 1;
+ }
+
+ delete [] rarray;
+ delete [] garray;
+ delete [] barray;
+//
+// Close the file.
+//
+ file_in.close ( );
+
+ return error;
+# undef VERBOSE
+}
+//****************************************************************************
+
+bool bmp_read ( char *file_in_name, unsigned long int *width, long int *height,
+ unsigned char **rarray, unsigned char **garray, unsigned char **barray )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_READ reads the header and data of a BMP file.
+//
+// Discussion:
+//
+// Thanks to Tak Fung for suggesting that BMP files should be opened with
+// the binary option.
+//
+// Thanks to Kelly Anderson for discovering that the routine could not read
+// monochrome images (bitsperpixel = 8 ) and suggesting how to fix that.
+//
+// Modified:
+//
+// 01 April 2005
+//
+// Author:
+//
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, char *FILE_IN_NAME, the name of the input file.
+//
+// Output, unsigned long int *WIDTH, the X dimension of the image.
+//
+// Output, long int *HEIGHT, the Y dimension of the image.
+//
+// Output, unsigned char **RARRAY, **GARRAY, **BARRAY, pointers to the red, green
+// and blue color arrays.
+//
+// Output, bool BMP_READ, is true if an error occurred.
+//
+{
+ unsigned char *aparray;
+ unsigned long int bitmapoffset;
+ unsigned short int bitsperpixel;
+ unsigned char *bparray;
+ unsigned long int colorsimportant;
+ unsigned long int colorsused;
+ unsigned long int compression;
+ bool error;
+ ifstream file_in;
+ unsigned long int filesize;
+ unsigned short int filetype;
+ unsigned char *gparray;
+ unsigned long int horzresolution;
+ unsigned short int magic;
+ int numbytes;
+ unsigned short int planes;
+ unsigned short int reserved1;
+ unsigned short int reserved2;
+ unsigned char *rparray;
+ unsigned long int size;
+ unsigned long int sizeofbitmap;
+ unsigned long int vertresolution;
+//
+// Open the input file.
+//
+ file_in.open ( file_in_name, ios::in | ios::binary );
+
+ if ( !file_in )
+ {
+ error = true;
+ cout << "\n";
+ cout << "BMP_READ - Fatal error!\n";
+ cout << " Could not open the input file.\n";
+ return error;
+ }
+//
+// Read header 1.
+//
+ error = bmp_header1_read ( file_in, &filetype, &filesize, &reserved1,
+ &reserved2, &bitmapoffset );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_READ: Fatal error!\n";
+ cout << " BMP_HEADER1_READ failed.\n";
+ return error;
+ }
+//
+// Make sure the filetype is 'BM'.
+//
+ magic = 'B' * 256 + 'M';
+
+ if ( filetype != magic )
+ {
+ cout << "\n";
+ cout << "BMP_READ: Fatal error!\n";
+ cout << " The file's internal magic number is not \"BM\".\n";
+ cout << " with the numeric value " << magic << "\n";
+ cout << "\n";
+ cout << " Instead, it is \""
+ << ( char ) ( filetype / 256 )
+ << ( char ) ( filetype % 256 )
+ << "\".\n";
+ cout << " with the numeric value " << filetype << "\n";
+ cout << "\n";
+ cout << " (Perhaps you need to reverse the byte swapping option!)\n";
+ return 1;
+ }
+//
+// Read header 2.
+//
+ error = bmp_header2_read ( file_in, &size, width, height, &planes,
+ &bitsperpixel, &compression, &sizeofbitmap, &horzresolution,
+ &vertresolution, &colorsused, &colorsimportant );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_READ: Fatal error!\n";
+ cout << " BMP_HEADER2_READ failed.\n";
+ return error;
+ }
+//
+// Read the palette.
+//
+ if ( 0 < colorsused )
+ {
+ rparray = new unsigned char[colorsused];
+ gparray = new unsigned char[colorsused];
+ bparray = new unsigned char[colorsused];
+ aparray = new unsigned char[colorsused];
+
+ error = bmp_palette_read ( file_in, colorsused, rparray, gparray,
+ bparray, aparray );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_READ: Fatal error!\n";
+ cout << " BMP_PALETTE_READ failed.\n";
+ return error;
+ }
+ delete [] rparray;
+ delete [] gparray;
+ delete [] bparray;
+ delete [] aparray;
+ }
+//
+// Allocate storage.
+//
+ numbytes = ( *width ) * ( abs ( *height ) ) * sizeof ( unsigned char );
+
+ *rarray = new unsigned char[numbytes];
+ *garray = new unsigned char[numbytes];
+ *barray = new unsigned char[numbytes];
+//
+// Read the data.
+//
+ if ( bitsperpixel == 8 )
+ {
+ error = bmp_08_data_read ( file_in, *width, *height, *rarray );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_READ: Fatal error!\n";
+ cout << " BMP_08_DATA_READ failed.\n";
+ return error;
+ }
+
+ *garray = *rarray;
+ *barray = *rarray;
+ }
+ else if ( bitsperpixel == 24 )
+ {
+ error = bmp_24_data_read ( file_in, *width, *height, *rarray, *garray,
+ *barray );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_READ: Fatal error!\n";
+ cout << " BMP_24_DATA_READ failed.\n";
+ return error;
+ }
+ }
+ else
+ {
+ cout << "\n";
+ cout << "BMP_READ: Fatal error!\n";
+ cout << " Unrecognized value of BITSPERPIXEL = " << bitsperpixel << "\n";
+ return 1;
+ }
+//
+// Close the file.
+//
+ file_in.close ( );
+
+ error = false;
+ return error;
+}
+//****************************************************************************
+
+bool bmp_read_test ( char *file_in_name )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_READ_TEST tests the BMP read routines.
+//
+// Modified:
+//
+// 05 March 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, char *FILE_IN_NAME, the name of the input file.
+//
+// Output, bool BMP_READ_TEST, is true if an error occurred.
+//
+{
+# define VERBOSE false
+
+ unsigned char *barray;
+ bool error;
+ unsigned char *garray;
+ long int height;
+ unsigned char *rarray;
+ unsigned long int width;
+
+ rarray = NULL;
+ garray = NULL;
+ barray = NULL;
+//
+// Read the data from file.
+//
+ error = bmp_read ( file_in_name, &width, &height, &rarray, &garray,
+ &barray );
+//
+// Free the memory.
+//
+ delete [] rarray;
+ delete [] garray;
+ delete [] barray;
+
+ if ( VERBOSE )
+ {
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_READ_TEST - Fatal error!\n";
+ cout << " The test failed.\n";
+ }
+ else
+ {
+ cout << "\n";
+ cout << "BMP_READ_TEST:\n";
+ cout << " WIDTH = " << width << ".\n";
+ cout << " HEIGHT = " << height << ".\n";
+ cout << "\n";
+ cout << "BMP_READ_TEST:\n";
+ cout << " The test was successful.\n";
+ }
+ }
+
+ return error;
+# undef VERBOSE
+}
+//****************************************************************************
+
+bool bmp_08_write ( char *file_out_name, unsigned long int width, long int height,
+ unsigned char *rarray )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_08_WRITE writes the header and data for a monochrome BMP file.
+//
+// Discussion:
+//
+// XV seems to think the resulting BMP file is "unexpectedly truncated".
+//
+// Modified:
+//
+// 02 April 2005
+//
+// Author:
+//
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, char *FILE_OUT_NAME, the name of the output file.
+//
+// Input, unsigned long int WIDTH, the X dimension of the image.
+//
+// Input, long int HEIGHT, the Y dimension of the image.
+//
+// Input, unsigned char *RARRAY, pointer to the red color array.
+//
+// Output, bool BMP_08_WRITE, is true if an error occurred.
+//
+{
+ unsigned char *aparray = NULL;
+ unsigned long int bitmapoffset;
+ unsigned short int bitsperpixel;
+ unsigned char *bparray = NULL;
+ unsigned long int colorsimportant;
+ unsigned long int colorsused;
+ unsigned long int compression;
+ bool error;
+ ofstream file_out;
+ unsigned long int filesize;
+ unsigned short int filetype;
+ unsigned char *gparray = NULL;
+ unsigned long int horzresolution;
+ int padding;
+ unsigned short int planes;
+ unsigned short int reserved1 = 0;
+ unsigned short int reserved2 = 0;
+ unsigned char *rparray = NULL;
+ unsigned long int size = 40;
+ unsigned long int sizeofbitmap;
+ unsigned long int vertresolution;
+//
+// Open the output file.
+//
+ file_out.open ( file_out_name, ios::out | ios::binary );
+
+ error = !file_out;
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_08_WRITE - Fatal error!\n";
+ cout << " Could not open the output file.\n";
+ return error;
+ }
+//
+// Write header 1.
+//
+ if ( bmp_byte_swap )
+ {
+ filetype = 'M' * 256 + 'B';
+ }
+ else
+ {
+ filetype = 'B' * 256 + 'M';
+ }
+//
+// Determine the padding needed when WIDTH is not a multiple of 4.
+//
+ padding = ( 4 - ( ( 1 * width ) % 4 ) ) % 4;
+
+ filesize = 54 + ( width + padding ) * abs ( height );
+ bitmapoffset = 54;
+
+ bmp_header1_write ( file_out, filetype, filesize, reserved1,
+ reserved2, bitmapoffset );
+//
+// Write header 2.
+//
+ planes = 1;
+ bitsperpixel = 8;
+ compression = 0;
+ sizeofbitmap = 0;
+ horzresolution = 0;
+ vertresolution = 0;
+ colorsused = 0;
+ colorsimportant = 0;
+
+ bmp_header2_write ( file_out, size, width, height, planes, bitsperpixel,
+ compression, sizeofbitmap, horzresolution, vertresolution,
+ colorsused, colorsimportant );
+//
+// Write the palette.
+//
+ bmp_palette_write ( file_out, colorsused, rparray, gparray, bparray,
+ aparray );
+//
+// Write the data.
+//
+ bmp_08_data_write ( file_out, width, height, rarray );
+//
+// Close the file.
+//
+ file_out.close ( );
+
+ error = false;
+ return error;
+}
+//****************************************************************************
+
+bool bmp_08_write_test ( char *file_out_name )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_08_WRITE_TEST tests the BMP write routines.
+//
+// Modified:
+//
+// 02 April 2005
+//
+// Author:
+//
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, char *FILE_OUT_NAME, the name of the output file.
+//
+// Output, bool BMP_08_WRITE_TEST, is true if an error occurred.
+//
+{
+# define VERBOSE false
+
+ bool error;
+ long int height;
+ int i;
+ unsigned char *indexr;
+ int j;
+ int j2;
+ int numbytes;
+ unsigned char *rarray;
+ int result;
+ unsigned long int width;
+
+ width = 255;
+ height = 255;
+//
+// Allocate the memory.
+//
+ numbytes = width * abs ( height ) * sizeof ( unsigned char );
+
+ rarray = new unsigned char[numbytes];
+//
+// Set the data.
+//
+ indexr = rarray;
+
+ for ( j = 0; j < height; j++ )
+ {
+ for ( i = 0; i < width; i++ )
+ {
+ *indexr = i % ( j + 1 );
+ indexr = indexr + 1;
+ }
+ }
+//
+// Write the data to a file.
+//
+ error = bmp_08_write ( file_out_name, width, height, rarray );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_08_WRITE_TEST - Fatal error!\n";
+ cout << " The test failed.\n";
+ return error;
+ }
+//
+// Free the memory.
+//
+ delete [] rarray;
+
+ if ( VERBOSE )
+ {
+ cout << "\n";
+ cout << "BMP_08_WRITE_TEST:\n";
+ cout << " The test was successful.\n";
+ }
+
+ error = false;
+ return error;
+# undef VERBOSE
+}
+//****************************************************************************
+
+bool bmp_24_write ( char *file_out_name, unsigned long int width, long int height,
+ unsigned char *rarray, unsigned char *garray, unsigned char *barray )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_24_WRITE writes the header and data for a BMP file using three colors.
+//
+// Discussion
+//
+// Thanks to Keefe Roedersheimer for pointing out that I was creating
+// a filetype of 'MB' instead of 'BM'.
+//
+// Lee Mulcahy pointed out that the BMP format requires that horizonal lines
+// must have a length that is a multiple of 4, or be padded so that this is the case.
+//
+// Thanks to Tak Fung for suggesting that BMP files should be opened with
+// the binary option.
+//
+// Modified:
+//
+// 02 April 2005
+//
+// Author:
+//
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, char *FILE_OUT_NAME, the name of the output file.
+//
+// Input, unsigned long int WIDTH, the X dimension of the image.
+//
+// Input, long int HEIGHT, the Y dimension of the image.
+//
+// Input, unsigned char *RARRAY, *GARRAY, *BARRAY, pointers to the red, green
+// and blue color arrays.
+//
+// Output, bool BMP_24_WRITE, is true if an error occurred.
+//
+{
+ unsigned char *aparray = NULL;
+ unsigned long int bitmapoffset;
+ unsigned short int bitsperpixel;
+ unsigned char *bparray = NULL;
+ unsigned long int colorsimportant;
+ unsigned long int colorsused;
+ unsigned long int compression;
+ bool error;
+ ofstream file_out;
+ unsigned long int filesize;
+ unsigned short int filetype;
+ unsigned char *gparray = NULL;
+ unsigned long int horzresolution;
+ int padding;
+ unsigned short int planes;
+ unsigned short int reserved1 = 0;
+ unsigned short int reserved2 = 0;
+ unsigned char *rparray = NULL;
+ unsigned long int size = 40;
+ unsigned long int sizeofbitmap;
+ unsigned long int vertresolution;
+//
+// Open the output file.
+//
+ file_out.open ( file_out_name, ios::out | ios::binary );
+
+ error = !file_out;
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_24_WRITE - Fatal error!\n";
+ cout << " Could not open the output file.\n";
+ return error;
+ }
+//
+// Write header 1.
+//
+ if ( bmp_byte_swap )
+ {
+ filetype = 'M' * 256 + 'B';
+ }
+ else
+ {
+ filetype = 'B' * 256 + 'M';
+ }
+//
+// Determine the padding needed when WIDTH is not a multiple of 4.
+//
+ padding = ( 4 - ( ( 3 * width ) % 4 ) ) % 4;
+
+ filesize = 54 + ( ( 3 * width ) + padding ) * abs ( height );
+ bitmapoffset = 54;
+
+ bmp_header1_write ( file_out, filetype, filesize, reserved1,
+ reserved2, bitmapoffset );
+//
+// Write header 2.
+//
+ planes = 1;
+ bitsperpixel = 24;
+ compression = 0;
+ sizeofbitmap = 0;
+ horzresolution = 0;
+ vertresolution = 0;
+ colorsused = 0;
+ colorsimportant = 0;
+
+ bmp_header2_write ( file_out, size, width, height, planes, bitsperpixel,
+ compression, sizeofbitmap, horzresolution, vertresolution,
+ colorsused, colorsimportant );
+//
+// Write the palette.
+//
+ bmp_palette_write ( file_out, colorsused, rparray, gparray, bparray,
+ aparray );
+//
+// Write the data.
+//
+ bmp_24_data_write ( file_out, width, height, rarray, garray, barray );
+//
+// Close the file.
+//
+ file_out.close ( );
+
+ error = false;
+ return error;
+}
+//****************************************************************************
+
+bool bmp_24_write_test ( char *file_out_name )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// BMP_24_WRITE_TEST tests the BMP write routines.
+//
+// Modified:
+//
+// 05 March 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// References:
+//
+// David Kay and John Levine,
+// Graphics File Formats,
+// Second Edition,
+// McGraw Hill, 1995.
+//
+// Microsoft Corporation,
+// Microsoft Windows Programmer's Reference,
+// Volume 5; Messages, Structures, and Macros,
+// Microsoft Press, 1993.
+//
+// John Miano,
+// Compressed Image File Formats,
+// Addison Wesley, 1999.
+//
+// Parameters:
+//
+// Input, char *FILE_OUT_NAME, the name of the output file.
+//
+// Output, bool BMP_24_WRITE_TEST, is true if an error occurred.
+//
+{
+# define VERBOSE false
+
+ unsigned char *barray;
+ bool error;
+ unsigned char *garray;
+ long int height;
+ int i;
+ unsigned char *indexb;
+ unsigned char *indexg;
+ unsigned char *indexr;
+ int j;
+ int j2;
+ int numbytes;
+ unsigned char *rarray;
+ int result;
+ unsigned long int width;
+
+ width = 200;
+ height = 200;
+//
+// Allocate the memory.
+//
+ numbytes = width * abs ( height ) * sizeof ( unsigned char );
+
+ rarray = new unsigned char[numbytes];
+ garray = new unsigned char[numbytes];
+ barray = new unsigned char[numbytes];
+//
+// Set the data.
+// Note that BMP files go from "bottom" up, so we'll reverse the
+// sense of "J" here to get what we want.
+//
+ indexr = rarray;
+ indexg = garray;
+ indexb = barray;
+
+ for ( j2 = 0; j2 < abs ( height ); j2++ )
+ {
+ j = abs ( height ) - j2;
+ for ( i = 0; i < width; i++ )
+ {
+ if ( i <= j )
+ {
+ *indexr = 255;
+ *indexg = 0;
+ *indexb = 0;
+ }
+ else if ( ( width - 1 ) * j + ( abs ( height ) - 1 ) * i <=
+ ( width - 1 ) * ( abs ( height ) - 1 ) )
+ {
+ *indexr = 0;
+ *indexg = 255;
+ *indexb = 0;
+ }
+ else
+ {
+ *indexr = 0;
+ *indexg = 0;
+ *indexb = 255;
+ }
+ indexr = indexr + 1;
+ indexg = indexg + 1;
+ indexb = indexb + 1;
+ }
+ }
+//
+// Write the data to a file.
+//
+ error = bmp_24_write ( file_out_name, width, height, rarray, garray, barray );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "BMP_24_WRITE_TEST - Fatal error!\n";
+ cout << " The test failed.\n";
+ return error;
+ }
+//
+// Free the memory.
+//
+ delete [] rarray;
+ delete [] garray;
+ delete [] barray;
+
+ if ( VERBOSE )
+ {
+ cout << "\n";
+ cout << "BMP_24_WRITE_TEST:\n";
+ cout << " The test was successful.\n";
+ }
+
+ error = false;
+ return error;
+# undef VERBOSE
+}
+//****************************************************************************
+
+bool long_int_read ( long int *long_int_val, ifstream &file_in )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// LONG_INT_READ reads a long int from a file.
+//
+// Modified:
+//
+// 06 March 2004
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Output, long int *LONG_INT_VAL, the value that was read.
+//
+// Input, ifstream &FILE_IN, a reference to the input file.
+//
+// Output, bool LONG_INT_READ, is true if an error occurred.
+//
+{
+ bool error;
+ unsigned short int u_short_int_val_hi;
+ unsigned short int u_short_int_val_lo;
+
+ if ( bmp_byte_swap )
+ {
+ error = u_short_int_read ( &u_short_int_val_lo, file_in );
+ if ( error )
+ {
+ return error;
+ }
+ error = u_short_int_read ( &u_short_int_val_hi, file_in );
+ if ( error )
+ {
+ return error;
+ }
+ }
+ else
+ {
+ error = u_short_int_read ( &u_short_int_val_hi, file_in );
+ if ( error )
+ {
+ return error;
+ }
+ error = u_short_int_read ( &u_short_int_val_lo, file_in );
+ if ( error )
+ {
+ return error;
+ }
+ }
+
+ *long_int_val = ( long int )
+ ( u_short_int_val_hi << 16 ) | u_short_int_val_lo;
+
+ return false;
+}
+//****************************************************************************
+
+void long_int_write ( long int long_int_val, ofstream &file_out )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// LONG_INT_WRITE writes a long int to a file.
+//
+// Modified:
+//
+// 06 March 2004
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Input, long int *LONG_INT_VAL, the value to be written.
+//
+// Input, ofstream &FILE_OUT, a reference to the output file.
+//
+{
+ long int temp;
+ unsigned short int u_short_int_val_hi;
+ unsigned short int u_short_int_val_lo;
+
+ temp = long_int_val / 65536;
+ if ( temp < 0 )
+ {
+ temp = temp + 65536;
+ }
+ u_short_int_val_hi = ( unsigned short ) temp;
+
+ temp = long_int_val % 65536;
+ if ( temp < 0 )
+ {
+ temp = temp + 65536;
+ }
+ u_short_int_val_lo = ( unsigned short ) temp;
+
+ if ( bmp_byte_swap )
+ {
+ u_short_int_write ( u_short_int_val_lo, file_out );
+ u_short_int_write ( u_short_int_val_hi, file_out );
+ }
+ else
+ {
+ u_short_int_write ( u_short_int_val_hi, file_out );
+ u_short_int_write ( u_short_int_val_lo, file_out );
+ }
+
+ return;
+}
+//****************************************************************************
+
+bool u_long_int_read ( unsigned long int *u_long_int_val,
+ ifstream &file_in )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// U_LONG_INT_READ reads an unsigned long int from a file.
+//
+// Modified:
+//
+// 05 March 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Output, unsigned long int *U_LONG_INT_VAL, the value that was read.
+//
+// Input, ifstream &FILE_IN, a reference to the input file.
+//
+// Output, bool U_LONG_INT_READ, is true if an error occurred.
+//
+{
+ bool error;
+ unsigned short int u_short_int_val_hi;
+ unsigned short int u_short_int_val_lo;
+
+ if ( bmp_byte_swap )
+ {
+ error = u_short_int_read ( &u_short_int_val_lo, file_in );
+ if ( error )
+ {
+ return error;
+ }
+ error = u_short_int_read ( &u_short_int_val_hi, file_in );
+ if ( error )
+ {
+ return error;
+ }
+ }
+ else
+ {
+ error = u_short_int_read ( &u_short_int_val_hi, file_in );
+ if ( error )
+ {
+ return error;
+ }
+ error = u_short_int_read ( &u_short_int_val_lo, file_in );
+ if ( error )
+ {
+ return error;
+ }
+ }
+//
+// Acknowledgement:
+//
+// A correction to the following line was supplied by
+// Peter Kionga-Kamau, 20 May 2000.
+//
+
+ *u_long_int_val = ( u_short_int_val_hi << 16 ) | u_short_int_val_lo;
+
+ return false;
+}
+//****************************************************************************
+
+void u_long_int_write ( unsigned long int u_long_int_val,
+ ofstream &file_out )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// U_LONG_INT_WRITE writes an unsigned long int to a file.
+//
+// Modified:
+//
+// 05 March 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Input, unsigned long int *U_LONG_INT_VAL, the value to be written.
+//
+// Input, ofstream &FILE_OUT, a reference to the output file.
+//
+{
+ unsigned short int u_short_int_val_hi;
+ unsigned short int u_short_int_val_lo;
+
+ u_short_int_val_hi = ( unsigned short ) ( u_long_int_val / 65536 );
+ u_short_int_val_lo = ( unsigned short ) ( u_long_int_val % 65536 );
+
+ if ( bmp_byte_swap )
+ {
+ u_short_int_write ( u_short_int_val_lo, file_out );
+ u_short_int_write ( u_short_int_val_hi, file_out );
+ }
+ else
+ {
+ u_short_int_write ( u_short_int_val_hi, file_out );
+ u_short_int_write ( u_short_int_val_lo, file_out );
+ }
+
+ return;
+}
+//****************************************************************************
+
+bool u_short_int_read ( unsigned short int *u_short_int_val,
+ ifstream &file_in )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// U_SHORT_INT_READ reads an unsigned short int from a file.
+//
+// Modified:
+//
+// 30 March 2005
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Output, unsigned short int *U_SHORT_INT_VAL, the value that was read.
+//
+// Input, ifstream &FILE_IN, a reference to the input file.
+//
+// Output, bool U_SHORT_INT_READ, is true if an error occurred.
+//
+{
+ char c;
+ unsigned char chi;
+ unsigned char clo;
+
+ if ( bmp_byte_swap )
+ {
+ file_in.read ( &c, 1 );
+ if ( file_in.eof() )
+ {
+ return true;
+ }
+ clo = ( unsigned char ) c;
+
+ file_in.read ( &c, 1 );
+ if ( file_in.eof() )
+ {
+ return true;
+ }
+ chi = ( unsigned char ) c;
+ }
+ else
+ {
+ file_in.read ( &c, 1 );
+ if ( file_in.eof() )
+ {
+ return true;
+ }
+ chi = ( unsigned char ) c;
+
+ file_in.read ( &c, 1 );
+ if ( file_in.eof() )
+ {
+ return true;
+ }
+ clo = ( unsigned char ) c;
+ }
+
+ *u_short_int_val = ( chi << 8 ) | clo;
+
+ return false;
+}
+//****************************************************************************
+
+void u_short_int_write ( unsigned short int u_short_int_val,
+ ofstream &file_out )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// U_SHORT_INT_WRITE writes an unsigned short int to a file.
+//
+// Modified:
+//
+// 26 February 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Input, unsigned short int *U_SHORT_INT_VAL, the value to be written.
+//
+// Input, ofstream &FILE_OUT, a reference to the output file.
+//
+{
+ unsigned char chi;
+ unsigned char clo;
+
+ chi = ( unsigned char ) ( u_short_int_val / 256 );
+ clo = ( unsigned char ) ( u_short_int_val % 256 );
+
+ if ( bmp_byte_swap )
+ {
+ file_out << clo << chi;
+ }
+ else
+ {
+ file_out << chi << clo;
+ }
+
+ return;
+}
diff --git a/src/ppma_2_bmp/bmp_io.H b/src/ppma_2_bmp/bmp_io.H
new file mode 100644
index 0000000..fad954c
--- /dev/null
+++ b/src/ppma_2_bmp/bmp_io.H
@@ -0,0 +1,74 @@
+bool bmp_byte_swap_get ( void );
+void bmp_byte_swap_set ( bool value );
+
+bool bmp_08_data_read ( ifstream &file_in, unsigned long int width, long int height,
+ unsigned char *rarray );
+void bmp_08_data_write ( ofstream &file_out, unsigned long int width,
+ long int height, unsigned char *rarray );
+
+bool bmp_24_data_read ( ifstream &file_in, unsigned long int width,
+ long int height, unsigned char *rarray, unsigned char *garray, unsigned char *barray );
+void bmp_24_data_write ( ofstream &file_out, unsigned long int width,
+ long int height, unsigned char *rarray, unsigned char *garray, unsigned char *barray );
+
+void bmp_header1_print ( unsigned short int filetype,
+ unsigned long int filesize, unsigned short int reserved1,
+ unsigned short int reserved2, unsigned long int bitmapoffset );
+bool bmp_header1_read ( ifstream &file_in, unsigned short int *filetype,
+ unsigned long int *filesize, unsigned long int *reserved1,
+ unsigned short int *reserved2, unsigned long int *bitmapoffset );
+void bmp_header1_write ( ofstream &file_out, unsigned short int filetype,
+ unsigned long int filesize, unsigned long int reserved1,
+ unsigned short int reserved2, unsigned long int bitmapoffset );
+
+void bmp_header2_print ( unsigned long int size, unsigned long int width,
+ long int height,
+ unsigned short int planes, unsigned short int bitsperpixel,
+ unsigned long int compression, unsigned long int sizeofbitmap,
+ unsigned long int horzresolution, unsigned long int vertresolution,
+ unsigned long int colorsused, unsigned long int colorsimportant );
+bool bmp_header2_read ( ifstream &file_in, unsigned long int *size,
+ unsigned long int *width, long int *height,
+ unsigned short int *planes, unsigned short int *bitsperpixel,
+ unsigned long int *compression, unsigned long int *sizeofbitmap,
+ unsigned long int *horzresolution, unsigned long int *vertresolution,
+ unsigned long int *colorsused, unsigned long int *colorsimportant );
+void bmp_header2_write ( ofstream &file_out, unsigned long int size,
+ unsigned long int width, long int height,
+ unsigned short int planes, unsigned short int bitsperpixel,
+ unsigned long int compression, unsigned long int sizeofbitmap,
+ unsigned long int horzresolution, unsigned long int vertresolution,
+ unsigned long int colorsused, unsigned long int colorsimportant );
+
+void bmp_palette_print ( unsigned long int colorsused,
+ unsigned char *rparray, unsigned char *gparray, unsigned char *bparray,
+ unsigned char *aparray );
+bool bmp_palette_read ( ifstream &file_in, unsigned long int colorsused,
+ unsigned char *rparray, unsigned char *gparray, unsigned char *bparray,
+ unsigned char *aparray );
+void bmp_palette_write ( ofstream &file_out, unsigned long int colorsused,
+ unsigned char *rparray, unsigned char *gparray, unsigned char *bparray,
+ unsigned char *aparray );
+
+bool bmp_print_test ( char *file_in_name );
+
+bool bmp_read ( char *file_in_name, unsigned long int *width, long int *height,
+ unsigned char **rarray, unsigned char **garray, unsigned char **barray );
+bool bmp_read_test ( char *file_in_name );
+
+bool bmp_08_write ( char *file_out_name, unsigned long int width, long int height,
+ unsigned char *rarray, unsigned char *garray, unsigned char *barray );
+bool bmp_08_write_test ( char *file_out_name );
+
+bool bmp_24_write ( char *file_out_name, unsigned long int width, long int height,
+ unsigned char *rarray, unsigned char *garray, unsigned char *barray );
+bool bmp_24_write_test ( char *file_out_name );
+
+bool long_int_read ( long int *long_int_val, ifstream &file_in );
+void long_int_write ( long int long_int_val, ofstream &file_out );
+
+bool u_long_int_read ( unsigned long int *u_long_int_val, ifstream &file_in );
+void u_long_int_write ( unsigned long int u_long_int_val, ofstream &file_out );
+
+bool u_short_int_read ( unsigned short int *u_short_int_val, ifstream &file_in );
+void u_short_int_write ( unsigned short int u_short_int_val, ofstream &file_out );
diff --git a/src/ppma_2_bmp/ppma_2_bmp.C b/src/ppma_2_bmp/ppma_2_bmp.C
new file mode 100644
index 0000000..885037a
--- /dev/null
+++ b/src/ppma_2_bmp/ppma_2_bmp.C
@@ -0,0 +1,374 @@
+# include <cstdlib>
+# include <iostream>
+# include <iomanip>
+# include <fstream>
+# include <ctime>
+
+using namespace std;
+
+# include "bmp_io.H"
+# include "ppma_io.H"
+
+int main ( int argc, char *argv[] );
+void imat_vert_flip ( int xsize, int ysize, int *array );
+void int_2_u_char ( int xsize, int ysize, int *a_int, unsigned char *a_u );
+bool ppma_2_bmp ( char *file_in_name, char *file_out_name );
+void timestamp ( void );
+
+//****************************************************************************
+
+int main ( int argc, char *argv[] )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// PPMA_2_BMP converts an ASCII PPM file to a BMP file.
+//
+// Discussion:
+//
+// The program requires the BMP_IO and PPMA_IO libraries.
+//
+// Modified:
+//
+// 09 April 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// Usage:
+//
+// ppma_2_bmp file.ppma file.bmp
+//
+// Parameters:
+//
+// FILE.PPMA is the name of the input ASCII PPM file to be read.
+//
+// FILE.BMP is the name of the output BMP file to be created.
+//
+{
+ bool error;
+ char file_in_name[80];
+ char file_out_name[80];
+
+ timestamp ( );
+
+ cout << "\n";
+ cout << "PPMA_2_BMP:\n";
+ cout << "\n";
+ cout << " Compiled on " << __DATE__ << " at " << __TIME__ << ".\n";
+ cout << "\n";
+ cout << " Convert a NetPBM ASCII PPM file to Microsoft BMP format.\n";
+//
+// Get the specification for the input file.
+//
+ if ( argc < 2 )
+ {
+ cout << "\n";
+ cout << "PPMA_2_BMP:\n";
+ cout << " Please enter the input PPMA file name:\n";
+
+ cin.getline ( file_in_name, sizeof ( file_in_name ) );
+
+ error = cin.eof();
+
+ if ( error )
+ {
+ exit ( 1 );
+ }
+ }
+ else
+ {
+ strcpy ( file_in_name, argv[1] );
+ }
+//
+// Get the specification for the output file.
+//
+ if ( argc < 3 )
+ {
+ cout << "\n";
+ cout << "PPMA_2_BMP:\n";
+ cout << " Please enter the output BMP file name:\n";
+
+ cin.getline ( file_out_name, sizeof ( file_out_name ) );
+
+ error = cin.eof();
+
+ if ( error )
+ {
+ exit ( 1 );
+ }
+ }
+ else
+ {
+ strcpy ( file_out_name, argv[2] );
+ }
+
+ error = ppma_2_bmp ( file_in_name, file_out_name );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "PPMA_2_BMP - Fatal error!\n";
+ cout << " The conversion was not successful.\n";
+ exit ( 1 );
+ }
+
+ cout << "\n";
+ cout << "PPMA_2_BMP:\n";
+ cout << " Normal end of execution.\n";
+
+ cout << "\n";
+ timestamp ( );
+
+ return 0;
+}
+//****************************************************************************
+
+bool ppma_2_bmp ( char *file_in_name, char *file_out_name )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// PPMA_2_BMP reads a PPMA (ASCII PPM) file and writes a BMP file.
+//
+// Modified:
+//
+// 06 April 2001
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Input, char *FILE_IN_NAME, the name of the input PPMA file.
+//
+// Input, char *FILE_OUT_NAME, the name of the output BMP file.
+//
+// Output, bool ppma_2_bmp, is true if an error occurred.
+//
+{
+ int *b_int;
+ unsigned char *b_u_char;
+ bool error;
+ int *g_int;
+ unsigned char *g_u_char;
+ long int height;
+ int maxrgb;
+ int *r_int;
+ unsigned char *r_u_char;
+ unsigned long int width;
+ int xsize;
+ int ysize;
+
+ r_int = NULL;
+ g_int = NULL;
+ b_int = NULL;
+//
+// Read the integer data from the PPMA file.
+//
+ error = ppma_read ( file_in_name, &xsize, &ysize, &maxrgb,
+ &r_int, &g_int, &b_int );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "PPMA_2_BMP - Fatal error!\n";
+ cout << " PPMA_READ failed.\n";
+ return error;
+ }
+
+ cout << "\n";
+ cout << "PPMA_2_BMP:\n";
+ cout << " XSIZE = " << xsize << ".\n";
+ cout << " YSIZE = " << ysize << ".\n";
+//
+// The BMP up-down orientation is the opposite of what it is in PPM.
+//
+ cout << "\n";
+ cout << "PPMA_2_BMP:\n";
+ cout << " Flipping data orientation.\n";
+
+ imat_vert_flip ( xsize, ysize, r_int );
+ imat_vert_flip ( xsize, ysize, g_int );
+ imat_vert_flip ( xsize, ysize, b_int );
+//
+// BMP expects unsigned characters, not integers.
+//
+ r_u_char = new unsigned char [xsize*ysize];
+ g_u_char = new unsigned char [xsize*ysize];
+ b_u_char = new unsigned char [xsize*ysize];
+
+ int_2_u_char ( xsize, ysize, r_int, r_u_char );
+ int_2_u_char ( xsize, ysize, g_int, g_u_char );
+ int_2_u_char ( xsize, ysize, b_int, b_u_char );
+
+ delete [] r_int;
+ delete [] g_int;
+ delete [] b_int;
+
+ height = ( long int ) ysize;
+ width = ( unsigned long int ) xsize;
+
+ error = bmp_24_write ( file_out_name, width, height,
+ r_u_char, g_u_char, b_u_char );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "PPMA_2_BMP - Fatal error!\n";
+ cout << " BMP_24_WRITE failed.\n";
+ return error;
+ }
+
+ delete [] r_u_char;
+ delete [] g_u_char;
+ delete [] b_u_char;
+
+ cout << "\n";
+ cout << "PPMA_2_BMP:\n";
+ cout << " Normal end of translation.\n";
+
+ return false;
+}
+//****************************************************************************
+
+void imat_vert_flip ( int xsize, int ysize, int *array )
+
+//****************************************************************************
+
+//
+// Purpose:
+//
+// IMAT_VERT_FLIP swaps rows of a 2D array, to flip it vertically.
+//
+// Modified:
+//
+// 07 April 2001
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Input, int XSIZE, int YSIZE, the number of columns and rows.
+//
+// Input, int *ARRAY, the address of the first element of the array.
+//
+{
+ int i;
+ int j;
+ int k1;
+ int k2;
+ int temp;
+
+ for ( j = 0; j <= ( ysize / 2 ); j++ )
+ {
+ k1 = xsize * j;
+ k2 = xsize * ( ysize - 1 - j );
+
+ for ( i = 0; i < xsize; i++ )
+ {
+ temp = array[k1+i];
+ array[k1+i] = array[k2+i];
+ array[k2+i] = temp;
+ }
+ }
+
+ return;
+}
+//****************************************************************************
+
+void int_2_u_char ( int xsize, int ysize, int *a_int, unsigned char *a_u )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// INT_2_U_CHAR converts a 2D array of ints to unsigned chars.
+//
+// Modified:
+//
+// 09 April 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Input, int XSIZE, int YSIZE, the number of columns and rows.
+//
+// Input, int char *A_INT, the array of ints.
+//
+// Output, unsigned char *A_U, the array of unsigned chars.
+//
+{
+ int *b_int;
+ unsigned char *b_u;
+ int i;
+ int j;
+
+ b_u = a_u;
+ b_int = a_int;
+
+ for ( i = 0; i < xsize; i++ )
+ {
+ for ( j = 0; j < ysize; j++ )
+ {
+ *b_u = ( unsigned char ) *b_int;
+ b_int = b_int + 1;
+ b_u = b_u + 1;
+ }
+ }
+
+ return;
+}
+//**********************************************************************
+
+void timestamp ( void )
+
+//**********************************************************************
+//
+// Purpose:
+//
+// TIMESTAMP prints the current YMDHMS date as a time stamp.
+//
+// Example:
+//
+// May 31 2001 09:45:54 AM
+//
+// Modified:
+//
+// 24 September 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// None
+//
+{
+#define TIME_SIZE 40
+
+ static char time_buffer[TIME_SIZE];
+ const struct tm *tm;
+ size_t len;
+ time_t now;
+
+ now = time ( NULL );
+ tm = localtime ( &now );
+
+ len = strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm );
+
+ cout << time_buffer << "\n";
+
+ return;
+#undef TIME_SIZE
+}
diff --git a/src/ppma_2_bmp/ppma_io.C b/src/ppma_2_bmp/ppma_io.C
new file mode 100644
index 0000000..6ea648c
--- /dev/null
+++ b/src/ppma_2_bmp/ppma_io.C
@@ -0,0 +1,897 @@
+# include <cstdlib>
+# include <iostream>
+# include <iomanip>
+# include <fstream>
+# include <cmath>
+# include <ctime>
+
+using namespace std;
+
+# include "ppma_io.H"
+
+# define MAX(a,b) ( (a)>(b) ? (a) : (b) )
+
+//****************************************************************************
+
+bool ppma_check_data ( int xsize, int ysize, int maxrgb, int *r,
+ int *g, int *b )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// PPMA_CHECK_DATA checks the data for an ASCII portable pixel map file.
+//
+// Discussion:
+//
+// XSIZE and YSIZE must be positive, the pointers must not be null,
+// and the data must be nonnegative and no greater than MAXRGB.
+//
+// Example:
+//
+// P3
+// # feep.ppm
+// 4 4
+// 15
+// 0 0 0 0 0 0 0 0 0 15 0 15
+// 0 0 0 0 15 7 0 0 0 0 0 0
+// 0 0 0 0 0 0 0 15 7 0 0 0
+// 15 0 15 0 0 0 0 0 0 0 0 0
+//
+// Modified:
+//
+// 28 February 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Input, int XSIZE, YSIZE, the number of rows and columns of data.
+//
+// Input, int MAXRGB, the maximum RGB value.
+//
+// Input, int *R, *G, *B, the arrays of XSIZE by YSIZE data values.
+//
+// Output, bool PPMA_CHECK_DATA, is
+// true, if an error was detected, or
+// false, if the data was legal.
+//
+{
+ char c;
+ int i;
+ int *index;
+ int j;
+ int k;
+
+ if ( xsize <= 0 )
+ {
+ cout << "\n";
+ cout << "PPMA_CHECK_DATA: Error!\n";
+ cout << " xsize <= 0.\n";
+ cout << " xsize = " << xsize << "\n";
+ return true;
+ }
+
+ if ( ysize <= 0 )
+ {
+ cout << "\n";
+ cout << "PPMA_CHECK_DATA: Error!\n";
+ cout << " ysize <= 0.\n";
+ cout << " ysize = " << ysize << "\n";
+ return true;
+ }
+
+ if ( r == NULL )
+ {
+ cout << "\n";
+ cout << "PPMA_CHECK_DATA: Error!\n";
+ cout << " Null pointer to R.\n";
+ return true;
+ }
+
+ if ( g == NULL )
+ {
+ cout << "\n";
+ cout << "PPMA_CHECK_DATA: Error!\n";
+ cout << " Null pointer to G.\n";
+ return true;
+ }
+
+ if ( b == NULL )
+ {
+ cout << "\n";
+ cout << "PPMA_CHECK_DATA: Error!\n";
+ cout << " Null pointer to B.\n";
+ return true;
+ }
+
+ for ( k = 0; k < 3; k++ )
+ {
+
+ if ( k == 0 )
+ {
+ index = r;
+ c = 'R';
+ }
+ else if ( k == 1 )
+ {
+ index = g;
+ c = 'G';
+ }
+ else if ( k == 2 )
+ {
+ index = b;
+ c = 'B';
+ }
+
+ for ( j = 0; j < ysize; j++ )
+ {
+ for ( i = 0; i < xsize; i++ )
+ {
+ if ( *index < 0 )
+ {
+ cout << "\n";
+ cout << "PPMA_CHECK_DATA - Fatal error!\n";
+ cout << " Negative data.\n";
+ cout << " " << c << "(" << i << "," << j << ")=" << *index << "\n";
+ return true;
+ }
+ else if ( maxrgb < *index )
+ {
+ cout << "\n";
+ cout << "PPMA_CHECK_DATA - Fatal error!\n";
+ cout << " Data exceeds MAXRGB = " << maxrgb << "\n";
+ cout << " " << c << "(" << i << "," << j << ")=" << *index << "\n";
+ return true;
+ }
+
+ index = index + 1;
+ }
+ }
+ }
+
+ return false;
+}
+//****************************************************************************
+
+bool ppma_example ( int xsize, int ysize, int *r, int *g, int *b )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// PPMA_EXAMPLE sets up some RGB data.
+//
+// Modified:
+//
+// 28 February 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Input, int XSIZE, YSIZE, the number of rows and columns of data.
+//
+// Output, int *R, *G, *B, the arrays of XSIZE by YSIZE RGB values.
+//
+// Output, bool PPMA_EXAMPLE, is
+// false, if no error occurred,
+// true, if an error occurred.
+//
+{
+ float f1;
+ float f2;
+ float f3;
+ int i;
+ int *indexr;
+ int *indexg;
+ int *indexb;
+ int j;
+ float x;
+ float y;
+
+ indexr = r;
+ indexg = g;
+ indexb = b;
+
+ for ( i = 0; i < ysize; i++ )
+ {
+ y = ( float ) ( ysize + 1 - i ) / ( float ) ( ysize - 1 );
+ for ( j = 0; j < xsize; j++ )
+ {
+ x = ( float ) ( j ) / ( float ) ( xsize - 1 );
+
+ f1 = 4.0 * ( x - 0.5 ) * ( x - 0.5 );
+ f2 = sin ( 3.14159265 * x );
+ f3 = x;
+
+ if ( y <= f1 )
+ {
+ *indexr = ( int ) ( 255.0 * f1 );
+ }
+ else
+ {
+ *indexr = 50;
+ }
+
+ if ( y <= f2 )
+ {
+ *indexg = ( int ) ( 255.0 * f2 );
+ }
+ else
+ {
+ *indexg = 150;
+ }
+
+ if ( y <= f3 )
+ {
+ *indexb = ( int ) ( 255.0 * f3 );
+ }
+ else
+ {
+ *indexb = 250;
+ }
+
+ indexr = indexr + 1;
+ indexg = indexg + 1;
+ indexb = indexb + 1;
+ }
+ }
+
+ return false;
+}
+//****************************************************************************
+
+bool ppma_read ( char *file_in_name, int *xsize, int *ysize, int *maxrgb,
+ int **r, int **g, int **b )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// PPMA_READ reads the header and data from an ASCII portable pixel map file.
+//
+// Modified:
+//
+// 28 February 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Input, char *FILE_IN_NAME, the name of the file containing the ASCII
+// portable pixel map data.
+//
+// Output, int *XSIZE, *YSIZE, the number of rows and columns of data.
+//
+// Output, int *MAXRGB, the maximum RGB value.
+//
+// Output, int **R, **G, **B, the arrays of XSIZE by YSIZE data values.
+//
+// Output, bool PPMA_READ, is
+// true, if an error was detected, or
+// false, if the file was read.
+//
+{
+ bool error;
+ ifstream file_in;
+ int numbytes;
+
+ file_in.open ( file_in_name );
+
+ if ( !file_in )
+ {
+ cout << "\n";
+ cout << "PPMA_READ - Fatal error!\n";
+ cout << " Cannot open the input file \"" << file_in_name << "\".\n";
+ return true;
+ }
+//
+// Read the header.
+//
+ error = ppma_read_header ( file_in, xsize, ysize, maxrgb );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "PPMA_READ - Fatal error!\n";
+ cout << " PPMA_READ_HEADER failed.\n";
+ return true;
+ }
+//
+// Allocate storage for the data.
+//
+ numbytes = (*xsize) * (*ysize) * sizeof ( int );
+
+ *r = new int[numbytes];
+ *g = new int[numbytes];
+ *b = new int[numbytes];
+//
+// Read the data.
+//
+ error = ppma_read_data ( file_in, *xsize, *ysize, *r, *g, *b );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "PPMA_READ - Fatal error!\n";
+ cout << " PPMA_READ_DATA failed.\n";
+ return true;
+ }
+//
+// Close the file.
+//
+ file_in.close ( );
+
+ return false;
+}
+//****************************************************************************
+
+bool ppma_read_data ( ifstream &file_in, int xsize, int ysize, int *r,
+ int *g, int *b )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// PPMA_READ_DATA reads the data in an ASCII portable pixel map file.
+//
+// Modified:
+//
+// 07 August 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Input, ifstream &FILE_IN, a pointer to the file containing the ASCII
+// portable pixel map data.
+//
+// Input, int XSIZE, YSIZE, the number of rows and columns of data.
+//
+// Output, int *R, *G, *B, the arrays of XSIZE by YSIZE data values.
+//
+// Output, bool PPMA_READ_DATA, is
+// true, if an error was detected, or
+// false, if the data was read.
+//
+{
+ int i;
+ int j;
+
+ for ( j = 0; j < ysize; j++ )
+ {
+ for ( i = 0; i < xsize; i++ )
+ {
+ file_in >> *r;
+ if ( file_in.eof() )
+ {
+ return true;
+ }
+ r = r + 1;
+
+ file_in >> *g;
+ if ( file_in.eof() )
+ {
+ return true;
+ }
+ g = g + 1;
+
+ file_in >> *b;
+ if ( file_in.eof() )
+ {
+ return true;
+ }
+ b = b + 1;
+ }
+ }
+
+ return false;
+}
+//****************************************************************************
+
+bool ppma_read_header ( ifstream &file_in, int *xsize, int *ysize, int *maxrgb )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// PPMA_READ_HEADER reads the header of an ASCII portable pixel map file.
+//
+// Modified:
+//
+// 28 February 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Input, ifstream &FILE_IN, a pointer to the file containing the ASCII
+// portable pixel map data.
+//
+// Output, int *XSIZE, *YSIZE, the number of rows and columns of data.
+//
+// Output, int *MAXRGB, the maximum RGB value.
+//
+// Output, bool PPMA_READ_HEADER, is
+// true, if an error was detected, or
+// false, if the header was read.
+//
+{
+ int count;
+ char line[255];
+ char *next;
+ int step;
+ int width;
+ char word[255];
+
+ step = 0;
+
+ while ( 1 )
+ {
+ file_in.getline ( line, sizeof ( line ) );
+
+ if ( file_in.eof() )
+ {
+ cout << "\n";
+ cout << "PPMA_READ_HEADER - Fatal error!\n";
+ cout << " End of file.\n";
+ return true;
+ }
+
+ next = line;
+
+ if ( line[0] == '#' )
+ {
+ continue;
+ }
+
+ if ( step == 0 )
+ {
+ count = sscanf ( next, "%s%n", word, &width );
+ if ( count == EOF || count ==0 )
+ {
+ continue;
+ }
+ next = next + width;
+ if ( strcmp ( word, "P3" ) != 0 && strcmp ( word, "p3" ) != 0 )
+ {
+ cout << "\n";
+ cout << "PPMA_READ_HEADER - Fatal error.\n";
+ cout << " Bad magic number = \"" << word << "\".\n";
+ return true;
+ }
+ step = 1;
+ }
+
+ if ( step == 1 )
+ {
+
+ count = sscanf ( next, "%d%n", xsize, &width );
+ next = next + width;
+ if ( count == EOF || count ==0 )
+ {
+ continue;
+ }
+ step = 2;
+ }
+
+ if ( step == 2 )
+ {
+ count = sscanf ( next, "%d%n", ysize, &width );
+ next = next + width;
+ if ( count == EOF || count ==0 )
+ {
+ continue;
+ }
+ step = 3;
+ }
+
+ if ( step == 3 )
+ {
+ count = sscanf ( next, "%d%n", maxrgb, &width );
+ next = next + width;
+ if ( count == EOF || count ==0 )
+ {
+ continue;
+ }
+ break;
+ }
+
+ }
+
+ return false;
+}
+//****************************************************************************
+
+bool ppma_read_test ( char *file_in_name )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// PPMA_READ_TEST tests the ASCII portable pixel map read routines.
+//
+// Modified:
+//
+// 07 August 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Input, char *FILE_IN_NAME, the name of the file containing the ASCII
+// portable pixel map data.
+//
+// Output, bool PPMA_READ_TEST, is
+// true, if an error was detected, or
+// false, if the test was carried out.
+//
+{
+ int *b;
+ bool error;
+ int *g;
+ int maxrgb;
+ int *r;
+ int xsize;
+ int ysize;
+
+ r = NULL;
+ g = NULL;
+ b = NULL;
+//
+// Read the data.
+//
+ error = ppma_read ( file_in_name, &xsize, &ysize, &maxrgb, &r, &g, &b );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "PPMA_READ_TEST - Fatal error!\n";
+ cout << " PPMA_READ failed.\n";
+
+ delete [] r;
+ delete [] g;
+ delete [] b;
+
+ return true;
+ }
+
+ cout << "\n";
+ cout << "PPMA_READ_TEST:\n";
+ cout << " PPMA_READ was able to read \"" << file_in_name << "\".\n";
+//
+// Check the data.
+//
+ error = ppma_check_data ( xsize, ysize, maxrgb, r, g, b );
+
+ delete [] r;
+ delete [] g;
+ delete [] b;
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "PPMA_READ_TEST - Fatal error!\n";
+ cout << " PPMA_CHECK_DATA reports bad data in the file.\n";
+ return true;
+ }
+
+ cout << "\n";
+ cout << "PPMA_READ_TEST:\n";
+ cout << " PPMA_CHECK_DATA has approved the data from the file.\n";
+
+ return false;
+}
+//****************************************************************************
+
+bool ppma_write ( char *file_out_name, int xsize, int ysize, int *r,
+ int *g, int *b )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// PPMA_WRITE writes the header and data for an ASCII portable pixel map file.
+//
+// Example:
+//
+// P3
+// # feep.ppm
+// 4 4
+// 15
+// 0 0 0 0 0 0 0 0 0 15 0 15
+// 0 0 0 0 15 7 0 0 0 0 0 0
+// 0 0 0 0 0 0 0 15 7 0 0 0
+// 15 0 15 0 0 0 0 0 0 0 0 0
+//
+// Modified:
+//
+// 28 February 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Input, char *FILE_OUT_NAME, the name of the file to contain the ASCII
+// portable pixel map data.
+//
+// Input, int XSIZE, YSIZE, the number of rows and columns of data.
+//
+// Input, int *R, *G, *B, the arrays of XSIZE by YSIZE data values.
+//
+// Output, bool PPMA_WRITE, is
+// true, if an error was detected, or
+// false, if the file was written.
+//
+{
+ bool error;
+ ofstream file_out;
+ int i;
+ int *indexb;
+ int *indexg;
+ int *indexr;
+ int j;
+ int maxrgb;
+//
+// Open the output file.
+//
+ file_out.open ( file_out_name );
+
+ if ( !file_out )
+ {
+ cout << "\n";
+ cout << "PPMA_WRITE - Fatal error!\n";
+ cout << " Cannot open the output file \"" << file_out_name << "\".\n";
+ return true;
+ }
+//
+// Compute the maximum.
+//
+ maxrgb = 0;
+ indexr = r;
+ indexg = g;
+ indexb = b;
+
+ for ( j = 0; j < ysize; j++ )
+ {
+ for ( i = 0; i < xsize; i++ )
+ {
+ maxrgb = MAX ( maxrgb, *indexr );
+ maxrgb = MAX ( maxrgb, *indexg );
+ maxrgb = MAX ( maxrgb, *indexb );
+ indexr = indexr + 1;
+ indexg = indexg + 1;
+ indexb = indexb + 1;
+ }
+ }
+//
+// Write the header.
+//
+ error = ppma_write_header ( file_out, file_out_name, xsize, ysize, maxrgb );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "PPMA_WRITE - Fatal error!\n";
+ cout << " PPMA_WRITE_HEADER failed.\n";
+ return true;
+ }
+//
+// Write the data.
+//
+ error = ppma_write_data ( file_out, xsize, ysize, r, g, b );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "PPMA_WRITE - Fatal error!\n";
+ cout << " PPMA_WRITE_DATA failed.\n";
+ return true;
+ }
+//
+// Close the file.
+//
+ file_out.close ( );
+
+ return false;
+}
+//****************************************************************************
+
+bool ppma_write_data ( ofstream &file_out, int xsize, int ysize, int *r,
+ int *g, int *b )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// PPMA_WRITE_DATA writes the data for an ASCII portable pixel map file.
+//
+// Modified:
+//
+// 28 February 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Input, ofstream &FILE_OUT, a pointer to the file to contain the ASCII
+// portable pixel map data.
+//
+// Input, int XSIZE, YSIZE, the number of rows and columns of data.
+//
+// Input, int *R, *G, *B, the arrays of XSIZE by YSIZE data values.
+//
+// Output, bool PPMA_WRITE_DATA, is
+// true, if an error was detected, or
+// false, if the data was written.
+//
+{
+ int i;
+ int *indexb;
+ int *indexg;
+ int *indexr;
+ int j;
+ int numval;
+
+ indexr = r;
+ indexg = g;
+ indexb = b;
+ numval = 0;
+
+ for ( j = 0; j < ysize; j++ )
+ {
+ for ( i = 0; i < xsize; i++ )
+ {
+ file_out << *indexr << " " << *indexg << " " << *indexb;
+ numval = numval + 3;
+ indexr = indexr + 1;
+ indexg = indexg + 1;
+ indexb = indexb + 1;
+
+ if ( numval % 12 == 0 || i == xsize - 1 || numval == 3 * xsize * ysize )
+ {
+ file_out << "\n";
+ }
+ else
+ {
+ file_out << " ";
+ }
+
+ }
+ }
+ return false;
+}
+//****************************************************************************
+
+bool ppma_write_header ( ofstream &file_out, char *file_out_name, int xsize,
+ int ysize, int maxrgb )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// PPMA_WRITE_HEADER writes the header of an ASCII portable pixel map file.
+//
+// Modified:
+//
+// 28 February 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Input, ofstream &FILE_OUT, a pointer to the file to contain the ASCII
+// portable pixel map data.
+//
+// Input, char *FILE_OUT_NAME, the name of the file.
+//
+// Input, int XSIZE, YSIZE, the number of rows and columns of data.
+//
+// Input, int MAXRGB, the maximum RGB value.
+//
+// Output, bool PPMA_WRITE_HEADER, is
+// true, if an error was detected, or
+// false, if the header was written.
+//
+{
+ file_out << "P3\n";
+ file_out << "# " << file_out_name << " created by PPMA_IO::PPMA_WRITE.\n";
+ file_out << xsize << " " << ysize << "\n";
+ file_out << maxrgb << "\n";
+
+ return false;
+}
+//****************************************************************************
+
+bool ppma_write_test ( char *file_out_name )
+
+//****************************************************************************
+//
+// Purpose:
+//
+// PPMA_WRITE_TEST tests the ASCII portable pixel map write routines.
+//
+// Modified:
+//
+// 28 February 2003
+//
+// Author:
+//
+// John Burkardt
+//
+// Parameters:
+//
+// Input, char *FILE_OUT_NAME, the name of the file to contain the ASCII
+// portable pixel map data.
+//
+// Output, bool PPMA_WRITE_TEST, equals
+// true, if the test could not be carried out,
+// false, if the test was carried out.
+//
+{
+ int *b;
+ bool error;
+ int *g;
+ int maxrgb;
+ int *r;
+ int xsize;
+ int ysize;
+
+ xsize = 300;
+ ysize = 300;
+//
+// Allocate memory.
+//
+ r = new int[xsize * ysize];
+ g = new int[xsize * ysize];
+ b = new int[xsize * ysize];
+//
+// Set the data.
+//
+ error = ppma_example ( xsize, ysize, r, g, b );
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "PPMA_WRITE_TEST - Fatal error!\n";
+ cout << " PPMA_EXAMPLE failed.\n";
+ return true;
+ }
+//
+// Write the data to the file.
+//
+ error = ppma_write ( file_out_name, xsize, ysize, r, g, b );
+
+ delete [] r;
+ delete [] g;
+ delete [] b;
+
+ if ( error )
+ {
+ cout << "\n";
+ cout << "PPMA_WRITE_TEST - Fatal error!\n";
+ cout << " PPMA_WRITE failed.\n";
+ return true;
+ }
+
+ return false;
+}
diff --git a/src/ppma_2_bmp/ppma_io.H b/src/ppma_2_bmp/ppma_io.H
new file mode 100644
index 0000000..c9741dd
--- /dev/null
+++ b/src/ppma_2_bmp/ppma_io.H
@@ -0,0 +1,18 @@
+bool ppma_check_data ( int xsize, int ysize, int maxrgb, int *rarray,
+ int *garray, int *barray );
+bool ppma_example ( int xsize, int ysize, int *rarray, int *garray, int *barray );
+
+bool ppma_read ( char *file_in_name, int *xsize, int *ysize, int *maxrgb,
+ int **rarrary, int **garray, int **barray );
+bool ppma_read_data ( ifstream &file_in, int xsize, int ysize, int *rarray,
+ int *garray, int *barray );
+bool ppma_read_header ( ifstream &file_in, int *xsize, int *ysize, int *maxrgb );
+bool ppma_read_test ( char *file_in_name );
+
+bool ppma_write ( char *file_out_name, int xsize, int ysize, int *rarray,
+ int *garray, int *barray );
+bool ppma_write_data ( ofstream &file_out, int xsize, int ysize, int *rarray,
+ int *garray, int *barray );
+bool ppma_write_header ( ofstream &file_out, char *file_out_name, int xsize,
+ int ysize, int maxrgb );
+bool ppma_write_test ( char *file_out_name );
diff --git a/src/profile.c b/src/profile.c
new file mode 100644
index 0000000..e018282
--- /dev/null
+++ b/src/profile.c
@@ -0,0 +1,662 @@
+/*
+ Copyright (c)2005, Trevor Bruen
+ All rights reserved.
+
+ Any feedback is very welcome.
+ email: trevor at mcb.mcgill.ca
+*/
+
+#include <time.h>
+
+#include "global.h"
+#include "profile_options.h"
+#include "misc.h"
+#include "pairScore.h"
+
+
+#include "normal.h"
+#include "stats.h"
+#include "mem.h"
+#include "phylip.h"
+#include "fasta.h"
+#include "seqManip.h"
+
+
+void print_usage()
+{
+
+ fprintf(stderr, "Input file not specified!!! (use -f|-r|-s)\n");
+
+ fprintf(stderr, "Usage: Phi [-f|-s|-r] Filename [-t] AlignmentType\n");
+ fprintf(stderr, " [-w #] [-k #] [- v] [-n #] [-m #]\n\n");
+
+
+ fprintf(stderr, "Options:\n");
+ fprintf(stderr, " -f: Filename = FASTA format\n");
+ fprintf(stderr, " -s: Filename = Strict phylip file\n");
+ fprintf(stderr, " -r: Filename = Relaxed phylip file\n");
+ fprintf(stderr, " -t: AlignmentType = D|A|O where D=DNA\n");
+ fprintf(stderr, " A=AA and O=OTHER [default DNA]\n");
+
+ fprintf(stderr, " -w: # = Change default window size for PHI [default w = 100]\n");
+
+
+
+ fprintf(stderr, " -v: Verbose [default = FALSE]\n");
+
+ fprintf(stderr, " -n: # = Change scanning size for regions to test [default n = 1000]\n");
+ fprintf(stderr, " -m: # = Step size for profile method [default m = 25]\n");
+
+
+
+
+
+}
+
+
+void get_params(int argc, char**argv, options *opt)
+{
+ char *cur,ch,nextch;
+ char temp[MAX_SIZE+1];
+ int i;
+ cbool inFileFound=FALSE;
+
+ opt->doPerm=FALSE;
+ opt->winSize=100;
+ opt->k=0;
+ opt->ntrials=1000;
+ opt->alignKind=DNA;
+ opt->breakWindow=1000;
+ opt->stepSize=25;
+
+ opt->verbose=FALSE;
+
+ if(argc < 3)
+ {
+ print_usage();
+ exit(1);
+ }
+
+
+ for(i=1;i<argc;i++)
+ {
+ cur=argv[i];
+ ch=cur[0];
+
+ //cout<<"Have "<<cur<<" and "<<ch<<endl;
+ if(ch == '-')
+ {
+ ch=toupper(cur[1]);
+ switch(ch)
+ {
+
+ /* Type of sequence */
+ case 'T':
+ i++;
+ cur=argv[i];
+ nextch=toupper(cur[0]);
+ if(nextch == 'D')
+ opt->alignKind=DNA;
+ else if(nextch == 'A')
+ opt->alignKind=AA;
+ else if(nextch == 'O')
+ opt->alignKind=OTHER;
+ else
+ opt->alignKind=OTHER;
+ //Error
+ break;
+
+ /* Fasta file */
+ case 'F':
+ if(!inFileFound)
+ {
+ inFileFound=TRUE;
+ opt->inFile=fasta;
+ i++;
+ strsub(opt->seqFile,argv[i],0);
+ break;
+
+ }
+ else
+ {
+ //Error
+ }
+ break;
+
+ /* Strict phylip */
+ case 'S':
+ if(!inFileFound)
+ {
+ inFileFound=TRUE;
+ opt->inFile=strict;
+ i++;
+ strsub(opt->seqFile,argv[i],0);
+ break;
+
+ }
+ else
+ {
+ //Error
+ }
+ break;
+
+ /* Relaxed phylip */
+ case 'R':
+ if(!inFileFound)
+ {
+ inFileFound=TRUE;
+ opt->inFile=relaxed;
+ i++;
+ strsub(opt->seqFile,argv[i],0);
+ break;
+
+ }
+ else
+ {
+ //Error
+ }
+ break;
+
+ case 'V':
+ opt->verbose=TRUE;
+ break;
+
+
+
+ /* Or window size */
+ case 'W':
+ i++;
+ strsub(temp,argv[i],0);
+ opt->winSize=atof(temp);
+ break;
+
+
+ /* Window size for profile method */
+ case 'N':
+ i++;
+ strsub(temp,argv[i],0);
+ opt->breakWindow=atoi(temp);
+ break;
+
+ /* Step size for profile method*/
+ case 'M':
+ i++;
+ strsub(temp,argv[i],0);
+ opt->stepSize=atoi(temp);
+ break;
+
+ }
+ }
+ else
+ {
+ //Error
+ }
+ }
+ // Error if no file
+ if(!(inFileFound))
+ {
+ print_usage();
+ exit(1);
+ }
+
+}
+void print_vals(FILE *logfile,cbool print_val_a,cbool print_val_b,double val_a, double val_b)
+{
+ if(print_val_a)
+ {
+ fprintf(stdout,"%4.2le ",val_a);
+ fprintf(logfile,"%4.2le ",val_a);
+ }
+ else
+ {
+ fprintf(stdout," -- ");
+ fprintf(logfile," -- ");
+ }
+ if(print_val_b)
+ {
+ fprintf(stdout,"%4.2le\n",val_b);
+ fprintf(logfile,"%4.2le\n",val_b);
+ }
+ else
+ {
+ fprintf(stdout,"--\n");
+ fprintf(logfile,"--\n");
+ }
+
+}
+
+
+int main(int argc, char* argv[])
+{
+ align_type **alignment;
+ char **taxa_names;
+ int num_taxa,num_sites;
+ int num_inf;
+ int pair_inc;
+ double divg,val;
+
+ /*Parameters */
+ options opt;
+
+ /* Number of states at each character and description of each site */
+ int *site_states;
+ site *site_desc;
+
+ /* Counts of incompatibilities */
+ int *counts,max_state,max_inc;
+
+
+ /* Alignment for informative states */
+ align_type **inf_alignment;
+ int *inf_states;
+ site *inf_site_desc;
+
+ /* Alignment by characters */
+ align_type **char_alignment;
+
+ /* Matrix of incompatibilities */
+ int i,j;
+ inc_type **inc_matrix;
+
+ /* Log file */
+ FILE *logfile;
+
+ /* Stuff for profiling... */
+ int big_counter,k;
+ double *values;
+ int num_tests;
+ FILE *vals_file;
+ align_type **new_alignment;
+
+
+ /* Values of statistics */
+ cbool valid_normal_approx;
+ double orig_PHI,cur_PHI;
+ double sum_PHI=0,sum_sq_PHI=0,obs_mean=0,obs_varnce=0;
+ double mean=0.0,variance=0.0;
+ double difference,normal_p_val=0.0;
+ int emp_PHI=0;
+
+ int *permutation;
+
+
+ /* Seed random number generator */
+ srand(time(NULL));
+
+ get_params(argc,argv,&opt);
+
+ /* Open log file */
+
+ logfile=ffopen("Profile.log","w");
+
+
+ fprintf(stdout,"Reading sequence file %s\n",opt.seqFile);
+ fprintf(logfile,"Reading sequence file %s\n",opt.seqFile);
+
+ switch(opt.inFile)
+ {
+ case strict:
+ read_phylip(opt.seqFile,TRUE, &taxa_names,&alignment,&num_taxa,&num_sites);
+ break;
+ case relaxed:
+ read_phylip(opt.seqFile,FALSE, &taxa_names,&alignment,&num_taxa,&num_sites);
+ break;
+ case fasta:
+ read_fasta(opt.seqFile, &taxa_names,&alignment,&num_taxa,&num_sites );
+ break;
+ }
+
+ fprintf(logfile,"Allocating space for %d taxa and %d sites\n",num_taxa,num_sites);
+
+ if(num_taxa<=0 || num_sites<=0)
+ error("No sequences or sitesin alignment");
+
+
+ /* Validate alignment type */
+ validate_alignment(alignment,opt.alignKind,num_taxa,num_sites);
+ fprintf(stdout,"Alignment looks like a valid ");
+ fprintf(logfile,"Alignment looks like a valid ");
+ switch(opt.alignKind)
+ {
+ case DNA:
+ fprintf(stdout,"DNA alignment.\n");
+ fprintf(logfile,"DNA alignment.\n");
+ break;
+ case AA:
+ fprintf(stdout,"AA alignment.\n");
+ fprintf(logfile,"AA alignment.\n");
+ break;
+ case OTHER:
+ fprintf(stdout,"OTHER alignment.\n");
+ fprintf(logfile,"OTHER alignment.\n");
+ break;
+ }
+
+
+ /* Big loop here? */
+ num_tests=(int)((num_sites-opt.breakWindow)/opt.stepSize)+1;
+ values=(double *)mmalloc(num_tests * sizeof(double));
+
+
+ fprintf(stdout,"\nPHI is calculated with w as %3.0lf\n\n",opt.winSize);
+ fprintf(logfile,"\nPHI is calculated with w as %3.0lf\n\n",opt.winSize);
+
+
+ fprintf(stdout,"Checking for recombination using a window size of %d and a step size of %d\n\n",opt.breakWindow,opt.stepSize);
+ fprintf(logfile,"Checking for recombination using a window size of %d and a step size of %d\n\n",opt.breakWindow,opt.stepSize);
+
+ // fprintf(stderr,"Allocated total before is %d\n",(int)alloc_size());
+ for(big_counter=0;big_counter<num_tests;big_counter++)
+ {
+
+ fprintf(stdout,"Checking for recombination at %d between %d and %d\n",big_counter*opt.stepSize+opt.breakWindow/2,big_counter*opt.stepSize,big_counter*opt.stepSize+opt.breakWindow);
+ fprintf(logfile,"Checking for recombination at %d between %d and %d\n",big_counter*opt.stepSize+opt.breakWindow/2,big_counter*opt.stepSize,big_counter*opt.stepSize+opt.breakWindow);
+
+ extract(alignment,num_taxa,num_sites,big_counter*opt.stepSize,big_counter*opt.stepSize+opt.breakWindow,&new_alignment);
+
+ // fprintf(stderr,"After extract is %d\n",(int)alloc_size());
+
+ /* Initialize k*/
+ opt.k=0;
+
+ get_seq_div(new_alignment, opt.alignKind, num_taxa, opt.breakWindow, &divg);
+ if(opt.verbose)
+ {
+ fprintf(stdout,"Estimated diversity is (pairwise deletion - ignoring missing/ambig): %4.1lf%%\n",(divg*100.0));
+ fprintf(logfile,"Estimated diversity is (pairwise deletion - ignoring missing/ambig): %4.1lf%%\n",(divg*100.0));
+ }
+
+ /* Get informative sites */
+ find_states(new_alignment, opt.alignKind,FALSE,num_taxa, opt.breakWindow, &site_desc, &site_states);
+
+ // fprintf(stderr,"After states is %d\n",(int)alloc_size());
+
+
+ get_informative(new_alignment, site_desc, site_states, num_taxa, opt.breakWindow, &num_inf, &inf_alignment, &inf_states, &inf_site_desc);
+
+
+ if(opt.verbose)
+ {
+ fprintf(stdout,"Found %d informative sites.\n",num_inf);
+ fprintf(logfile,"Found %d informative sites.\n",num_inf);
+ }
+
+ // fprintf(stderr,"After informative is %d\n",(int)alloc_size());
+
+
+ /* Allocate possibly sparsely - big matrix sequential stride */
+ inc_matrix=(inc_type **)mmalloc(num_inf * sizeof(inc_type *) );
+ for(i=0;i<num_inf;i++)
+ inc_matrix[i]=(inc_type *)mmalloc( num_inf * sizeof(inc_type));
+
+
+ // fprintf(stderr,"After matrix is %d\n",(int)alloc_size());
+
+ /* Reorder by character */
+ reorder_chars(inf_alignment, opt.alignKind,FALSE,num_inf, num_taxa, &char_alignment);
+
+ // fprintf(stderr,"After character is %d\n",(int)alloc_size());
+ switch(opt.alignKind)
+ {
+ case DNA:
+ max_state=4;
+ break;
+ case AA:
+ max_state=20;
+ break;
+ case OTHER:
+ max_state=MAX_STATE;
+ break;
+ default:
+ max_state=0;
+ }
+ max_inc=max_state*max_state-2*max_state+1;
+
+ // fprintf(stdout,"Calculating all pairwise incompatibilities...\n");
+ /* Now get incompatibilities between all pairs... */
+ for(i=0;i<num_inf;i++)
+ {
+ /* Fix / remove this... */
+ if(i % 100 == 0)
+ {
+ //if(i != 0)
+ // fprintf(stdout,"\b\b\b\b\b\b");
+ // else
+ // fprintf(stdout,"Done: ");
+
+ val=((double)i)*((double)num_inf)-((double)i)*((double)(i+1))/2.0;
+ val=val/(((double)num_inf)*((double)num_inf-1)/2);
+ val=val*100.0;
+ // fprintf(stdout,"%5.1f%%",val);
+
+ // fflush(stdout);
+ }
+
+ for(j=i;j<num_inf;j++)
+ {
+ if(i == j)
+ inc_matrix[i][j]=(inc_type)0;
+ else
+ {
+
+ pair_inc=pair_score(char_alignment, inf_states,i, j, num_inf, num_taxa);
+
+ inc_matrix[i][j]=(inc_type)pair_inc;
+ inc_matrix[j][i]=(inc_type)pair_inc;
+ }
+ }
+ }
+
+ // fprintf(stdout,"\b\b\b\b\b\b");
+ // fprintf(stdout,"%5.1f%%",100.0);
+ // fflush(stdout);
+ // fprintf(stdout,"\n\n");
+
+ inc_stats(max_inc,num_inf,opt.verbose,inc_matrix,&counts,logfile);
+ // fprintf(stderr,"After inc_stats is %d\n",(int)alloc_size());
+ if(opt.k == 0)
+ {
+ val=((double)num_inf)/((double)opt.breakWindow);
+ val=val*opt.winSize;
+
+ opt.k=(int)(val+0.5);
+
+ if(opt.k == 0)
+ opt.k++;
+ }
+ else
+ {
+ val=((double)opt.breakWindow)/((double)num_inf);
+ val=val*opt.k;
+ opt.winSize=val;
+ }
+
+ if(opt.verbose)
+ {
+ fprintf(stdout, "Using a window size of %3.0lf with k as %d\n",opt.winSize,opt.k);
+ fprintf(logfile, "Using a window size of %3.0lf with k as %d\n",opt.winSize,opt.k);
+ }
+
+ permutation=(int *)mmalloc(num_inf * sizeof(int));
+ // fprintf(stderr,"After permutation is %d\n",(int)alloc_size());
+
+ identity_permutation(permutation,num_inf);
+ orig_PHI=PHI(inc_matrix,inf_states,permutation,num_inf,opt.k);
+
+ if(num_inf <= 2*opt.k)
+ {
+ valid_normal_approx=FALSE;
+ fprintf(stdout, "Too few informative sites to use normal approximation.\nTry doing a permutation test or increasing alignment length\nCan also try decreasing windowsize.\n\n");
+ fprintf(logfile, "Too few informative sites to use normal approximation.\nTry doing a permutation test or increasing alignment length\nCan also try decreasing windowsize.\n\n");
+ }
+ else
+ {
+ valid_normal_approx=TRUE;
+ // fprintf(stdout,"\nCalculating analytical mean and variance\n");
+ // fprintf(logfile,"\nCalculating analytical mean and variance\n");
+
+ /* Fix argument with 1 */
+ analytic_mean_variance(inc_matrix,inf_states,num_inf,opt.k,&mean,&variance);
+
+ difference=mean-orig_PHI;
+ normal_p_val=normal_01_cdf((-difference)/sqrt(variance));
+
+ values[big_counter]=normal_01_cdf((-difference)/sqrt(variance));
+
+ if(opt.verbose)
+ {
+ fprintf(stdout,"\nZ-value for PHI is: %le\n",((-difference)/sqrt(variance)));
+ fprintf(logfile,"\nZ-value for PHI is: %le\n",((-difference)/sqrt(variance)));
+ }
+
+ }
+
+ if(opt.doPerm)
+ {
+ if(opt.k >= num_inf)
+ {
+ error("Too few informative sites to test significance. Try decreasing windowsize or increasing alignment length\n\n");
+ }
+ // fprintf(stdout,"\nDoing permutation test for PHI\n");
+ // fprintf(logfile,"\nDoing permutation test for PHI\n");
+ for(i=0;i<opt.ntrials;i++)
+ {
+ sample_permutation(permutation,num_inf);
+ cur_PHI=PHI(inc_matrix,inf_states,permutation,num_inf,opt.k);
+ if(cur_PHI <= orig_PHI)
+ emp_PHI++;
+ sum_PHI=sum_PHI+cur_PHI;
+ sum_sq_PHI=sum_sq_PHI+cur_PHI*cur_PHI;
+
+ }
+ obs_mean=sum_PHI/((double)opt.ntrials);
+ obs_varnce=(sum_sq_PHI-opt.ntrials*obs_mean*obs_mean)/(opt.ntrials-1);
+
+ }
+
+
+ if(opt.verbose)
+ {
+
+ fprintf(stdout,"\n PHI Values\n");
+ fprintf(stdout," ----------\n");
+
+ fprintf(logfile,"\n PHI Values\n");
+ fprintf(logfile," ----------\n");
+
+ if(!opt.doPerm)
+ i=0;
+ else
+ i=opt.ntrials;
+
+ fprintf(stdout," Analytical (%d) Permutations\n\n",i);
+ fprintf(logfile," Analytical (%d) Permutations\n\n",i);
+
+ fprintf(stdout,"Mean: ");
+ fprintf(logfile,"Mean: ");
+
+ print_vals(logfile,valid_normal_approx,opt.doPerm,mean,obs_mean);
+
+ fprintf(stdout,"Variance: ");
+ fprintf(logfile,"Variance: ");
+
+ print_vals(logfile,valid_normal_approx,opt.doPerm,variance,obs_varnce);
+
+ fprintf(stdout,"Observed: %4.2le %4.2le \n\n",orig_PHI,orig_PHI);
+ fprintf(logfile,"Observed: %4.2le %4.2le \n\n",orig_PHI,orig_PHI);
+
+
+
+ fprintf(stdout,"\n **p-Value(s)** \n");
+ fprintf(stdout," ----------\n\n");
+
+
+ fprintf(logfile,"\n p-Value(s)\n");
+ fprintf(logfile," ----------\n\n");
+
+ }
+
+ if(valid_normal_approx)
+ {
+ fprintf(stdout,"PHI (Normal): %4.2le\n",normal_p_val);
+ fprintf(logfile,"PHI (Normal): %4.2le\n",normal_p_val);
+ }
+ else
+ {
+ fprintf(stdout,"PHI (Normal): --\n");
+ fprintf(logfile,"PHI (Normal): --\n");
+ }
+
+ // fprintf(stderr,"Total allocated is %d\n",(int)alloc_size());
+
+ mfree(permutation,sizeof(int)*num_inf);
+ // fprintf(stderr,"Freed permutation %d\n",(int)alloc_size());
+
+ mfree(counts,sizeof(int)*max_inc);
+ // fprintf(stderr,"Freed inc_stats %d\n",(int)alloc_size());
+
+ for(k=0;k<num_inf;k++)
+ {
+ mfree(char_alignment[k],sizeof(align_type) * num_taxa);
+ }
+ mfree(char_alignment,sizeof(align_type *) * num_inf);
+
+ // fprintf(stderr,"Freed char alignment %d\n",(int)alloc_size());
+
+ for(k=0;k<num_inf;k++)
+ {
+ mfree(inc_matrix[k],sizeof(inc_type) * num_inf);
+ }
+ mfree(inc_matrix,sizeof(inc_type *) * num_inf);
+
+
+ // fprintf(stderr,"Freed matrix alignment %d\n",(int)alloc_size());
+
+ for(k=0;k<num_taxa;k++)
+ {
+ // fprintf(stderr,"Freeing taxa %d\n",k);
+ mfree(inf_alignment[k],sizeof(align_type) * num_inf);
+
+ }
+ // fprintf(stderr,"Freeing inf_alignment\n");
+ mfree(inf_alignment,sizeof(align_type *) * num_taxa);
+
+ // fprintf(stderr,"Freed inf_alignment\n");
+
+ mfree(inf_site_desc,sizeof(site) * num_inf);
+ // fprintf(stderr,"Freed inf_site\n");
+ mfree(inf_states,sizeof(int)*num_inf);
+ // fprintf(stderr,"Freed inf_states\n");
+ // fprintf(stderr,"Freed informative alignment %d\n",(int)alloc_size());
+
+ mfree(site_desc,sizeof(site) * opt.breakWindow);
+ mfree(site_states,sizeof(int) * opt.breakWindow);
+
+ // fprintf(stderr,"Freed states%d\n",(int)alloc_size());
+
+ for(k=0;k<num_taxa;k++)
+ {
+ mfree(new_alignment[k],sizeof(align_type) * opt.breakWindow);
+ }
+ mfree(new_alignment,sizeof(align_type *) * num_taxa);
+ // fprintf(stderr,"Freed extract%d\n",(int)alloc_size());
+ // fprintf(stdout,"Total allocated after free is %d\n",(int)alloc_size());
+
+ }
+
+ fprintf(stdout,"Number of tests performed is %d\n\n",num_tests);
+ fprintf(logfile,"Number of tests performed is %d\n\n",num_tests);
+
+ vals_file=ffopen("Profile.csv","w");
+ for(k=0;k<num_tests;k++)
+ {
+ fprintf(vals_file,"%d, %8.7le\n",k*opt.stepSize+(opt.breakWindow)/2,values[k]);
+ }
+ fclose(vals_file);
+
+ fprintf(stdout,"\n");
+ fprintf(logfile,"\n");
+ fclose(logfile);
+ return 0;
+
+}
diff --git a/src/profile_options.h b/src/profile_options.h
new file mode 100644
index 0000000..08fecbb
--- /dev/null
+++ b/src/profile_options.h
@@ -0,0 +1,28 @@
+#ifndef PROFILE_OPTIONS
+#define PROFILE_OPTIONS
+
+typedef struct{
+
+
+ alignmentClass alignKind;
+ fileType inFile;
+
+ char seqFile[MAX_SIZE+1];
+
+ cbool doPerm;
+ int ntrials;
+ cbool otherStats;
+
+ double winSize;
+ int k;
+
+ cbool verbose;
+
+ int breakWindow;
+ int stepSize;
+
+
+} options;
+
+
+#endif
diff --git a/src/queue.c b/src/queue.c
new file mode 100644
index 0000000..2bd90f6
--- /dev/null
+++ b/src/queue.c
@@ -0,0 +1,92 @@
+/*
+ Copyright (c)2005, Trevor Bruen
+ All rights reserved.
+
+ Any feedback is very welcome.
+ email: trevor at mcb.mcgill.ca
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include "queue.h"
+#include "mem.h"
+
+void init_queue(queue *q)
+{
+ (*q).elements=(queue_elem *)mcalloc( (q->max_size),sizeof(queue_elem));
+ q->front=0;
+ q->back=0;
+ q->cur_size=0;
+}
+
+void destroy(queue *q)
+{
+ free((*q).elements);
+}
+
+queue *enqueue(queue *q, queue_elem elem)
+{
+ if(q->cur_size == q->max_size)
+ {
+ return NULL;
+ }
+ else
+ {
+ (*q).elements[q->back]=elem;
+ (q->cur_size)=(q->cur_size)+1;
+ /* Loop around storage space */
+ q->back=(q->back+1) % (q->max_size);
+ }
+ return q;
+}
+
+queue *element_at(queue *q, queue_elem *elem, int index)
+{
+ int mapped_index=0;
+ if(index > q->cur_size)
+ return NULL;
+ else
+ {
+ mapped_index=((q->front)+(index)) % (q->max_size);
+ *elem=(*q).elements[mapped_index];
+
+ }
+ return q;
+}
+
+void clear_queue(queue *q)
+{
+ q->front=0;
+ q->back=0;
+ q->cur_size=0;
+}
+void print_queue(queue *q)
+{
+ int cur=q->cur_size,i;
+ queue_elem elem=0;
+ fprintf(stdout,"Queue: ");
+ for(i=0;i<cur;i++)
+ {
+ element_at(q,&elem,i);
+ fprintf(stdout,"%d ",elem);
+
+ }
+ fprintf(stdout,"\n");
+}
+queue *dequeue_front(queue *q, queue_elem *elem)
+{
+ if(q->cur_size == 0)
+ {
+ //fprintf(stderr,"Cannot dequeue\n");
+ return NULL;
+ }
+ else
+ {
+ *elem=(*q).elements[q->front];
+ (q->cur_size)=(q->cur_size)-1;
+ /* Loop around storage space */
+ q->front=(q->front+1) % (q->max_size);
+
+ }
+ return q;
+}
diff --git a/src/queue.h b/src/queue.h
new file mode 100644
index 0000000..d139ef5
--- /dev/null
+++ b/src/queue.h
@@ -0,0 +1,30 @@
+#ifndef QUEUE
+#define QUEUE 1
+
+typedef int queue_elem;
+
+typedef struct {
+ int max_size;
+ int front;
+ int back;
+ int cur_size;
+ queue_elem *elements;
+} queue;
+
+
+
+void init_queue(queue *q);
+
+void destroy(queue *q);
+
+queue *enqueue(queue *q, queue_elem elem);
+
+queue *element_at(queue *q, queue_elem *elem, int index);
+
+void clear_queue(queue *q);
+
+void print_queue(queue *q);
+
+queue *dequeue_front(queue *q, queue_elem *elem);
+
+#endif
diff --git a/src/seqManip.c b/src/seqManip.c
new file mode 100644
index 0000000..599da88
--- /dev/null
+++ b/src/seqManip.c
@@ -0,0 +1,441 @@
+/*
+ Copyright (c)2005, Trevor Bruen
+ All rights reserved.
+
+ Any feedback is very welcome.
+ email: trevor at mcb.mcgill.ca
+*/
+
+#include "global.h"
+#include "mem.h"
+#include "seqManip.h"
+
+void get_polymorphic( align_type **alignment, site* site_desc, int *site_states, int num_taxa, int num_sites, int *new_num_sites, align_type ***new_alignment, int **new_site_states, site **new_site_desc)
+{
+ int i,j;
+ int site_count=0,polymorphic_count=0;
+ for(i=0;i<num_sites;i++)
+ {
+ if((site_desc[i].poly)==polymorphic)
+ polymorphic_count++;
+ }
+ *new_num_sites=polymorphic_count;
+
+ *new_site_states=(int *)mcalloc(polymorphic_count , sizeof(int));
+ *new_site_desc=(site *)mcalloc(polymorphic_count , sizeof(site));
+ *new_alignment=(align_type **)mcalloc(num_taxa , sizeof(align_type *));
+
+
+ for(i=0;i<num_taxa;i++)
+ ((*new_alignment)[i])=(align_type *)mcalloc(polymorphic_count , sizeof(align_type) );
+
+ for(j=0;j<num_sites;j++)
+ {
+
+ if((site_desc[j].poly)==polymorphic)
+ {
+
+ for(i=0;i<num_taxa;i++)
+ {
+ (*new_alignment)[i][site_count]=alignment[i][j];
+ }
+ (*new_site_states)[site_count]=site_states[j];
+ (*new_site_desc)[site_count].inf=site_desc[j].inf;
+ (*new_site_desc)[site_count].poly=site_desc[j].poly;
+ (*new_site_desc)[site_count].gap=site_desc[j].gap;
+ (*new_site_desc)[site_count].orig_index=site_desc[j].orig_index;
+ (*new_site_desc)[site_count].num_missing=site_desc[j].num_missing;
+ site_count++;
+ }
+ }
+
+}
+
+void extract( align_type **alignment, int num_taxa, int num_sites, int start, int end, align_type ***new_alignment)
+{
+ int i,j;
+ int site_count=0,new_count=end-start;
+
+ *new_alignment=(align_type **)mcalloc(num_taxa , sizeof(align_type *));
+
+
+ for(i=0;i<num_taxa;i++)
+ ((*new_alignment)[i])=(align_type *)mcalloc(new_count , sizeof(align_type) );
+
+ for(j=start;j<end;j++)
+ {
+
+ for(i=0;i<num_taxa;i++)
+ {
+ (*new_alignment)[i][site_count]=alignment[i][j];
+ }
+ site_count++;
+ }
+
+}
+
+
+void get_unambig( align_type **alignment, site* site_desc, int *site_states, int num_taxa, int num_sites, int *new_num_sites, align_type ***new_alignment, int **new_site_states, site **new_site_desc)
+{
+ int i,j;
+ int site_count=0,nongapped_count=0;
+ for(i=0;i<num_sites;i++)
+ {
+ if((site_desc[i].gap)==nongapped && (site_desc[i].num_missing == 0))
+ nongapped_count++;
+ }
+ *new_num_sites=nongapped_count;
+
+ *new_site_states=(int *)mcalloc(nongapped_count , sizeof(int));
+ *new_site_desc=(site *)mcalloc(nongapped_count , sizeof(site));
+ *new_alignment=(align_type **)mcalloc(num_taxa , sizeof(align_type *));
+
+
+ for(i=0;i<num_taxa;i++)
+ ((*new_alignment)[i])=(align_type *)mcalloc(nongapped_count , sizeof(align_type) );
+
+ for(j=0;j<num_sites;j++)
+ {
+
+ if(((site_desc[j].gap)==nongapped) && (site_desc[j].num_missing == 0))
+ {
+
+ for(i=0;i<num_taxa;i++)
+ {
+ (*new_alignment)[i][site_count]=alignment[i][j];
+ }
+ (*new_site_states)[site_count]=site_states[j];
+ (*new_site_desc)[site_count].inf=site_desc[j].inf;
+ (*new_site_desc)[site_count].poly=site_desc[j].poly;
+ (*new_site_desc)[site_count].gap=site_desc[j].gap;
+ (*new_site_desc)[site_count].orig_index=site_desc[j].orig_index;
+ (*new_site_desc)[site_count].num_missing=site_desc[j].num_missing;
+ site_count++;
+ }
+ }
+
+}
+
+
+
+
+/* In: alignment - alignment ordered by taxa
+ site_desc - a description of each site
+ site_states - the number of states at each site
+ num_taxa.. num_inf - number of taxa char, etc..
+ Out: new_num_sites - the new number of sites
+ new_alignment - alignment ordered by taxa with only informative
+ new_site_states - number of states at each informative site
+ new_site_desc - description of states at each informative site
+*/
+
+void get_informative( align_type **alignment, site* site_desc, int *site_states, int num_taxa, int num_sites, int* new_num_sites, align_type ***new_alignment, int **new_site_states, site **new_site_desc)
+{
+ int i,j;
+ int site_count=0,informative_count=0;
+ for(i=0;i<num_sites;i++)
+ {
+ if((site_desc[i].inf)==informative)
+ informative_count++;
+ }
+ *new_num_sites=informative_count;
+
+ *new_site_states=(int *)mcalloc(informative_count , sizeof(int));
+ *new_site_desc=(site *)mcalloc(informative_count , sizeof(site));
+ *new_alignment=(align_type **)mcalloc(num_taxa , sizeof(align_type *));
+
+
+ for(i=0;i<num_taxa;i++)
+ ((*new_alignment)[i])=(align_type *)mcalloc(informative_count , sizeof(align_type) );
+
+ for(j=0;j<num_sites;j++)
+ {
+
+ if((site_desc[j].inf)==informative)
+ {
+
+ for(i=0;i<num_taxa;i++)
+ {
+ (*new_alignment)[i][site_count]=alignment[i][j];
+ }
+ (*new_site_states)[site_count]=site_states[j];
+ (*new_site_desc)[site_count].inf=site_desc[j].inf;
+ (*new_site_desc)[site_count].poly=site_desc[j].poly;
+ (*new_site_desc)[site_count].gap=site_desc[j].gap;
+ (*new_site_desc)[site_count].orig_index=site_desc[j].orig_index;
+ (*new_site_desc)[site_count].num_missing=site_desc[j].num_missing;
+
+ site_count++;
+ }
+ }
+
+}
+
+/* Check validity of alignment */
+cbool validate_alignment(align_type **alignment, alignmentClass alignKind,int num_taxa, int num_sites)
+{
+ int i,j;
+ char ch;
+ char s[MAX_SIZE+1];
+
+ for(i=0;i<num_taxa;i++)
+ {
+ for(j=0;j<num_sites;j++)
+ {
+ ch=alignment[i][j];
+ if(!(validState(alignKind,ch) || missing_ambig_State(alignKind,ch) || (ch == (GLOBAL_GAP-CHAR_START))))
+ {
+ sprintf(s,"Error %c (%d) is not a valid state for this type of sequence\n",ch+CHAR_START,(int)ch+CHAR_START);
+ error(s);
+ }
+
+ }
+
+ }
+ return TRUE;
+
+}
+/* Estimate diversity using pairwise deletion */
+void get_seq_div(align_type **alignment, alignmentClass alignKind, int num_taxa, int num_sites, double *div)
+{
+ int i,j,l,count=0,num=0;
+ double val=0;
+
+ /* fprintf(stdout,"Looking at alignment %d \n",alignKind);*/
+ for(i=0;i<(num_taxa-1);i++)
+ {
+ for(j=(i+1);j<num_taxa;j++)
+ {
+ count=0;
+ num=0;
+ for(l=0;l<num_sites;l++)
+ {
+ if(validState(alignKind,alignment[i][l]) && validState(alignKind,alignment[j][l]))
+ /* if((alignment[i][l] < MAX_STATE) && (alignment[j][l] <MAX_STATE)) */
+ {
+ if(alignment[i][l]!=alignment[j][l])
+ count++;
+ num++;
+ }
+ }
+ val=val+((double)count)/((double)num);
+
+ }
+
+ }
+
+ *div=(val*2)/(num_taxa*(num_taxa-1));
+ //fprintf(stdout,"Found %lf\n",*div);
+}
+
+
+/* In: alignment - ordered by taxa
+ num_taxa - number of taxa
+ num_sites - number of sites
+ Out: site_states - number of states at every site
+ site_desc - type of every site
+
+*/
+void find_states( align_type **alignment, alignmentClass alignKind, cbool stateMissing, int num_taxa, int num_sites, site** site_desc, int** site_states)
+{
+ int state_count,big_states, char_A,i,j;
+ int state_map[MAX_STATE];
+ int missing_ambig_count=0;
+ char s[250];
+
+ cbool gap_char;
+
+ *site_desc=(site *)mcalloc(num_sites , sizeof(site));
+ *site_states=(int *)mcalloc(num_sites , sizeof(int));
+
+ for(j=0;j<num_sites;j++)
+ {
+ for(i=0;i<MAX_STATE;i++)
+ state_map[i]=0;
+
+ state_count=0;
+ gap_char=FALSE;
+ missing_ambig_count=0;
+
+
+ for(i=0;i<num_taxa;i++)
+ {
+ char_A=(int)alignment[i][j];
+
+ if(validState(alignKind,char_A))
+ /* if(char_A <=MAX_STATE) */
+ {
+ if(state_map[char_A]<=0)
+ {
+ state_count++;
+ state_map[char_A]++;
+
+ }
+ else
+ state_map[char_A]++;
+ }
+ else if(missing_ambig_State(alignKind,char_A))
+ {
+ missing_ambig_count++;
+
+ }
+ else if(valid_gap(alignKind,char_A))
+ {
+ gap_char=TRUE;
+ }
+ else
+ {
+ sprintf(s,"Invalid state %c\n",(char_A+CHAR_START));
+ error(s);
+ }
+
+ }
+ /* Add current index to description */
+ ((*site_desc)[j]).orig_index=j;
+
+ if(stateMissing && (missing_ambig_count > 0))
+ state_count++;
+
+ /*Add state count */
+ (*site_states)[j]=state_count;
+
+ ((*site_desc)[j]).num_states=state_count;
+
+ /* Add missing count */
+ ((*site_desc)[j]).num_missing=missing_ambig_count;
+
+
+ /* Check if gapped */
+ if(gap_char)
+ {
+ ((*site_desc)[j]).gap=gapped;
+ }
+ else
+ {
+ ((*site_desc)[j]).gap=nongapped;
+ }
+
+ /* Check if informative */
+ big_states=0;
+
+ if(state_count >= 2)
+ {
+ for(i=0;i<MAX_STATE;i++)
+ if(state_map[i]>= 2)
+ big_states++;
+ if(stateMissing && (missing_ambig_count >=2))
+ big_states++;
+
+ }
+
+
+ if(state_count>=2)
+ {
+ ((*site_desc)[j]).poly=polymorphic;
+ if(big_states>=2)
+ {
+
+ ((*site_desc)[j]).inf=informative;
+
+
+ }
+ else
+ {
+
+ ((*site_desc)[j]).inf=uninformative;
+
+
+ }
+
+ }
+ else
+ {
+ ((*site_desc)[j]).inf=uninformative;
+
+ (*site_desc)[j].poly=constant;
+
+
+ }
+ }
+
+
+
+
+}
+
+
+/* In: alignment - ordered by taxa
+ site_states - number of states at each site
+ num_sites - number of sites
+ num_taxa - number of taxa...
+Out:
+ new_alignment - ordered by character
+ where each character goes from
+ 0..k, for k states, with NEGATIVE
+ states for missing/gaps...
+
+*/
+void reorder_chars( align_type **alignment, alignmentClass alignKind, cbool stateMissing,int num_sites, int num_taxa, align_type ***new_alignment)
+{
+ int state_map[MAX_STATE];
+ int state_count,cur_state;
+ int i,j,k,char_A;
+ *new_alignment=(align_type **)mcalloc(num_sites , sizeof(align_type *));
+
+ for(i=0;i<num_sites;i++)
+ ((*new_alignment)[i])=(align_type *)mcalloc(num_taxa , sizeof(align_type));
+
+
+
+ for(j=0;j<num_sites;j++)
+ {
+ for(k=0;k<MAX_STATE;k++)
+ state_map[k]=-1;
+
+ state_count=0;
+ for(i=0;i<num_taxa;i++)
+ {
+ char_A=(int)alignment[i][j];
+
+ /* Figure out which positive state 0..k */
+ /* if(char_A <=MAX_STATE)*/
+ if(validState(alignKind,char_A))
+ {
+ if(state_map[char_A]<0)
+ {
+ state_map[char_A]=state_count;
+ cur_state=state_count;
+ state_count++;
+
+ }
+ else
+ {
+ cur_state=state_map[char_A];
+ }
+ }
+ else if(missing_ambig_State(alignKind,char_A) && (stateMissing == TRUE))
+ {
+ if(state_map[MISSING_STATE]<0)
+ {
+ state_map[MISSING_STATE]=state_count;
+ cur_state=state_count;
+ state_count++;
+
+ }
+ else
+ {
+ cur_state=state_map[MISSING_STATE];
+ }
+ }
+ /* Otherwise - state that should be ignored - use ignore state */
+ else
+ {
+ cur_state=IGNORE_STATE;
+ }
+ /* Add taxa */
+ (*new_alignment)[j][i]=(align_type)cur_state;
+ }
+
+ }
+
+}
diff --git a/src/seqManip.h b/src/seqManip.h
new file mode 100644
index 0000000..bb3cb3c
--- /dev/null
+++ b/src/seqManip.h
@@ -0,0 +1,55 @@
+#include "global.h"
+#ifndef SEQMANIP
+#define SEQMANIP
+
+
+/* Check validity of alignment */
+cbool validate_alignment(align_type **alignment, alignmentClass alignKind,int num_taxa, int num_sites);
+
+void get_polymorphic( align_type **alignment, site* site_desc, int *site_states, int num_taxa, int num_sites, int *new_num_sites, align_type ***new_alignment, int **new_site_states, site **new_site_desc);
+
+void get_seq_div(align_type **alignment, alignmentClass alignKind, int num_taxa, int num_sites, double *div);
+
+/*void get_seq_div(align_type **alignment, int num_taxa, int num_sites, double *div);*/
+
+
+void extract( align_type **alignment, int num_taxa, int num_sites, int start, int end, align_type ***new_alignment);
+
+void get_unambig( align_type **alignment, site* site_desc, int *site_states, int num_taxa, int num_sites, int *new_num_sites, align_type ***new_alignment, int **new_site_states, site **new_site_desc);
+
+/* In: alignment - alignment ordered by taxa
+ site_desc - a description of each site
+ site_states - the number of states at each site
+ num_taxa.. num_inf - number of taxa char, etc..
+ Out: new_alignment - alignment ordered by taxa with only informative
+ new_site_states - number of states at each informative site
+ new_site_desc - description of states at each informative site
+*/
+void get_informative( align_type **alignment, site* site_desc, int *site_states, int num_taxa, int num_sites, int *new_num_sites, align_type ***new_alignment, int **new_site_states, site **new_site_desc);
+
+/* In: alignment - ordered by taxa
+ Out: site_states - number of states at every site
+ site_desc - type of every site
+ num_inf - number of informative sites
+*/
+void find_states( align_type **alignment, alignmentClass alignKind, cbool ignoreMissing, int num_taxa, int num_sites, site** site_desc, int** site_states);
+
+ /*void find_states( align_type **alignment, int num_taxa, int num_sites, site** site_desc, int** site_states);*/
+
+
+
+/* In: alignment - ordered by taxa
+ site_states - number of states at each site
+ num_sites - number of sites
+ num_taxa - number of taxa...
+Out:
+ new_alignment - ordered by character
+ where each character goes from
+ 0..k, for k states, with NEGATIVE
+ states for missing/gaps...
+
+*/
+/*void reorder_chars( align_type **alignment, int num_sites, int num_taxa, align_type ***new_alignment);*/
+void reorder_chars( align_type **alignment, alignmentClass alignKind, cbool ignoreMissing,int num_sites, int num_taxa, align_type ***new_alignment);
+
+#endif
diff --git a/src/stats.c b/src/stats.c
new file mode 100644
index 0000000..725edbe
--- /dev/null
+++ b/src/stats.c
@@ -0,0 +1,232 @@
+/*
+ Copyright (c)2005, Trevor Bruen
+ All rights reserved.
+
+ Any feedback is very welcome.
+ email: trevor at mcb.mcgill.ca
+*/
+
+#include "global.h"
+#include "stats.h"
+#include "math.h"
+#include "mem.h"
+
+void identity_permutation(int *permutation, int n)
+{
+ int i;
+
+ i=0;
+ for(i=0;i<n;i++)
+ permutation[i]=i;
+}
+
+
+void sample_permutation(int *permutation, int n)
+{
+ int i,temp,val;
+
+ i=0;
+ identity_permutation(permutation,n);
+
+ for(i=0;i<n-1;i++)
+ {
+ val=rand() % (n-i) +i;
+ //fprintf(stdout, "Val is between %d & %d - got %d\n",i,(n-1),val);
+ temp=permutation[i];
+ permutation[i]=permutation[val];
+ permutation[val]=temp;
+ }
+
+}
+
+/* Print out histogram of incompatibilities */
+void inc_stats(int max_size,int num_chars,cbool verbose,inc_type **inc_matrix,int **counts, FILE *logfile)
+{
+ int i,j,total=0,act_max=0;
+ double prop;
+
+ *counts=(int *)mmalloc(max_size * sizeof(int));
+
+ for(i=0;i<max_size;i++)
+ (*counts)[i]=0;
+
+ for(i=0;i<num_chars;i++)
+ {
+ for(j=i+1;j<num_chars;j++)
+ {
+ (*counts)[inc_matrix[i][j]]=(*counts)[inc_matrix[i][j]] +1;
+ if(inc_matrix[i][j] > act_max)
+ act_max=inc_matrix[i][j];
+ }
+ }
+
+ total=(num_chars*(num_chars-1))/2;
+
+
+ /* Print out values */
+ if(verbose)
+ {
+ fprintf(stdout,"Distribution of scaled incompatibility scores:\n");
+ fprintf(stdout,"Score (%c):\n",'%');
+ for(i=0;i<=act_max;i++)
+ {
+ prop=((double) ((*counts)[i]) )/((double)total) * 50.0;
+
+ fprintf(stdout,"%2d (%4.1f): ",i,prop*2);
+ fprintf(logfile,"%2d (%4.1f): ",i,prop*2);
+ for(j=0;j<prop;j++)
+ {
+ fprintf(stdout, "o");
+ fprintf(logfile, "o");
+ }
+ fprintf(stdout,"\n");
+ fprintf(logfile,"\n");
+ }
+ fprintf(stdout,"\n");
+ fprintf(logfile,"\n");
+ }
+
+
+ return;
+}
+
+
+double PHI(inc_type **inc_matrix,int *num_states,int *permutation, int num_chars, int k)
+{
+ int i,j;
+ int p_i,p_j,states_i,states_j;
+ double val;
+ double score=0.0;
+ int terms;
+
+ for(i=0;i<(num_chars-1);i++)
+ {
+ p_i=permutation[i];
+ states_i=num_states[p_i];
+
+ for(j=1;j<=k;j++)
+ {
+ if(i<(num_chars-j))
+ {
+ p_j=permutation[i+j];
+ states_j=num_states[p_j];
+ val=((double)((int)inc_matrix[p_i][p_j]));
+
+ score=score+val;
+ }
+ }
+ }
+ terms=(k*(2*num_chars-k-1))/2;
+ return score/((double)(terms));
+}
+
+
+double NSS(inc_type **inc_matrix, int *permutation, int num_chars)
+{
+ int i,j,count=0,val,next_val;
+ int p_i,p_j,p_j_1;
+ double score=0.0;
+
+ for(i=0;i<num_chars;i++)
+ {
+ p_i=permutation[i];
+ for(j=0;j<(num_chars-1);j++)
+ {
+ p_j=permutation[j];
+ p_j_1=permutation[j+1];
+ val=(int)inc_matrix[p_i][p_j];
+ next_val=(int)inc_matrix[p_i][p_j_1];
+ if(((val>0) && (next_val >0)) || ((val ==0) && (next_val ==0)))
+ score++;
+ count++;
+ }
+ }
+ return score/((double)count);
+}
+
+
+void get_f_and_g(inc_type **inc_matrix,int *num_states,int num_chars, double *f_values,double *g_values)
+ {
+ int i,j;
+ double fscore=0.0,gscore=0.0;
+ double val;
+ for(i=0;i<num_chars;i++)
+ {
+ fscore=0.0;
+ gscore=0.0;
+ f_values[i]=0.0;
+ g_values[i]=0.0;
+
+ for(j=0;j<num_chars;j++)
+ {
+ val=((double)((int)inc_matrix[i][j]));
+ fscore=fscore+val;
+ gscore=gscore+val*val;
+
+ }
+ f_values[i]=fscore;
+ g_values[i]=gscore;
+ }
+ }
+
+void analytic_mean_variance(inc_type** inc_matrix, int* num_states, int num_chars,int k_val, double *mean, double *varnce)
+{
+ double coeff_1,coeff_2,coeff_3,sum1,sum2,sum3;
+ int i;
+
+ double n,top,bottom;
+ double f_vals[num_chars],g_vals[num_chars];
+
+
+ double k=(double)k_val;
+ n=(double)num_chars;
+
+
+ get_f_and_g(inc_matrix,num_states,num_chars,f_vals,g_vals);
+
+
+ /* Figure out mean */
+ sum1=0;
+ for(i=0;i<num_chars;i++)
+ {
+ sum1=sum1+f_vals[i];
+ }
+
+ (*mean)=sum1/((double)(num_chars * (num_chars -1)));
+
+ /* Figure out variance - one term at a time */
+
+ /* First coeff */
+ top=(double)(27*k*n-18*pow(k,2)+28*pow(k,2)*n-21*k*pow(n,2)-9*k+5*n-9*pow(k,3)-11*pow(n,2)+6*pow(n,3)+6*pow(k,3)*n-4*pow(k,2)*pow(n,2));
+ bottom=(double)(k*pow((k+1-2*n),2)*pow((n-1),2)*(n-2)*(n-3)*pow(n,2));
+
+ coeff_1=((2.0)/(3.0))*(top/bottom);
+
+ /* Second coeff */
+ top=(double)(8*pow(k,2)*n-14*pow(k,2)+39*k*n+19*n-21*k+3*pow(k,3)-15*k*pow(n,2)+6*pow(n,3)-21*pow(n,2)-4);
+ bottom=(double)(k*pow((2*n-k-1),2)*n*(n-1)*(n-2)*(n-3));
+
+ coeff_2=((2.0)/(3.0))*(top/bottom);
+
+ /* Third coeff */
+ top=(double)(-18*k*n-2*pow(k,2)*n+16*pow(k,2)+6*pow(n,2)-10*n+2+15*k+3*pow(k,3));
+ bottom=(double)(k*pow((k+1-2*n),2)*n*(n-1)*(n-2)*(n-3));
+ coeff_3=(-4.0/3.0)*(top/bottom);
+
+ /* Now figure out (sum(f))^2, sumg(g) and sum(f^2) */
+ sum1=sum1*sum1;
+
+ sum2=0;
+ for(i=0;i<num_chars;i++)
+ {
+ sum2=sum2+(g_vals[i]);
+ }
+
+ sum3=0;
+ for(i=0;i<num_chars;i++)
+ {
+ sum3=sum3+(f_vals[i])*(f_vals[i]);
+ }
+
+ *varnce=coeff_1*sum1+coeff_2*sum2+coeff_3*sum3;
+}
diff --git a/src/stats.h b/src/stats.h
new file mode 100644
index 0000000..8ae279c
--- /dev/null
+++ b/src/stats.h
@@ -0,0 +1,24 @@
+#ifndef STATS
+#define STATS
+
+void identity_permutation(int *permutation, int n);
+
+
+void sample_permutation(int *permutation, int n);
+
+
+/* Print out histogram of incompatibilities */
+void inc_stats(int max_size,int num_chars,cbool verbose,inc_type **inc_matrix,int **counts, FILE *logfile);
+
+double PHI(inc_type **inc_matrix,int *num_states,int *permutation, int num_chars, int k);
+
+
+double NSS(inc_type **inc_matrix, int *permutation, int num_chars);
+
+
+void get_f_and_g(inc_type **inc_matrix,int *num_states,int num_chars, double *f_values,double *g_values);
+
+void write_diag(const char *file_name,int k,double small_variance, double mean, inc_type** inc_matrix,int *num_states, int num_chars);
+
+void analytic_mean_variance(inc_type** inc_matrix, int* num_states, int num_chars,int k_val ,double *mean, double *varnce) ;
+#endif
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/phipack.git
More information about the debian-med-commit
mailing list