├── .gitignore
├── Doxyfile
├── Makefile
├── Makefiles
├── Makefile.base
├── Makefile.common
├── Makefile.ext
├── Makefile.extlib
├── Makefile.footer
├── Makefile.help
├── Makefile.include
├── Makefile.lib
├── Makefile.src
├── Makefile.test
├── Makefile.tool
├── Makefile.toolchain
└── Makefile.wholepackage
├── README.md
├── bam
├── BamIndex.cpp
├── BamIndex.h
├── BamInterface.cpp
├── BamInterface.h
├── COPYING
├── CigarHelper.cpp
├── CigarHelper.h
├── GenericSamInterface.cpp
├── GenericSamInterface.h
├── Makefile
├── Makefile.depends
├── Pileup.h
├── PileupElement.cpp
├── PileupElement.h
├── PileupElementBaseQual.cpp
├── PileupElementBaseQual.h
├── PosList.cpp
├── PosList.h
├── SamCoordOutput.cpp
├── SamCoordOutput.h
├── SamFile.cpp
├── SamFile.h
├── SamFileHeader.cpp
├── SamFileHeader.h
├── SamFilter.cpp
├── SamFilter.h
├── SamFlag.h
├── SamHeaderHD.cpp
├── SamHeaderHD.h
├── SamHeaderPG.cpp
├── SamHeaderPG.h
├── SamHeaderRG.cpp
├── SamHeaderRG.h
├── SamHeaderRecord.cpp
├── SamHeaderRecord.h
├── SamHeaderSQ.cpp
├── SamHeaderSQ.h
├── SamHeaderTag.cpp
├── SamHeaderTag.h
├── SamHelper.h
├── SamInterface.cpp
├── SamInterface.h
├── SamQuerySeqWithRefHelper.cpp
├── SamQuerySeqWithRefHelper.h
├── SamRecord.cpp
├── SamRecord.h
├── SamRecordHelper.cpp
├── SamRecordHelper.h
├── SamRecordPool.cpp
├── SamRecordPool.h
├── SamReferenceInfo.cpp
├── SamReferenceInfo.h
├── SamStatistics.cpp
├── SamStatistics.h
├── SamStatus.h
├── SamTags.cpp
├── SamTags.h
├── SamValidation.cpp
├── SamValidation.h
├── examples
│ ├── Makefile
│ ├── pileup
│ │ ├── .gitignore
│ │ ├── Main.cpp
│ │ └── Makefile
│ └── printRefPositions
│ │ ├── .gitignore
│ │ ├── Main.cpp
│ │ ├── Makefile
│ │ ├── PrintRefPositions.cpp
│ │ ├── PrintRefPositions.h
│ │ └── expected
│ │ └── test.txt
└── test
│ ├── .gitignore
│ ├── BamIndexTest.cpp
│ ├── BamIndexTest.h
│ ├── Main.cpp
│ ├── Makefile
│ ├── Modify.cpp
│ ├── Modify.h
│ ├── ModifyVar.cpp
│ ├── ModifyVar.h
│ ├── ReadFiles.cpp
│ ├── ReadFiles.h
│ ├── SamFileTest.cpp
│ ├── SamFileTest.h
│ ├── ShiftIndels.cpp
│ ├── ShiftIndels.h
│ ├── TestCigarHelper.cpp
│ ├── TestCigarHelper.h
│ ├── TestEquals.cpp
│ ├── TestEquals.h
│ ├── TestFilter.cpp
│ ├── TestFilter.h
│ ├── TestPileup.cpp
│ ├── TestPileup.h
│ ├── TestPosList.cpp
│ ├── TestPosList.h
│ ├── TestSamCoordOutput.cpp
│ ├── TestSamCoordOutput.h
│ ├── TestSamRecordHelper.cpp
│ ├── TestSamRecordHelper.h
│ ├── TestSamRecordPool.cpp
│ ├── TestSamRecordPool.h
│ ├── TestValidate.cpp
│ ├── TestValidate.h
│ ├── ValidationTest.cpp
│ ├── ValidationTest.h
│ ├── WriteFiles.cpp
│ ├── WriteFiles.h
│ ├── expected
│ ├── TestSamCoordOutput.sam
│ ├── addedTagToBam.bam
│ ├── addedTagToBam.sam
│ ├── addedTagToSam.bam
│ ├── addedTagToSam.sam
│ ├── noZlib
│ │ ├── TestSamCoordOutput.sam
│ │ ├── addedTagToBam.bam
│ │ ├── addedTagToBam.sam
│ │ ├── addedTagToSam.bam
│ │ ├── addedTagToSam.sam
│ │ ├── samTest.log
│ │ ├── testEqWithBases.bam
│ │ ├── testEqWithBases.sam
│ │ ├── testEqWithEq.bam
│ │ ├── testEqWithEq.sam
│ │ ├── testEqWithOrig.bam
│ │ ├── testEqWithOrig.sam
│ │ ├── testShift.bam
│ │ ├── testShift.sam
│ │ ├── updateTag.bam
│ │ ├── updateTagFromBam.sam
│ │ └── updateTagFromSam.sam
│ ├── samTest.log
│ ├── testEqWithBases.bam
│ ├── testEqWithBases.sam
│ ├── testEqWithEq.bam
│ ├── testEqWithEq.sam
│ ├── testEqWithOrig.bam
│ ├── testEqWithOrig.sam
│ ├── testShift.bam
│ ├── testShift.sam
│ ├── updateTag.bam
│ ├── updateTagFromBam.sam
│ └── updateTagFromSam.sam
│ ├── results
│ └── .gitignore
│ ├── test.sh
│ └── testFiles
│ ├── chr1_partial-bs.umfa
│ ├── chr1_partial.fa
│ ├── sortedBam.bam
│ ├── sortedBam.bam.bai
│ ├── sortedBam2.bai
│ ├── sortedBam2.bam
│ ├── testBam.bam
│ ├── testBam1.bam
│ ├── testEq.bam
│ ├── testEq.sam
│ ├── testSam.sam
│ ├── testSam1.sam
│ ├── testSamSOcoord.sam
│ ├── testSamSOinvalid.sam
│ ├── testSamSOquery.sam
│ ├── testShift.bam
│ ├── testShift.sam
│ └── testVar.bam
├── copyrights
├── COPYING
├── COPYING.samtools
├── LICENSE.md5
├── LICENSE.twister
└── LICENSE.txt
├── fastq
├── BaseComposition.cpp
├── BaseComposition.h
├── BaseCount.cpp
├── BaseCount.h
├── COPYING
├── FastQFile.cpp
├── FastQFile.h
├── FastQStatus.cpp
├── FastQStatus.h
├── Makefile
├── Makefile.depends
└── test
│ ├── .gitignore
│ ├── FastQFileTest.cpp
│ ├── FastQValidatorTest.sh
│ ├── Makefile
│ ├── README.txt
│ ├── expectedResults
│ └── ExpectedResultsFastqTestResults.txt
│ └── testFile.txt
├── general
├── BaseAsciiMap.cpp
├── BaseAsciiMap.h
├── BaseQualityHelper.cpp
├── BaseQualityHelper.h
├── BaseUtilities.cpp
├── BaseUtilities.h
├── BasicHash.cpp
├── BasicHash.h
├── BgzfFileType.cpp
├── BgzfFileType.h
├── BgzfFileTypeRecovery.cpp
├── BgzfFileTypeRecovery.h
├── CSG_MD5.h
├── CharBuffer.cpp
├── CharBuffer.h
├── Chromosome.cpp
├── Chromosome.h
├── Cigar.cpp
├── Cigar.h
├── CigarRoller.cpp
├── CigarRoller.h
├── Constant.h
├── Error.cpp
├── Error.h
├── ErrorHandler.cpp
├── ErrorHandler.h
├── FileType.cpp
├── FileType.h
├── FortranFormat.cpp
├── FortranFormat.h
├── Generic.cpp
├── Generic.h
├── GenomeSequence.cpp
├── GenomeSequence.h
├── GenomeSequenceHelpers.h
├── GenotypeLists.cpp
├── GenotypeLists.h
├── GreedyTupleAligner.h
├── GzipFileType.cpp
├── GzipFileType.h
├── GzipHeader.cpp
├── GzipHeader.h
├── Hash.cpp
├── Hash.h
├── IndexBase.cpp
├── IndexBase.h
├── InplaceMerge.cpp
├── InplaceMerge.h
├── Input.cpp
├── Input.h
├── InputFile.cpp
├── InputFile.h
├── IntArray.cpp
├── IntArray.h
├── IntHash.cpp
├── IntHash.h
├── LICENSE.twister
├── LICENSE.txt
├── LongHash.h
├── LongInt.h
├── LongLongCounter.cpp
├── LongLongCounter.h
├── Makefile
├── Makefile.depends
├── MapFunction.cpp
├── MapFunction.h
├── MathConstant.h
├── MathMatrix.cpp
├── MathMatrix.h
├── MathVector.cpp
├── MathVector.h
├── MemoryAllocators.cpp
├── MemoryAllocators.h
├── MemoryInfo.cpp
├── MemoryInfo.h
├── MemoryMap.cpp
├── MemoryMap.h
├── MemoryMapArray.cpp
├── MemoryMapArray.h
├── MiniDeflate.cpp
├── MiniDeflate.h
├── NonOverlapRegions.cpp
├── NonOverlapRegions.h
├── PackedVector.h
├── Parameters.cpp
├── Parameters.h
├── Pedigree.cpp
├── Pedigree.h
├── PedigreeAlleleFreq.cpp
├── PedigreeAlleleFreq.h
├── PedigreeAlleles.h
├── PedigreeDescription.cpp
├── PedigreeDescription.h
├── PedigreeFamily.cpp
├── PedigreeFamily.h
├── PedigreeGlobals.cpp
├── PedigreeGlobals.h
├── PedigreeLoader.cpp
├── PedigreePerson.cpp
├── PedigreePerson.h
├── PedigreeTrim.cpp
├── PedigreeTwin.cpp
├── Performance.h
├── PhoneHome.cpp
├── PhoneHome.h
├── QuickIndex.cpp
├── QuickIndex.h
├── Random.cpp
├── Random.h
├── ReferenceSequence.cpp
├── ReferenceSequence.h
├── ReusableVector.h
├── STLUtilities.cpp
├── STLUtilities.h
├── SimpleStats.h
├── SmithWaterman.cpp
├── SmithWaterman.h
├── Sort.cpp
├── Sort.h
├── StatGenStatus.cpp
├── StatGenStatus.h
├── String.cpp
├── StringAlias.cpp
├── StringAlias.h
├── StringArray.cpp
├── StringArray.h
├── StringBasics.cpp
├── StringBasics.h
├── StringHash.cpp
├── StringHash.h
├── StringMap.cpp
├── StringMap.h
├── Tabix.cpp
├── Tabix.h
├── TrimSequence.h
├── UncompressedFileType.cpp
├── UncompressedFileType.h
├── UnitTest.h
├── glfHandler.cpp
├── glfHandler.h
├── obj
│ └── README.txt
└── test
│ ├── Chromosome_test.cpp
│ ├── GenomeSequence_test.cpp
│ ├── GreedyTupleAligner_test.cpp
│ ├── Makefile
│ ├── STLUtilities_test.cpp
│ ├── TrimSequence_test.cpp
│ ├── baseUtilitiesTest
│ ├── .gitignore
│ ├── BaseUtilitiesTest.cpp
│ ├── BaseUtilitiesTest.h
│ └── Makefile
│ ├── cigar
│ ├── .gitignore
│ ├── CigarRollerTest.cpp
│ ├── CigarRollerTest.h
│ └── Makefile
│ ├── dbsnp
│ ├── .gitignore
│ ├── Main.cpp
│ ├── Makefile
│ ├── expected
│ │ └── results.txt
│ └── testFiles
│ │ ├── chr1_partial-bs.umfa
│ │ ├── chr1_partial.fa
│ │ ├── dbsnp.vcf
│ │ └── dbsnp.vcf.gz
│ ├── gtest.cpp
│ ├── inputFileTest
│ ├── .gitignore
│ ├── InputFileTest.cpp
│ ├── InputFileTest.h
│ ├── Makefile
│ ├── data
│ │ ├── InputFileTest.bam
│ │ ├── InputFileTest.glf
│ │ ├── InputFileTest.gz
│ │ ├── InputFileTest.txt
│ │ ├── InputFileTest2.gz
│ │ ├── InputFileTest2.txt
│ │ ├── InputFileTestLarge.bam
│ │ ├── InputFileTestLarge.glf
│ │ ├── InputFileTestLarge.gz
│ │ ├── InputFileTestLarge.txt
│ │ ├── textFile.gz
│ │ └── textFile.txt
│ └── expected
│ │ ├── results.log
│ │ └── resultsNoZlib.log
│ ├── memoryMapArrayTest
│ ├── .gitignore
│ ├── Makefile
│ ├── MemoryMapArrayTest.cpp
│ └── MemoryMapArrayTest.h
│ ├── nonOverlapRegions
│ ├── .gitignore
│ ├── Makefile
│ ├── NonOverlapRegionsTest.cpp
│ ├── NonOverlapRegionsTest.h
│ ├── expectedNonOverlapRegionsTest.txt
│ └── results
│ │ └── .gitignore
│ ├── packedVectorTest
│ ├── .gitignore
│ ├── Makefile
│ ├── PackedVectorTest.cpp
│ └── PackedVectorTest.h
│ ├── phiX.fa
│ ├── referenceSequenceTest
│ ├── .gitignore
│ ├── Makefile
│ ├── ReferenceSequenceTest.cpp
│ └── ReferenceSequenceTest.h
│ ├── reusableVector
│ ├── .gitignore
│ ├── Makefile
│ ├── ReusableVectorTest.cpp
│ └── ReusableVectorTest.h
│ ├── string
│ ├── .gitignore
│ ├── Makefile
│ ├── StringTest.cpp
│ ├── StringTest.h
│ └── testFiles
│ │ └── testFile.txt
│ ├── test_memmap_data.txt
│ └── trimSequence
│ ├── .gitignore
│ ├── Makefile
│ └── TrimSequence.cpp
├── glf
├── COPYING
├── GlfException.cpp
├── GlfException.h
├── GlfFile.cpp
├── GlfFile.h
├── GlfHeader.cpp
├── GlfHeader.h
├── GlfRecord.cpp
├── GlfRecord.h
├── GlfRefSection.cpp
├── GlfRefSection.h
├── GlfStatus.cpp
├── GlfStatus.h
├── Makefile
├── Makefile.depends
└── test
│ ├── .gitignore
│ ├── Main.cpp
│ ├── Makefile
│ ├── ReadFiles.cpp
│ ├── ReadFiles.h
│ ├── Validate.cpp
│ ├── Validate.h
│ ├── WriteFiles.cpp
│ ├── WriteFiles.h
│ ├── results
│ └── .gitignore
│ └── testFiles
│ └── testGlf.glf
├── include
└── .gitignore
├── samtools
├── COPYING
├── Makefile
├── Makefile.depends
├── README.txt
├── bam.h
├── bgzf.c
├── bgzf.h
├── khash.h
├── knetfile.c
└── knetfile.h
└── vcf
├── Makefile
├── VcfFile.cpp
├── VcfFile.h
├── VcfFileReader.cpp
├── VcfFileReader.h
├── VcfFileWriter.cpp
├── VcfFileWriter.h
├── VcfGenotypeField.cpp
├── VcfGenotypeField.h
├── VcfGenotypeFormat.cpp
├── VcfGenotypeFormat.h
├── VcfGenotypeSample.cpp
├── VcfGenotypeSample.h
├── VcfHeader.cpp
├── VcfHeader.h
├── VcfHelper.cpp
├── VcfHelper.h
├── VcfRecord.cpp
├── VcfRecord.h
├── VcfRecordDiscardRules.cpp
├── VcfRecordDiscardRules.h
├── VcfRecordField.cpp
├── VcfRecordField.h
├── VcfRecordFilter.cpp
├── VcfRecordFilter.h
├── VcfRecordGenotype.cpp
├── VcfRecordGenotype.h
├── VcfRecordInfo.cpp
├── VcfRecordInfo.h
├── VcfSubsetSamples.cpp
├── VcfSubsetSamples.h
└── test
├── .gitignore
├── Main.cpp
├── Makefile
├── VcfFileTest.cpp
├── VcfFileTest.h
├── VcfHeaderTest.cpp
├── VcfHeaderTest.h
├── expected
├── vcfFileNoInfo.vcf
├── vcfFileNoInfoBGZF.vcf
├── vcfFileNoInfoKeepGQHQ.vcf
├── vcfFileNoInfoKeepGT.vcf
└── vcfHeader.vcf
├── results
└── .gitignore
└── testFiles
├── exclude2.txt
├── excludeIDs.txt
├── includeIDs.txt
├── subset1.txt
├── subset2.txt
├── testTabix.vcf
├── testTabix.vcf.bgzf
├── testTabix.vcf.bgzf.tbi
├── testTabixBadIndex.vcf.bgzf
├── testTabixBadIndex.vcf.bgzf.tbi
└── vcfFile.vcf
/.gitignore:
--------------------------------------------------------------------------------
1 | *~
2 | *.o
3 | *.a
4 | *.bak
5 | dox/
6 | dox_errors.txt
7 | *#
8 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | VERSION ?= 1.0.14
2 |
3 | .PHONY: package
4 |
5 | SUBDIRS=general bam fastq glf samtools vcf
6 |
7 | include Makefiles/Makefile.base
8 |
9 |
10 | clean:$(SUBDIRS)
11 | rm -f $(STAT_GEN_LIB_OPT)
12 | rm -f $(STAT_GEN_LIB_DEBUG)
13 | rm -f $(STAT_GEN_LIB_PROFILE)
14 |
15 | # general depends on samtools
16 | general: samtools
17 |
18 | # other subdirectories depend on general
19 | bam fastq glf vcf: general
20 |
21 | RELEASE_FILE?=libStatGen.$(VERSION).tgz
22 |
23 | # Package the library.
24 | package :
25 | # the touch gets rid of a tar warning
26 | touch $(RELEASE_FILE)
27 | tar chvz --exclude="*~" --exclude=$(RELEASE_FILE) --exclude='obj/*' --exclude='*.a' --exclude='include/*' --exclude='bin/*' --exclude='test/results/*' --exclude-vcs -f $(RELEASE_FILE) --transform 's,^,libStatGen_$(VERSION)/,' * --show-transformed-names
28 |
--------------------------------------------------------------------------------
/Makefiles/Makefile.base:
--------------------------------------------------------------------------------
1 | # SUBDIRS should be set by the Makefile that includes this one.
2 | # SUBDIRS =
3 |
4 | MAKEFILES_PATH := $(dir $(lastword $(MAKEFILE_LIST)))
5 | include $(MAKEFILES_PATH)Makefile.include
6 |
7 | # Build in all subdirectories.
8 |
9 |
10 | .PHONY: $(SUBDIRS)
11 |
12 | include $(MAKEFILES_PATH)Makefile.help
13 |
14 | $(SUBDIRS):
15 | @$(MAKE) -C $@ $(MAKECMDGOALS)
16 |
17 | %: $(SUBDIRS) ;
18 |
19 | Makefile.%: ;
20 |
21 | Makefile: ;
22 |
--------------------------------------------------------------------------------
/Makefiles/Makefile.extlib:
--------------------------------------------------------------------------------
1 | # Your Makefile should include this Makefile after defining:
2 | # EXE - the library name
3 | # TOOLBASE - the base filename for files with .h & .cpp versions
4 | # SRCONLY - any cpp files without headers.
5 | # HDRONLY - any header files without cpp
6 | # COMPILE_ANY_CHANGE - any files that should be compiled if any of the
7 | # files change. These files MUST also be
8 | # included in TOOLBASE or SRCONLY. Here they are
9 | # just the base name without the extension.
10 | # VERSION - if not version in Makefile.include
11 | # BINDIR if it is not ../lib
12 | # TESTDIR if it is not ../test
13 | # USER_INCLUDES if any additional directories need to be included to pick up
14 | # header files (example: USER_INCLUDES=-ImyDir1 -ImyDir2)
15 | EXE ?=
16 | BINDIR ?= ../lib
17 | TESTDIR ?= ../test
18 |
19 | MAKEFILES_PATH := $(dir $(lastword $(MAKEFILE_LIST)))
20 | include $(MAKEFILES_PATH)Makefile.ext
21 |
22 | # Set the build commands for library
23 | OPT_BUILD = ar -cr $(PROG_OPT) $(OBJECTS_OPT)
24 | DEBUG_BUILD = ar -cr $(PROG_DEBUG) $(OBJECTS_DEBUG)
25 | PROFILE_BUILD = ar -cr $(PROG_PROFILE) $(OBJECTS_PROFILE)
26 |
27 | specific_clean :
28 | -$(AR) d $(PROG_OPT) $(OBJECTS_OPT)
29 | -$(RANLIB) $(PROG_OPT)
30 | -$(AR) d $(PROG_DEBUG) $(OBJECTS_DEBUG)
31 | -$(RANLIB) $(PROG_DEBUG)
32 | -$(AR) d $(PROG_PROFILE) $(OBJECTS_PROFILE)
33 | -$(RANLIB) $(PROG_PROFILE)
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Makefiles/Makefile.footer:
--------------------------------------------------------------------------------
1 |
2 | #
3 | # The newest version of astyle will remove parens in a statement
4 | # header (the character following if/while/do). The current
5 | # version in Ubuntu does not.
6 | #
7 | # See http://astyle.sourceforge.net/astyle.html#_Padding_Options
8 | #
9 | style:
10 | (command -v astyle || echo "astyle not installed.")
11 | (command -v astyle && astyle --style=ansi --preserve-date --unpad-paren --indent-switches *.cpp *.h)
12 |
13 |
14 | # DFLAGS=-I$(HEADER_DIR) -I/usr/include/g++
15 | DFLAGS=-Y $(CFLAGS)
16 |
17 | cleandepend:
18 | makedepend -- $(DFLAGS) --
19 |
20 | depend:
21 | makedepend -- $(DFLAGS) -- $(SOURCES) >/dev/null 2>&1
22 |
--------------------------------------------------------------------------------
/Makefiles/Makefile.help:
--------------------------------------------------------------------------------
1 | help :
2 | @echo "Makefile help"
3 | @echo "-------------"
4 | @echo "Type... To..."
5 | @echo "make Compile opt "
6 | @echo "make help Display this help screen"
7 | @echo "make all Compile everything (opt, debug, & profile)"
8 | @echo "make opt Compile optimized"
9 | @echo "make debug Compile for debug"
10 | @echo "make profile Compile for profile"
11 | @echo "make clean Delete temporary files"
12 | @echo "make test Execute tests (if there are any)"
13 | $(ADDITIONAL_HELP)
14 |
--------------------------------------------------------------------------------
/Makefiles/Makefile.lib:
--------------------------------------------------------------------------------
1 | # Your Makefile should include this Makefile after defining:
2 | # TOOLBASE - the base filename for files with .h & .cpp versions
3 | # SRCONLY - any cpp files without headers.
4 | # HDRONLY - any header files without cpp
5 | # VERSION - if not version in Makefile.include
6 |
7 | MAKEFILES_PATH := $(dir $(lastword $(MAKEFILE_LIST)))
8 |
9 | OBJDIR = obj
10 | include $(MAKEFILES_PATH)Makefile.common
11 |
12 | HEADERS=$(TOOLHDR)
13 |
14 |
15 |
16 | .PHONY: all test clean debug profile param install specific_clean $(STAT_GEN_LIB) $(STAT_GEN_LIB_DEBUG) $(STAT_GEN_LIB_PROFILE)
17 |
18 | # make everything, ensure headers are in the include direcotry.
19 | opt debug profile : $(addprefix $(INCLUDE_PATH)/, $(HEADERS))
20 |
21 | install: opt
22 |
23 | # Link into the include directory
24 | $(INCLUDE_PATH)/%.h: %.h
25 | -ln -s ../$(DIR_NAME)/$< $@
26 |
27 |
28 | #########
29 | # Build the library
30 | opt: $(STAT_GEN_LIB_OPT)
31 | debug: $(STAT_GEN_LIB_DEBUG)
32 | profile: $(STAT_GEN_LIB_PROFILE)
33 |
34 | # To build the library, build the objects
35 | # Then add them to the library
36 | $(STAT_GEN_LIB_OPT): $(OBJECTS_OPT)
37 | ar -cru $@ $(OBJECTS_OPT)
38 | $(STAT_GEN_LIB_DEBUG): $(OBJECTS_DEBUG)
39 | ar -cru $@ $(OBJECTS_DEBUG)
40 | $(STAT_GEN_LIB_PROFILE): $(OBJECTS_PROFILE)
41 | ar -cru $@ $(OBJECTS_PROFILE)
42 |
43 | UNAME=$(shell uname)
44 |
45 | ifeq ($(UNAME), Darwin)
46 | specific_clean:
47 | -rm -f $(addprefix $(INCLUDE_PATH)/, $(HEADERS))
48 | -$(AR) d $(STAT_GEN_LIB_OPT) $(OBJECTS_OPT)
49 | -$(RANLIB) $(STAT_GEN_LIB_OPT)
50 | -$(AR) d $(STAT_GEN_LIB_DEBUG) $(OBJECTS_DEBUG)
51 | -$(RANLIB) $(STAT_GEN_LIB_DEBUG)
52 | -$(AR) d $(STAT_GEN_LIB_PROFILE) $(OBJECTS_PROFILE)
53 | -$(RANLIB) $(STAT_GEN_LIB_PROFILE)
54 | else
55 | specific_clean:
56 | -rm -f $(addprefix $(INCLUDE_PATH)/, $(HEADERS))
57 | $(AR) d $(STAT_GEN_LIB_OPT) $(OBJECTS_OPT)
58 | $(RANLIB) $(STAT_GEN_LIB_OPT)
59 | $(AR) d $(STAT_GEN_LIB_DEBUG) $(OBJECTS_DEBUG)
60 | $(RANLIB) $(STAT_GEN_LIB_DEBUG)
61 | $(AR) d $(STAT_GEN_LIB_PROFILE) $(OBJECTS_PROFILE)
62 | $(RANLIB) $(STAT_GEN_LIB_PROFILE)
63 | endif
64 |
--------------------------------------------------------------------------------
/Makefiles/Makefile.test:
--------------------------------------------------------------------------------
1 | # Your Makefile should include this Makefile after defining:
2 | # TEST_COMMAND - the commands to run under make test
3 | # EXE - executable built for this test.
4 | # TOOLBASE - the base filename for files with .h & .cpp versions
5 | # SRCONLY - any cpp files without headers.
6 | # HDRONLY - any header files without cpp
7 | # VERSION - if not 0.0.1
8 | TEST_COMMAND ?=
9 | EXE ?=
10 | TOOLBASE ?=
11 | SRCONLY ?=
12 | HDRONLY ?=
13 | VERSION ?= 0.0.1
14 |
15 | MAKEFILES_PATH := $(dir $(lastword $(MAKEFILE_LIST)))
16 | include $(MAKEFILES_PATH)Makefile.include
17 |
18 | # Use debug opt flag.
19 | OPTFLAG?=$(OPTFLAG_DEBUG)
20 | OBJDIR?=obj
21 | #
22 | # Goncalo's Generic Makefile -- Compiles and installs a Generic Goncalo Tool
23 | # (c) 2000-2007 Goncalo Abecasis
24 | #
25 |
26 | # Source File Set
27 | # For best results, consider editing this manually ...
28 | TOOLHDR = $(TOOLBASE:=.h) $(HDRONLY)
29 | TOOLSRC = $(TOOLBASE:=.cpp) $(SRCONLY)
30 | TOOLOBJ = $(TOOLSRC:.cpp=.o)
31 | LIBRARY = $(REQ_LIBS_DEBUG)
32 | OBJECTS=$(patsubst %,$(OBJDIR)/%,$(TOOLOBJ))
33 |
34 | .DEFAULT_GOAL := all
35 |
36 | # make everything
37 | all debug: $(EXE)
38 |
39 | # dependencies for executables
40 | $(EXE) : $(LIBRARY) $(OBJECTS)
41 | $(CXX) $(COMPFLAGS) -o $@ $(OBJECTS) $(LIBRARY) -lm $(ZLIB_LIB) $(UNAME_LIBS)
42 |
43 | $(OBJECTS): $(TOOLHDR) $(LIBHDR) | $(OBJDIR)
44 |
45 | $(OBJDIR):
46 | mkdir $(OBJDIR)
47 |
48 | clean :
49 | -rm -rf $(OBJDIR) $(EXE) *~ results/*
50 | $(TEST_CLEAN)
51 |
52 | test : all
53 | $(TEST_COMMAND)
54 |
55 | $(OBJDIR)/%.o: %.c
56 | $(CXX) $(COMPFLAGS) -o $@ -c $*.c
57 |
58 | $(OBJDIR)/%.o: %.cpp
59 | $(CXX) $(COMPFLAGS) -o $@ -c $*.cpp -DVERSION="\"$(VERSION)\""
60 |
61 | .SUFFIXES : .cpp .c .o .X.o $(SUFFIXES)
62 |
63 | DFLAGS=-Y
64 |
65 | cleandepend:
66 | makedepend -- $(DFLAGS) --
67 |
68 | depend:
69 | makedepend -- $(DFLAGS) -- $(TOOLSRC) >/dev/null 2>&1
70 |
71 | # DO NOT DELETE THIS LINE -- make depend depends on it
72 |
--------------------------------------------------------------------------------
/Makefiles/Makefile.tool:
--------------------------------------------------------------------------------
1 |
2 | MAKEFILES_PATH := $(dir $(lastword $(MAKEFILE_LIST)))
3 | include $(MAKEFILES_PATH)Makefile.base
4 |
5 | RELEASE_FILE?=$(DIR_NAME).$(VERSION).tgz
6 |
7 | ADDITIONAL_HELP= @echo "make install Install binaries in $(INSTALLDIR)";\
8 | echo "make install INSTALLDIR=directory_for_binaries";\
9 | echo " Install binaries in directory_for_binaries"
10 |
11 |
12 | .PHONY: package wholepackage
13 |
14 | # Does not include the library.
15 | package :
16 | # the touch gets rid of a tar warning
17 | touch $(RELEASE_FILE)
18 | tar chvz --exclude="*~" --exclude=$(RELEASE_FILE) --exclude='obj/*' --exclude='*.a' --exclude='include/*' --exclude='bin/*' --exclude='test/results/*' --exclude-vcs -f $(RELEASE_FILE) --transform 's,^,$(DIR_NAME)_$(VERSION)/,' * --show-transformed-names
19 |
20 | BASE_LIB_PARTS := $(subst /, , $(BASE_LIB_PATH))
21 | BASE_LIB_DIRNAME := $(word $(words $(BASE_LIB_PARTS)), $(BASE_LIB_PARTS))
22 | WHOLEPACKAGE_MAKE := $(BASE_LIB_DIRNAME)/Makefiles/Makefile.wholepackage
23 |
24 | DIR_ABOVE_LIB := $(patsubst %$(BASE_LIB_DIRNAME)/, %, $(BASE_LIB_PATH))
25 |
26 | # also includes the library
27 | wholepackage:
28 | # the touch gets rid of a tar warning
29 | touch $(RELEASE_FILE)
30 | tar chvz --exclude="*~" --exclude=$(RELEASE_FILE) --exclude='obj/*' --exclude='*.a' --exclude='include/*' --exclude='bin/*' --exclude='test/results/*' --exclude-vcs -f $(RELEASE_FILE) --transform 's,^,$(DIR_NAME)_$(VERSION)/,;s,$(WHOLEPACKAGE_MAKE),Makefile,' -C .. $(DIR_NAME) -C $(DIR_NAME) -C $(DIR_ABOVE_LIB) $(BASE_LIB_DIRNAME) --show-transformed-names
31 |
--------------------------------------------------------------------------------
/Makefiles/Makefile.wholepackage:
--------------------------------------------------------------------------------
1 | SUBDIRS = $(sort $(dir $(wildcard */)))
2 |
3 | SUBDIRS_NO_STATGEN = $(filter-out libStatGen/,$(SUBDIRS))
4 |
5 | MAKEFILES_PATH := libStatGen/Makefiles/
6 | include $(MAKEFILES_PATH)Makefile.include
7 |
8 | # Build in all subdirectories.
9 |
10 |
11 | .PHONY: $(SUBDIRS)
12 |
13 | include $(MAKEFILES_PATH)Makefile.help
14 |
15 | $(SUBDIRS):
16 | @$(MAKE) -C $@ $(MAKECMDGOALS)
17 |
18 | $(SUBDIRS_NO_STATGEN): libStatGen/
19 |
20 | %: $(SUBDIRS) ;
21 |
22 | Makefile.%: ;
23 |
24 | Makefile: ;
25 | SUBDIRS = $(sort $(dir $(wildcard */)))
26 |
--------------------------------------------------------------------------------
/bam/GenericSamInterface.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "GenericSamInterface.h"
19 |
20 |
21 | GenericSamInterface::GenericSamInterface()
22 | {
23 | }
24 |
25 | GenericSamInterface::~GenericSamInterface()
26 | {
27 | }
28 |
29 | bool GenericSamInterface::isEOF(IFILE filePtr)
30 | {
31 | if (filePtr != NULL)
32 | {
33 | // File Pointer is set, so return if eof.
34 | return(ifeof(filePtr));
35 | }
36 | // File pointer is not set, so return true, eof.
37 | return true;
38 | }
39 |
--------------------------------------------------------------------------------
/bam/Makefile:
--------------------------------------------------------------------------------
1 | TOOLBASE = SamFileHeader SamFile GenericSamInterface SamInterface BamInterface SamRecord BamIndex SamHeaderHD SamHeaderPG SamHeaderRecord SamHeaderSQ SamHeaderRG SamHeaderTag SamValidation SamStatistics SamQuerySeqWithRefHelper SamFilter PileupElement PileupElementBaseQual SamReferenceInfo SamTags PosList CigarHelper SamRecordPool SamCoordOutput SamRecordHelper
2 | HDRONLY = Pileup.h SamHelper.h SamFlag.h SamStatus.h
3 |
4 | include ../Makefiles/Makefile.lib
--------------------------------------------------------------------------------
/bam/PileupElementBaseQual.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __PILEUP_ELEMENT_BASE_QUAL_H__
19 | #define __PILEUP_ELEMENT_BASE_QUAL_H__
20 |
21 | #include
22 | #include "PileupElement.h"
23 |
24 | /// This class inherits from the base class and stores base and qualities.
25 | class PileupElementBaseQual : public PileupElement
26 | {
27 | public:
28 | PileupElementBaseQual();
29 | // NOTE that this method does not actually copy, it just resets.
30 | PileupElementBaseQual(const PileupElementBaseQual& q);
31 | virtual ~PileupElementBaseQual();
32 |
33 | // Add an entry to this pileup element.
34 | virtual void addEntry(SamRecord& record);
35 |
36 | // Perform the alalysis associated with this class. In this case, it is
37 | // a print of the base & quality information associated with this position.
38 | virtual void analyze();
39 |
40 | // Resets the entry, setting the new position associated with this element.
41 | virtual void reset(int32_t refPosition);
42 |
43 | private:
44 | static const char UNSET_QUAL = 0xFF;
45 |
46 | char* myBases;
47 | char* myQualities;
48 | int myAllocatedSize;
49 | int myIndex;
50 | bool myAddDelAsBase;
51 | };
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/bam/PosList.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __POSLIST_H__
19 | #define __POSLIST_H__
20 |
21 | #include
22 |
23 | /// Store refID/position, but does not store values < 0.
24 | class PosList
25 | {
26 | public:
27 | /// Constructor
28 | PosList();
29 |
30 | /// Reserves space for numRefs reference ids and numPositions for each id.
31 | PosList(int numRefs, int numPositions);
32 |
33 | /// Destructor
34 | virtual ~PosList();
35 |
36 | /// Add the specified reference id/position (negative values will not be
37 | /// added).
38 | void addPosition(int refID, int refPosition);
39 |
40 | /// Return whether or not this list contains the specified reference ID
41 | /// and position (negative values will automatically return false).
42 | bool hasPosition(int refID, int refPosition);
43 |
44 | protected:
45 | PosList(const PosList& p);
46 |
47 | void initVars();
48 |
49 | // 2-D vector.
50 | // indexed by [referenceID][position].
51 | std::vector < std::vector > myPosList;
52 |
53 | int myNumRefs;
54 | int myNumPos;
55 | };
56 |
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/bam/SamHeaderHD.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "SamHeaderHD.h"
19 |
20 | // Constructor
21 | SamHeaderHD::SamHeaderHD()
22 | {
23 | // Add required tags for this type.
24 | myType = SamHeaderRecord::HD;
25 | myTypeString = "HD";
26 | addRequiredTag("VN");
27 | myKeyTag.clear();
28 | }
29 |
30 |
31 | // Destructor
32 | SamHeaderHD::~SamHeaderHD()
33 | {
34 | }
35 |
36 |
37 | const char* SamHeaderHD::getSortOrder()
38 | {
39 | return(getTagValue("SO"));
40 | }
41 |
42 |
43 | SamHeaderRecord* SamHeaderHD ::createCopy() const
44 | {
45 | SamHeaderHD* newHD = new SamHeaderHD();
46 | if(newHD == NULL)
47 | {
48 | std::cerr << "Failed to create a copy of an HD Header Record\n" ;
49 | return(NULL);
50 | }
51 | internalCopy(*newHD);
52 |
53 | return(newHD);
54 | }
55 |
--------------------------------------------------------------------------------
/bam/SamHeaderHD.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __SAMHEADERHD_H__
19 | #define __SAMHEADERHD_H__
20 |
21 | #include "SamHeaderRecord.h"
22 |
23 | class SamHeaderHD : public SamHeaderRecord
24 | {
25 | public:
26 | // Constructor
27 | SamHeaderHD();
28 |
29 | // Destructor
30 | virtual ~SamHeaderHD();
31 |
32 | const char* getSortOrder();
33 |
34 | /// Return a pointer to a newly created header record of the appropriate type
35 | /// that is a copy of this record. The newly created record will not be
36 | /// deleted by this class and it is the responsibility of the calling method
37 | /// to handle the deletion.
38 | /// Returns NULL on failure to copy.
39 | virtual SamHeaderRecord* createCopy() const;
40 |
41 | private:
42 | SamHeaderHD(const SamHeaderHD& samHeaderHD);
43 | SamHeaderHD& operator=(const SamHeaderHD& samHeaderHD);
44 | };
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/bam/SamHeaderPG.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "SamHeaderPG.h"
19 |
20 | // Constructor
21 | SamHeaderPG::SamHeaderPG()
22 | {
23 | // Add required tags for this type.
24 | myType = SamHeaderRecord::PG;
25 | myTypeString = "PG";
26 | addRequiredTag("ID");
27 | myKeyTag = "ID";
28 | }
29 |
30 |
31 | // Destructor
32 | SamHeaderPG::~SamHeaderPG()
33 | {
34 | }
35 |
36 |
37 | SamHeaderRecord* SamHeaderPG::createCopy() const
38 | {
39 | SamHeaderPG* newPG = new SamHeaderPG();
40 | if(newPG == NULL)
41 | {
42 | std::cerr << "Failed to create a copy of an PG Header Record\n" ;
43 | return(NULL);
44 | }
45 | internalCopy(*newPG);
46 |
47 | return(newPG);
48 | }
49 |
--------------------------------------------------------------------------------
/bam/SamHeaderPG.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __SAMHEADERPG_H__
19 | #define __SAMHEADERPG_H__
20 |
21 | #include
22 | #include "SamHeaderRecord.h"
23 |
24 | class SamHeaderPG : public SamHeaderRecord
25 | {
26 | public:
27 | // Constructor
28 | SamHeaderPG();
29 |
30 | // Destructor
31 | virtual ~SamHeaderPG();
32 |
33 | /// Return a pointer to a newly created header record of the appropriate type
34 | /// that is a copy of this record. The newly created record will not be
35 | /// deleted by this class and it is the responsibility of the calling method
36 | /// to handle the deletion.
37 | /// Returns NULL on failure to copy.
38 | virtual SamHeaderRecord* createCopy() const;
39 |
40 | private:
41 | SamHeaderPG(const SamHeaderPG& samHeaderPG);
42 | SamHeaderPG& operator=(const SamHeaderPG& samHeaderPG);
43 | };
44 |
45 | #endif
46 |
--------------------------------------------------------------------------------
/bam/SamHeaderRG.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "SamHeaderRG.h"
19 |
20 | // Constructor
21 | SamHeaderRG::SamHeaderRG()
22 | {
23 | // Add required tags for this type.
24 | myType = SamHeaderRecord::RG;
25 | myTypeString = "RG";
26 | addRequiredTag("ID");
27 | myKeyTag = "ID";
28 | }
29 |
30 |
31 | // Destructor
32 | SamHeaderRG::~SamHeaderRG()
33 | {
34 | }
35 |
36 |
37 | SamHeaderRecord* SamHeaderRG::createCopy() const
38 | {
39 | SamHeaderRG* newRG = new SamHeaderRG();
40 | if(newRG == NULL)
41 | {
42 | std::cerr << "Failed to create a copy of an RG Header Record\n" ;
43 | return(NULL);
44 | }
45 | internalCopy(*newRG);
46 |
47 | return(newRG);
48 | }
49 |
--------------------------------------------------------------------------------
/bam/SamHeaderRG.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __SAMHEADERRG_H__
19 | #define __SAMHEADERRG_H__
20 |
21 | #include "SamHeaderRecord.h"
22 |
23 | class SamHeaderRG : public SamHeaderRecord
24 | {
25 | public:
26 | // Constructor
27 | SamHeaderRG();
28 |
29 | // Destructor
30 | virtual ~SamHeaderRG();
31 |
32 | /// Return a pointer to a newly created header record of the appropriate type
33 | /// that is a copy of this record. The newly created record will not be
34 | /// deleted by this class and it is the responsibility of the calling method
35 | /// to handle the deletion.
36 | /// Returns NULL on failure to copy.
37 | virtual SamHeaderRecord* createCopy() const;
38 |
39 | private:
40 | SamHeaderRG(const SamHeaderRG& samHeaderRG);
41 | SamHeaderRG& operator=(const SamHeaderRG& samHeaderRG);
42 | };
43 |
44 | #endif
45 |
--------------------------------------------------------------------------------
/bam/SamHeaderSQ.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "SamHeaderSQ.h"
19 |
20 | // Constructor
21 | SamHeaderSQ::SamHeaderSQ()
22 | {
23 | // Add required tags for this type.
24 | myType = SamHeaderRecord::SQ;
25 | myTypeString = "SQ";
26 | addRequiredTag("SN");
27 | addRequiredTag("LN");
28 | myKeyTag = "SN";
29 | }
30 |
31 |
32 | // Destructor
33 | SamHeaderSQ::~SamHeaderSQ()
34 | {
35 | }
36 |
37 |
38 | SamHeaderRecord* SamHeaderSQ::createCopy() const
39 | {
40 | SamHeaderSQ* newSQ = new SamHeaderSQ();
41 | if(newSQ == NULL)
42 | {
43 | std::cerr << "Failed to create a copy of an SQ Header Record\n" ;
44 | return(NULL);
45 | }
46 | internalCopy(*newSQ);
47 |
48 | return(newSQ);
49 | }
50 |
--------------------------------------------------------------------------------
/bam/SamHeaderSQ.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __SAMHEADERSQ_H__
19 | #define __SAMHEADERSQ_H__
20 |
21 | #include "SamHeaderRecord.h"
22 |
23 | class SamHeaderSQ : public SamHeaderRecord
24 | {
25 | public:
26 | // Constructor
27 | SamHeaderSQ();
28 |
29 | // Destructor
30 | virtual ~SamHeaderSQ();
31 |
32 | /// Return a pointer to a newly created header record of the appropriate type
33 | /// that is a copy of this record. The newly created record will not be
34 | /// deleted by this class and it is the responsibility of the calling method
35 | /// to handle the deletion.
36 | /// Returns NULL on failure to copy.
37 | virtual SamHeaderRecord* createCopy() const;
38 |
39 | private:
40 | SamHeaderSQ(const SamHeaderSQ& samHeaderSQ);
41 | SamHeaderSQ& operator=(const SamHeaderSQ& samHeaderSQ);
42 | };
43 |
44 | #endif
45 |
--------------------------------------------------------------------------------
/bam/SamHeaderTag.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __SAMHEADER_TAG_H__
19 | #define __SAMHEADER_TAG_H__
20 |
21 | #include
22 |
23 | class SamHeaderTag
24 | {
25 | public:
26 | SamHeaderTag(const char* tag, const char* value);
27 | SamHeaderTag(const SamHeaderTag&);
28 |
29 | ~SamHeaderTag();
30 |
31 | // Add this tag to the passed in tag string.
32 | // If the tag value is blank, the tag will not be added to the
33 | // passed in string.
34 | // NOTE: does not clear tagString.
35 | bool getTagString(std::string& tagString);
36 |
37 | // Set this tag to the passed in tag and value.
38 | bool setTag(const char* tag, const char* value);
39 |
40 | // Set the value associated with this tag to the passed in value.
41 | bool setValue(const char* value);
42 |
43 | // Return the tag for this tag.
44 | const char* getTag();
45 |
46 | // Return the value associated with this tag.
47 | const char* getValue();
48 |
49 | // Return true if there is a non-blank value associated with this tag.
50 | bool hasValue();
51 |
52 | private:
53 | SamHeaderTag();
54 | SamHeaderTag& operator=(const SamHeaderTag&);
55 |
56 | std::string myTag;
57 | std::string myValue;
58 | };
59 |
60 | #endif
61 |
--------------------------------------------------------------------------------
/bam/SamHelper.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __SAM_HELPER_H__
19 | #define __SAM_HELPER_H__
20 |
21 | #include
22 |
23 | #ifdef DUPLICATE
24 | #undef DUPLICATE
25 | #endif
26 |
27 | /// Class for extracting information from a SAM Flag.
28 | class SamHelper
29 | {
30 | public:
31 |
32 | /// Helper method that combines the chromosome ID and position into a
33 | /// 64bit number by shifting the chromosome ID to the upper bits.
34 | static inline uint64_t combineChromPos(int32_t chromID, int32_t position)
35 | {
36 | return(((uint64_t)chromID << 32) | (position & 0xFFFFFFFF));
37 | }
38 |
39 | private:
40 | SamHelper();
41 | };
42 |
43 |
44 | #endif
45 |
--------------------------------------------------------------------------------
/bam/SamStatus.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __SAM_STATUS_H__
19 | #define __SAM_STATUS_H__
20 |
21 | #include "StatGenStatus.h"
22 |
23 | typedef StatGenStatus SamStatus;
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/bam/SamTags.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010-2011 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __SAM_TAGS_H__
19 | #define __SAM_TAGS_H__
20 |
21 | #include
22 | #include
23 | #include "SamRecord.h"
24 |
25 | /// Class for parsing/creating/operating on SAM/BAM record tags.
26 | class SamTags
27 | {
28 | public:
29 | ///////////////////////
30 | /// @name Constants for parsing tags.
31 | //@{
32 | static const char* BQ_TAG;
33 | static const char BQ_TAG_TYPE;
34 | static const char* MD_TAG;
35 | static const char MD_TAG_TYPE;
36 | static const char* ORIG_POS_TAG;
37 | static const char ORIG_POS_TAG_TYPE;
38 | static const char* ORIG_CIGAR_TAG;
39 | static const char ORIG_CIGAR_TAG_TYPE;
40 | static const char* ORIG_QUAL_TAG;
41 | static const char ORIG_QUAL_TAG_TYPE;
42 | //@}
43 |
44 | /// Create the MD tag for the specified input record and the genome.
45 | /// \return returns true if an MD tag was created, false if one could not
46 | /// be created.
47 | static bool createMDTag(String& outputMDtag, SamRecord& inputRec, GenomeSequence& genome);
48 | /// Check to see if the MD tag in the record is accurate.
49 | static bool isMDTagCorrect(SamRecord& inputRec, GenomeSequence& genome);
50 | // Update/Add the MD tag in the inputRec.
51 | static bool updateMDTag(SamRecord& inputRec, GenomeSequence& genome);
52 |
53 | private:
54 | SamTags();
55 | };
56 |
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/bam/examples/Makefile:
--------------------------------------------------------------------------------
1 | PATH_TO_BASE=../../..
2 | include ../../Makefiles/Makefile.include
3 |
4 | SUBDIRS = $(wildcard */)
5 |
6 | # Build in all subdirectories.
7 | #
8 | # see http://www.gnu.org/software/make/manual/make.html#Phony-Targets
9 | # for a way of improving the following:
10 | #
11 |
12 | .PHONY : clean $(SUBDIRS)
13 |
14 | all: $(SUBDIRS)
15 |
16 | $(SUBDIRS):
17 | (echo "building in directory $@"; $(MAKE) $(PARALLEL_MAKE) OPTFLAG="$(OPTFLAG)" --no-print-directory -C $@ ${RECURSIVE_TARGET})
18 |
19 | test: RECURSIVE_TARGET = test
20 | test: $(SUBDIRS)
21 |
22 | clean: RECURSIVE_TARGET = clean
23 | clean: $(SUBDIRS)
24 |
--------------------------------------------------------------------------------
/bam/examples/pileup/.gitignore:
--------------------------------------------------------------------------------
1 | pileup
2 |
--------------------------------------------------------------------------------
/bam/examples/pileup/Makefile:
--------------------------------------------------------------------------------
1 | EXE = pileup
2 | SRCONLY = Main.cpp
3 |
4 | TEST_COMMAND = ./pileup
5 |
6 | include ../../../Makefiles/Makefile.test
--------------------------------------------------------------------------------
/bam/examples/printRefPositions/.gitignore:
--------------------------------------------------------------------------------
1 | printRefPositions
2 | results/
--------------------------------------------------------------------------------
/bam/examples/printRefPositions/Main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #include "PrintRefPositions.h"
23 |
24 | int main(int argc, char ** argv)
25 | {
26 | std::string inFile = "../../test/testFiles/sortedBam.bam";
27 | std::string indexFile = "../../test/testFiles/sortedBam.bam.bai";
28 | std::string rname = "1";
29 | int startPosition = 1013;
30 | int endPosition = 1751;
31 | if(argc == 6)
32 | {
33 | inFile = argv[1];
34 | indexFile = argv[2];
35 | rname = argv[3];
36 | startPosition = atoi(argv[4]);
37 | endPosition = atoi(argv[5]);
38 | }
39 | printRefPositions(inFile, indexFile, rname, startPosition, endPosition);
40 | return(0);
41 | }
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/bam/examples/printRefPositions/Makefile:
--------------------------------------------------------------------------------
1 | EXE = printRefPositions
2 |
3 | SRCONLY = Main.cpp
4 | TOOLBASE = PrintRefPositions
5 |
6 | TEST_COMMAND = mkdir -p results; ./printRefPositions > results/test.txt; diff results/test.txt expected/test.txt
7 |
8 | include ../../../Makefiles/Makefile.test
--------------------------------------------------------------------------------
/bam/examples/printRefPositions/PrintRefPositions.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | //////////////////////////////////////////////////////////////////////////
19 | #include "SamFile.h"
20 |
21 | void printRefPositions(std::string inFile, std::string indexFile,
22 | std::string rname, int startPosition,
23 | int endPosition)
24 | {
25 | SamFileHeader header;
26 | // Open the bam file for reading and read the header.
27 | SamFile samIn(inFile.c_str(), SamFile::READ, &header);
28 |
29 | // Open the bam index file for reading.
30 | samIn.ReadBamIndex(indexFile.c_str());
31 |
32 | // Set the section to be read.
33 | samIn.SetReadSection(rname.c_str(), startPosition, endPosition);
34 |
35 | SamRecord record;
36 | // Keep reading BAM records until they aren't anymore.
37 | while(samIn.ReadRecord(header, record))
38 | {
39 | // Print the reference positions associated with this read.
40 | std::cout << "Read " << samIn.GetCurrentRecordCount() << ":";
41 | Cigar* cigar = record.getCigarInfo();
42 | for(int i = 0; i < record.getReadLength(); i++)
43 | {
44 | int refPos =
45 | cigar->getRefPosition(i, record.get1BasedPosition());
46 | if(refPos != Cigar::INDEX_NA)
47 | {
48 | std::cout << " " << refPos;
49 | }
50 | }
51 | std::cout << "\n";
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/bam/examples/printRefPositions/PrintRefPositions.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | //////////////////////////////////////////////////////////////////////////
19 |
20 | void printRefPositions(std::string inFile, std::string indexFile,
21 | std::string rname, int startPosition,
22 | int endPosition);
23 |
--------------------------------------------------------------------------------
/bam/examples/printRefPositions/expected/test.txt:
--------------------------------------------------------------------------------
1 | Read 1: 1011 1012 1013 1014 1015
2 | Read 2: 1751 1752 1753 1754 1755
3 |
--------------------------------------------------------------------------------
/bam/test/.gitignore:
--------------------------------------------------------------------------------
1 | samTest
2 |
--------------------------------------------------------------------------------
/bam/test/BamIndexTest.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not,x see .
16 | */
17 | #include "SamFile.h"
18 |
19 | class BamIndexFileTest : public SamFile
20 | {
21 | public:
22 | BamIndex* getBamIndex()
23 | {
24 | return(myBamIndex);
25 | }
26 | };
27 |
28 | void testBamIndex();
29 |
30 |
--------------------------------------------------------------------------------
/bam/test/Makefile:
--------------------------------------------------------------------------------
1 | EXE = samTest
2 | TOOLBASE = WriteFiles ValidationTest ReadFiles BamIndexTest ModifyVar Modify SamFileTest TestValidate TestEquals TestFilter ShiftIndels TestPileup TestPosList TestCigarHelper TestSamRecordPool TestSamCoordOutput TestSamRecordHelper
3 | SRCONLY = Main.cpp
4 | ifeq ($(ZLIB_AVAIL), 0)
5 | TEST_COMMAND = ./test.sh noZlib
6 | else
7 | TEST_COMMAND = ./test.sh
8 | endif
9 |
10 | include ../../Makefiles/Makefile.test
--------------------------------------------------------------------------------
/bam/test/Modify.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | void testModify();
19 |
20 | class modify
21 | {
22 | public:
23 | void testModify(const char* filename);
24 |
25 | private:
26 | void modifyPosition();
27 |
28 | void modifyCigar();
29 |
30 | void modifyFlag();
31 |
32 | // Open and read the first record.
33 | void openAndRead1Rec();
34 |
35 | void modifyTags();
36 |
37 | // Variables.
38 | std::string myFilename;
39 |
40 | // Rather than passing around all these variables, just store them in the class.
41 | SamFile samIn;
42 | SamFileHeader samHeader;
43 | SamRecord samRecord;
44 | };
45 |
--------------------------------------------------------------------------------
/bam/test/ReadFiles.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "SamFile.h"
19 | void testReadSam();
20 | void testReadBam();
21 | void testRead(SamFile &inSam);
22 |
23 | void testAddHeaderAndTagToFile(const char* inputName, const char* outputName);
24 |
25 | void testValidateSortedRead();
26 |
27 | void validateRead1ModQuality(SamRecord& samRecord);
28 |
29 | void testModHeader(SamFileHeader& samHeader);
30 |
31 | void testFlagRead(const char* fileName);
32 |
33 | void testCopyHeader(SamFileHeader& samHeader);
34 |
--------------------------------------------------------------------------------
/bam/test/SamFileTest.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | void testSamFile();
19 |
--------------------------------------------------------------------------------
/bam/test/ShiftIndels.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "ShiftIndels.h"
19 | #include "SamFile.h"
20 |
21 | void testShiftIndels()
22 | {
23 | ShiftIndelsTest::testShift("testFiles/testShift.sam", "results/testShift.sam");
24 | #ifdef __ZLIB_AVAILABLE__
25 | ShiftIndelsTest::testShift("testFiles/testShift.bam", "results/testShift.bam");
26 | ShiftIndelsTest::testShift("testFiles/testShift.bam", "results/testShiftFromBam.sam");
27 | #endif
28 | ShiftIndelsTest::testShift("testFiles/testShift.sam", "results/testShiftFromSam.bam");
29 | }
30 |
31 | void ShiftIndelsTest::testShift(const char* input, const char* output)
32 | {
33 | SamFile inSam, outSam;
34 |
35 | assert(inSam.OpenForRead(input));
36 | assert(outSam.OpenForWrite(output));
37 |
38 |
39 | // Read the SAM Header.
40 | SamFileHeader samHeader;
41 | assert(inSam.ReadHeader(samHeader));
42 | assert(outSam.WriteHeader(samHeader));
43 |
44 |
45 | SamRecord samRecord;
46 | int readNum = 1;
47 | bool shiftResult = true;
48 | while(inSam.ReadRecord(samHeader, samRecord))
49 | {
50 | if((readNum == 3)|| (readNum == 5))
51 | {
52 | shiftResult = false;
53 | }
54 | else
55 | {
56 | shiftResult = true;
57 | }
58 | ++readNum;
59 |
60 | assert(samRecord.shiftIndelsLeft() == shiftResult);
61 | assert(outSam.WriteRecord(samHeader, samRecord));
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/bam/test/ShiftIndels.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | void testShiftIndels();
19 |
20 | class ShiftIndelsTest
21 | {
22 | public:
23 | static void testShift(const char* input, const char* output);
24 |
25 | private:
26 | };
27 |
--------------------------------------------------------------------------------
/bam/test/TestCigarHelper.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "SamFile.h"
19 | void testCigarHelper();
20 |
21 | class CigarHelperTest
22 | {
23 | public:
24 | static void testCigarHelper();
25 |
26 | private:
27 | static void testSoftClipBeginByRefPos();
28 | static void testSoftClipEndByRefPos();
29 | };
30 |
--------------------------------------------------------------------------------
/bam/test/TestFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "SamFile.h"
19 | void testFilter();
20 |
21 | class FilterTest
22 | {
23 | public:
24 | enum FileType{SAM, BAM};
25 | static void testFilter(FileType inputType);
26 |
27 | private:
28 |
29 | };
30 |
--------------------------------------------------------------------------------
/bam/test/TestPileup.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 | #include "TestPileup.h"
18 |
19 | void testPileup()
20 | {
21 | TestPileup pileupTest;
22 | pileupTest.testPileupPosition();
23 | }
24 |
25 | void TestPileupElement::analyze()
26 | {
27 | assert(strcmp(getChromosome(), "") == 0);
28 | assert(getRefPosition() == 14000);
29 | }
30 |
31 |
32 | void TestPileup::testPileupPosition()
33 | {
34 | assert(pileupPosition(14000) == 0);
35 | assert(pileupHead == 14000);
36 | assert(pileupStart == 14000);
37 | assert(pileupTail == 14000);
38 |
39 | bool caught = false;
40 | try
41 | {
42 | pileupPosition(13999);
43 | }
44 | catch(std::exception& e)
45 | {
46 | caught = true;
47 | assert(strcmp(e.what(), "Overflow on the pileup buffer: specifiedPosition = 13999, pileup buffer start position: 14000, pileup buffer end position: 15024") == 0);
48 | }
49 | assert(caught);
50 |
51 | caught = false;
52 | try
53 | {
54 | pileupPosition(15025);
55 | }
56 | catch(std::exception& e)
57 | {
58 | caught = true;
59 | assert(strcmp(e.what(), "Overflow on the pileup buffer: specifiedPosition = 15025, pileup buffer start position: 14000, pileup buffer end position: 15024") == 0);
60 | }
61 | assert(caught);
62 | }
63 |
--------------------------------------------------------------------------------
/bam/test/TestPileup.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "Pileup.h"
19 | #include "PileupElementBaseQual.h"
20 |
21 | void testPileup();
22 |
23 | class TestPileupElement : public PileupElementBaseQual
24 | {
25 | public:
26 | // Overwrite to validate result.
27 | virtual void analyze();
28 |
29 | };
30 |
31 |
32 | class TestPileup : public Pileup
33 | {
34 | public:
35 | void testPileupPosition();
36 | private:
37 | };
38 |
--------------------------------------------------------------------------------
/bam/test/TestPosList.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 | #include "PosList.h"
18 |
19 |
20 | void testPosList();
21 |
22 | class TestPosList : public PosList
23 | {
24 | public:
25 | TestPosList();
26 |
27 | ~TestPosList();
28 |
29 | void testPosList();
30 |
31 | };
32 |
--------------------------------------------------------------------------------
/bam/test/TestSamCoordOutput.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __TEST_SAM_COORD_OUTPUT_H__
19 | #define __TEST_SAM_COORD_OUTPUT_H__
20 |
21 | void testSamCoordOutput();
22 |
23 | class SamCoordOutputTest
24 | {
25 | public:
26 | static void testSamCoordOutput();
27 |
28 | private:
29 | };
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/bam/test/TestSamRecordHelper.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "SamFile.h"
19 | void testSamRecordHelper();
20 |
21 | class SamRecordHelperTest
22 | {
23 | public:
24 | static void testSamRecordHelper(const char* fileName);
25 | private:
26 | };
27 |
--------------------------------------------------------------------------------
/bam/test/TestSamRecordPool.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __TEST_SAM_RECORD_POOL_H__
19 | #define __TEST_SAM_RECORD_POOL_H__
20 |
21 | void testSamRecordPool();
22 |
23 | class SamRecordPoolTest
24 | {
25 | public:
26 | static void testSamRecordPool();
27 |
28 | private:
29 | };
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/bam/test/ValidationTest.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | void testSamQNAME();
19 | void testBamRID();
20 |
21 | void testEmptyQual();
22 |
--------------------------------------------------------------------------------
/bam/test/WriteFiles.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | void testWrite();
19 | void testHeaderWrite();
20 | void testWriteCopiedHeader(const char* fileName);
21 |
--------------------------------------------------------------------------------
/bam/test/expected/TestSamCoordOutput.sam:
--------------------------------------------------------------------------------
1 | @SQ SN:1 LN:247249719
2 | @SQ SN:2 LN:242951149
3 | @SQ SN:3 LN:199501827
4 | @SQ SN:4 LN:191273063
5 | @SQ SN:5 LN:180857866
6 | @SQ SN:6 LN:170899992
7 | @SQ SN:7 LN:158821424
8 | @SQ SN:8 LN:146274826
9 | @SQ SN:9 LN:140273252
10 | @SQ SN:10 LN:135374737
11 | @SQ SN:11 LN:134452384
12 | @SQ SN:12 LN:132349534
13 | @SQ SN:13 LN:114142980
14 | @SQ SN:14 LN:106368585
15 | @SQ SN:15 LN:100338915
16 | @SQ SN:16 LN:88827254
17 | @SQ SN:17 LN:78774742
18 | @SQ SN:18 LN:76117153
19 | @SQ SN:19 LN:63811651
20 | @SQ SN:20 LN:62435964
21 | @SQ SN:21 LN:46944323
22 | @SQ SN:22 LN:49691432
23 | @SQ SN:X LN:154913754
24 | @RG ID:myID LB:library SM:sample
25 | @RG ID:myID2 SM:sample2 LB:library2
26 | @CO Comment 1
27 | @CO Comment 2
28 | 18:462+29M5I3M:F:295 97 1 75 0 * 18 757 0 * * AM:i:0
29 | 1:1011:F:255+17M15D20M 73 1 1011 0 5M2D = 1011 0 CCGAA 6>6+4 AM:i:0 MD:Z:37 NM:i:0 XT:A:R
30 | 1:1011:F:255+17M15D20M 133 1 1012 0 * = 1011 0 CTGT >>9>
31 | 18:462+29M5I3M:F:296 97 1 1751 0 3S2H5M 18 757 0 TGCACGTN 453;>>>>
32 | 18:462+29M5I3M:F:295 97 2 75 0 5M 18 757 0 ACGTN * AM:i:0 MD:Z:30A0C5 NM:i:2 XT:A:R
33 | 18:462+29M5I3M:F:297 97 2 1751 0 3S5M1S3H 18 757 0 TGCACGTNG 453;>>>>5
34 | 18:462+29M5I3M:F:298 97 3 75 0 3S5M4H 18 757 0 TGCACGTN 453;>>>>
35 | Y:16597235+13M13I11M:F:181 141 * 0 0 * * 0 0 AACT ==;;
36 | Y:16597235+13M13I11M:F:181 141 * 0 0 * * 0 0 * *
37 |
--------------------------------------------------------------------------------
/bam/test/expected/addedTagToBam.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/expected/addedTagToBam.bam
--------------------------------------------------------------------------------
/bam/test/expected/addedTagToBam.sam:
--------------------------------------------------------------------------------
1 | @SQ SN:1 LN:247249719
2 | @SQ SN:2 LN:242951149
3 | @SQ SN:3 LN:199501827
4 | @SQ SN:4 LN:191273063
5 | @SQ SN:5 LN:180857866
6 | @SQ SN:6 LN:170899992
7 | @SQ SN:7 LN:158821424
8 | @SQ SN:8 LN:146274826
9 | @SQ SN:9 LN:140273252
10 | @SQ SN:10 LN:135374737
11 | @SQ SN:11 LN:134452384
12 | @SQ SN:12 LN:132349534
13 | @SQ SN:13 LN:114142980
14 | @SQ SN:14 LN:106368585
15 | @SQ SN:15 LN:100338915
16 | @SQ SN:16 LN:88827254
17 | @SQ SN:17 LN:78774742
18 | @SQ SN:18 LN:76117153
19 | @SQ SN:19 LN:63811651
20 | @SQ SN:20 LN:62435964
21 | @SQ SN:21 LN:46944323
22 | @SQ SN:22 LN:49691432
23 | @SQ SN:X LN:154913754
24 | @RG ID:myID LB:library SM:sample
25 | @RG ID:myID2 SM:sample2 LB:library2
26 | @RG ID:myID3 SM:mySM
27 | @CO Comment 1
28 | @CO Comment 2
29 | 1:1011:F:255+17M15D20M 73 1 1011 0 5M2D = 1011 0 CCGAA 6>6+4 AM:i:0 MD:Z:37 NM:i:0 RR:Z:myID2 XT:A:R XA:i:456
30 | 18:462+29M5I3M:F:295 97 1 75 0 5M 18 757 0 ACGTN ;>>>> AM:i:0 MD:Z:2T1N0 NM:i:2 XT:A:R
31 |
--------------------------------------------------------------------------------
/bam/test/expected/addedTagToSam.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/expected/addedTagToSam.bam
--------------------------------------------------------------------------------
/bam/test/expected/addedTagToSam.sam:
--------------------------------------------------------------------------------
1 | @SQ SN:1 LN:247249719
2 | @SQ SN:2 LN:242951149
3 | @SQ SN:3 LN:199501827
4 | @SQ SN:4 LN:191273063
5 | @SQ SN:5 LN:180857866
6 | @SQ SN:6 LN:170899992
7 | @SQ SN:7 LN:158821424
8 | @SQ SN:8 LN:146274826
9 | @SQ SN:9 LN:140273252
10 | @SQ SN:10 LN:135374737
11 | @SQ SN:11 LN:134452384
12 | @SQ SN:12 LN:132349534
13 | @SQ SN:13 LN:114142980
14 | @SQ SN:14 LN:106368585
15 | @SQ SN:15 LN:100338915
16 | @SQ SN:16 LN:88827254
17 | @SQ SN:17 LN:78774742
18 | @SQ SN:18 LN:76117153
19 | @SQ SN:19 LN:63811651
20 | @SQ SN:20 LN:62435964
21 | @SQ SN:21 LN:46944323
22 | @SQ SN:22 LN:49691432
23 | @SQ SN:X LN:154913754
24 | @RG ID:myID LB:library SM:sample
25 | @RG ID:myID2 SM:sample2 LB:library2
26 | @RG ID:myID3 SM:mySM
27 | @CO Comment 1
28 | @CO Comment 2
29 | 1:1011:F:255+17M15D20M 73 1 1011 0 5M2D = 1011 0 CCGAA 6>6+4 AM:i:0 MD:Z:37 NM:i:0 RR:Z:myID2 XT:A:R XA:i:456
30 | 18:462+29M5I3M:F:295 97 1 75 0 5M 18 757 0 ACGTN ;>>>> AM:i:0 MD:Z:2T1N0 NM:i:2 XT:A:R
31 |
--------------------------------------------------------------------------------
/bam/test/expected/noZlib/TestSamCoordOutput.sam:
--------------------------------------------------------------------------------
1 | @SQ SN:1 LN:247249719
2 | @SQ SN:2 LN:242951149
3 | @SQ SN:3 LN:199501827
4 | @SQ SN:4 LN:191273063
5 | @SQ SN:5 LN:180857866
6 | @SQ SN:6 LN:170899992
7 | @SQ SN:7 LN:158821424
8 | @SQ SN:8 LN:146274826
9 | @SQ SN:9 LN:140273252
10 | @SQ SN:10 LN:135374737
11 | @SQ SN:11 LN:134452384
12 | @SQ SN:12 LN:132349534
13 | @SQ SN:13 LN:114142980
14 | @SQ SN:14 LN:106368585
15 | @SQ SN:15 LN:100338915
16 | @SQ SN:16 LN:88827254
17 | @SQ SN:17 LN:78774742
18 | @SQ SN:18 LN:76117153
19 | @SQ SN:19 LN:63811651
20 | @SQ SN:20 LN:62435964
21 | @SQ SN:21 LN:46944323
22 | @SQ SN:22 LN:49691432
23 | @SQ SN:X LN:154913754
24 | @RG ID:myID LB:library SM:sample
25 | @RG ID:myID2 SM:sample2 LB:library2
26 | @CO Comment 1
27 | @CO Comment 2
28 | 18:462+29M5I3M:F:295 97 1 75 0 * 18 757 0 * * AM:i:0
29 | 1:1011:F:255+17M15D20M 73 1 1011 0 5M2D = 1011 0 CCGAA 6>6+4 AM:i:0 MD:Z:37 NM:i:0 XT:A:R
30 | 1:1011:F:255+17M15D20M 133 1 1012 0 * = 1011 0 CTGT >>9>
31 | 18:462+29M5I3M:F:296 97 1 1751 0 3S2H5M 18 757 0 TGCACGTN 453;>>>>
32 | 18:462+29M5I3M:F:295 97 2 75 0 5M 18 757 0 ACGTN * AM:i:0 MD:Z:30A0C5 NM:i:2 XT:A:R
33 | 18:462+29M5I3M:F:297 97 2 1751 0 3S5M1S3H 18 757 0 TGCACGTNG 453;>>>>5
34 | 18:462+29M5I3M:F:298 97 3 75 0 3S5M4H 18 757 0 tgcacgtn 453;>>>>
35 | Y:16597235+13M13I11M:F:181 141 * 0 0 * * 0 0 AACT ==;;
36 | Y:16597235+13M13I11M:F:181 141 * 0 0 * * 0 0 * *
37 |
--------------------------------------------------------------------------------
/bam/test/expected/noZlib/addedTagToBam.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/expected/noZlib/addedTagToBam.bam
--------------------------------------------------------------------------------
/bam/test/expected/noZlib/addedTagToBam.sam:
--------------------------------------------------------------------------------
1 | ../addedTagToBam.sam
--------------------------------------------------------------------------------
/bam/test/expected/noZlib/addedTagToSam.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/expected/noZlib/addedTagToSam.bam
--------------------------------------------------------------------------------
/bam/test/expected/noZlib/addedTagToSam.sam:
--------------------------------------------------------------------------------
1 | ../addedTagToSam.sam
--------------------------------------------------------------------------------
/bam/test/expected/noZlib/samTest.log:
--------------------------------------------------------------------------------
1 | 1 invalid SAM/BAM Header lines were skipped due to:
2 | SAM/BAM Header line failure: Skipping RG line that has a repeated ID field.
3 |
4 | 1 invalid SAM/BAM Header lines were skipped due to:
5 | SAM/BAM Header line failure: Skipping RG line that has a repeated ID field.
6 |
7 | ERROR: Missing required tag: SN.
8 | 1 invalid SAM/BAM Header lines were skipped due to:
9 | SAM/BAM Header line failed to store SQ record.
10 |
11 | ERROR: Missing required tag: LN.
12 | 1 invalid SAM/BAM Header lines were skipped due to:
13 | SAM/BAM Header line failed to store SQ record.
14 |
15 | 1 invalid SAM/BAM Header lines were skipped due to:
16 | SAM/BAM Header line failure: Skipping SQ line that has a repeated SN field.
17 |
18 | 1 invalid SAM/BAM Header lines were skipped due to:
19 | SAM/BAM Header line failure: Skipping SQ line that has a repeated SN field.
20 |
21 | 1 invalid SAM/BAM Header lines were skipped due to:
22 | SAM/BAM Header line failure: multiple HD records.
23 |
24 | Can't modify the key tag, SN from chr20 to
25 | ERROR: Missing required tag: LN.
26 | ERROR: Missing required tag: VN.
27 | Can't modify the key tag, ID from pid to pid1
28 | Can't modify the key tag, ID from pid to pid1
29 | 1 invalid SAM/BAM Header lines were skipped due to:
30 | SAM/BAM Header line failure: Skipping PG line that has a repeated ID field.
31 |
32 | ERROR: Missing required tag: LN.
33 | ERROR: Missing required tag: LN.
34 | ERROR: Missing required tag: SM.
35 | Can't modify the key tag, ID from rgID to rgID1
36 | 1 invalid SAM/BAM Header lines were skipped due to:
37 | SAM/BAM Header line failure: Skipping RG line that has a repeated ID field.
38 |
39 | Can't modify the key tag, ID from rgID1 to rgID111
40 | SamCoordOutput::flush, no output file/header is set, so records removed without being written
41 |
--------------------------------------------------------------------------------
/bam/test/expected/noZlib/testEqWithBases.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/expected/noZlib/testEqWithBases.bam
--------------------------------------------------------------------------------
/bam/test/expected/noZlib/testEqWithBases.sam:
--------------------------------------------------------------------------------
1 | ../testEqWithBases.sam
--------------------------------------------------------------------------------
/bam/test/expected/noZlib/testEqWithEq.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/expected/noZlib/testEqWithEq.bam
--------------------------------------------------------------------------------
/bam/test/expected/noZlib/testEqWithEq.sam:
--------------------------------------------------------------------------------
1 | ../testEqWithEq.sam
--------------------------------------------------------------------------------
/bam/test/expected/noZlib/testEqWithOrig.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/expected/noZlib/testEqWithOrig.bam
--------------------------------------------------------------------------------
/bam/test/expected/noZlib/testEqWithOrig.sam:
--------------------------------------------------------------------------------
1 | ../testEqWithOrig.sam
--------------------------------------------------------------------------------
/bam/test/expected/noZlib/testShift.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/expected/noZlib/testShift.bam
--------------------------------------------------------------------------------
/bam/test/expected/noZlib/testShift.sam:
--------------------------------------------------------------------------------
1 | ../testShift.sam
--------------------------------------------------------------------------------
/bam/test/expected/noZlib/updateTag.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/expected/noZlib/updateTag.bam
--------------------------------------------------------------------------------
/bam/test/expected/noZlib/updateTagFromBam.sam:
--------------------------------------------------------------------------------
1 | ../updateTagFromBam.sam
--------------------------------------------------------------------------------
/bam/test/expected/noZlib/updateTagFromSam.sam:
--------------------------------------------------------------------------------
1 | ../updateTagFromSam.sam
--------------------------------------------------------------------------------
/bam/test/expected/testEqWithBases.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/expected/testEqWithBases.bam
--------------------------------------------------------------------------------
/bam/test/expected/testEqWithEq.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/expected/testEqWithEq.bam
--------------------------------------------------------------------------------
/bam/test/expected/testEqWithOrig.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/expected/testEqWithOrig.bam
--------------------------------------------------------------------------------
/bam/test/expected/testShift.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/expected/testShift.bam
--------------------------------------------------------------------------------
/bam/test/expected/testShift.sam:
--------------------------------------------------------------------------------
1 | @SQ SN:1 LN:247249719
2 | @SQ SN:2 LN:242951149
3 | @SQ SN:3 LN:199501827
4 | @SQ SN:4 LN:191273063
5 | @SQ SN:5 LN:180857866
6 | @SQ SN:6 LN:170899992
7 | @SQ SN:7 LN:158821424
8 | @SQ SN:8 LN:146274826
9 | @SQ SN:9 LN:140273252
10 | @SQ SN:10 LN:135374737
11 | @SQ SN:11 LN:134452384
12 | @SQ SN:12 LN:132349534
13 | @SQ SN:13 LN:114142980
14 | @SQ SN:14 LN:106368585
15 | @SQ SN:15 LN:100338915
16 | @SQ SN:16 LN:88827254
17 | @SQ SN:17 LN:78774742
18 | @SQ SN:18 LN:76117153
19 | @SQ SN:19 LN:63811651
20 | @SQ SN:20 LN:62435964
21 | @SQ SN:21 LN:46944323
22 | @SQ SN:22 LN:49691432
23 | @SQ SN:X LN:154913754
24 | Read1 73 1 10011 0 6M4I4M = 10009 0 GCAACCTTAATTGC ??????????????
25 | Read2 73 1 10011 0 1M4I5M = 10009 0 GCACACACGC ?????????? FZ:Z:abc
26 | Read3 73 1 10011 0 4M4D2M = 10009 0 GCACGC ??????
27 | Read4 73 1 10011 0 2M4I8M = 10009 0 GGCCAACCAACCCC ??????????????
28 | Read5 73 1 10011 0 2M4I8M = 10009 0 GGCCAACCAACCCC ??????????????
29 | Read6 73 1 10011 0 2S4I8M = 10009 0 GGCCAACCAACCCC ??????????????
30 | Read7 73 1 10011 0 3M3I10M = 10009 0 GTTCTCCTCTGTGCAA GTTCTCCTCTGTGCAA
31 |
--------------------------------------------------------------------------------
/bam/test/expected/updateTag.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/expected/updateTag.bam
--------------------------------------------------------------------------------
/bam/test/expected/updateTagFromBam.sam:
--------------------------------------------------------------------------------
1 | @SQ SN:1 LN:247249719
2 | @SQ SN:2 LN:242951149
3 | @SQ SN:3 LN:199501827
4 | @SQ SN:4 LN:191273063
5 | @SQ SN:5 LN:180857866
6 | @SQ SN:6 LN:170899992
7 | @SQ SN:7 LN:158821424
8 | @SQ SN:8 LN:146274826
9 | @SQ SN:9 LN:140273252
10 | @SQ SN:10 LN:135374737
11 | @SQ SN:11 LN:134452384
12 | @SQ SN:12 LN:132349534
13 | @SQ SN:13 LN:114142980
14 | @SQ SN:14 LN:106368585
15 | @SQ SN:15 LN:100338915
16 | @SQ SN:16 LN:88827254
17 | @SQ SN:17 LN:78774742
18 | @SQ SN:18 LN:76117153
19 | @SQ SN:19 LN:63811651
20 | @SQ SN:20 LN:62435964
21 | @SQ SN:21 LN:46944323
22 | @SQ SN:22 LN:49691432
23 | @SQ SN:X LN:154913754
24 | @RG ID:myID LB:library SM:sample
25 | @RG ID:myID2 SM:sample2 LB:library2
26 | @CO Comment 1
27 | @CO Comment 2
28 | 1:1011:F:255+17M15D20M 73 1 1011 0 5M2D = 1011 0 CCGAA 6>6+4 AM:i:0 NM:i:0 XT:A:R
29 | 1:1011:F:255+17M15D20M 133 1 1012 0 * = 1011 0 CTGT >>9>
30 | 18:462+29M5I3M:F:295 97 1 75 0 5M 18 757 0 ACGTN ;>>>> AM:i:0
31 | 18:462+29M5I3M:F:295 97 1 75 0 * 18 757 0 * * AM:i:0
32 | 18:462+29M5I3M:F:295 97 2 75 0 5M 18 757 0 ACGTN * AM:i:0 XT:A:R
33 | 18:462+29M5I3M:F:296 97 1 1751 0 3S2H5M 18 757 0 TGCACGTN 453;>>>>
34 | 18:462+29M5I3M:F:297 97 2 1751 0 3S5M1S3H 18 757 0 TGCACGTNG 453;>>>>5
35 | Y:16597235+13M13I11M:F:181 141 * 0 0 * * 0 0 AACT ==;;
36 | 18:462+29M5I3M:F:298 97 3 75 0 3S5M4H 18 757 0 TGCACGTN 453;>>>>
37 | Y:16597235+13M13I11M:F:181 141 * 0 0 * * 0 0 * *
38 |
--------------------------------------------------------------------------------
/bam/test/expected/updateTagFromSam.sam:
--------------------------------------------------------------------------------
1 | @SQ SN:1 LN:247249719
2 | @SQ SN:2 LN:242951149
3 | @SQ SN:3 LN:199501827
4 | @SQ SN:4 LN:191273063
5 | @SQ SN:5 LN:180857866
6 | @SQ SN:6 LN:170899992
7 | @SQ SN:7 LN:158821424
8 | @SQ SN:8 LN:146274826
9 | @SQ SN:9 LN:140273252
10 | @SQ SN:10 LN:135374737
11 | @SQ SN:11 LN:134452384
12 | @SQ SN:12 LN:132349534
13 | @SQ SN:13 LN:114142980
14 | @SQ SN:14 LN:106368585
15 | @SQ SN:15 LN:100338915
16 | @SQ SN:16 LN:88827254
17 | @SQ SN:17 LN:78774742
18 | @SQ SN:18 LN:76117153
19 | @SQ SN:19 LN:63811651
20 | @SQ SN:20 LN:62435964
21 | @SQ SN:21 LN:46944323
22 | @SQ SN:22 LN:49691432
23 | @SQ SN:X LN:154913754
24 | @RG ID:myID LB:library SM:sample
25 | @RG ID:myID2 SM:sample2 LB:library2
26 | @CO Comment 1
27 | @CO Comment 2
28 | 1:1011:F:255+17M15D20M 73 1 1011 0 5M2D = 1011 0 CCGAA 6>6+4 AM:i:0 NM:i:0 XT:A:R
29 | 1:1011:F:255+17M15D20M 133 1 1012 0 * = 1011 0 CTGT >>9>
30 | 18:462+29M5I3M:F:295 97 1 75 0 5M 18 757 0 ACGTN ;>>>> AM:i:0
31 | 18:462+29M5I3M:F:295 97 1 75 0 * 18 757 0 * * AM:i:0
32 | 18:462+29M5I3M:F:295 97 2 75 0 5M 18 757 0 ACGTN * AM:i:0 XT:A:R
33 | 18:462+29M5I3M:F:296 97 1 1751 0 3S2H5M 18 757 0 TGCACGTN 453;>>>>
34 | 18:462+29M5I3M:F:297 97 2 1751 0 3S5M1S3H 18 757 0 TGCACGTNG 453;>>>>5
35 | Y:16597235+13M13I11M:F:181 141 * 0 0 * * 0 0 AACT ==;;
36 | 18:462+29M5I3M:F:298 97 3 75 0 3S5M4H 18 757 0 tgcacgtn 453;>>>>
37 | Y:16597235+13M13I11M:F:181 141 * 0 0 * * 0 0 * *
38 |
--------------------------------------------------------------------------------
/bam/test/results/.gitignore:
--------------------------------------------------------------------------------
1 | *.sam
2 | *.bam
3 | *.log
--------------------------------------------------------------------------------
/bam/test/testFiles/chr1_partial-bs.umfa:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/testFiles/chr1_partial-bs.umfa
--------------------------------------------------------------------------------
/bam/test/testFiles/sortedBam.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/testFiles/sortedBam.bam
--------------------------------------------------------------------------------
/bam/test/testFiles/sortedBam.bam.bai:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/testFiles/sortedBam.bam.bai
--------------------------------------------------------------------------------
/bam/test/testFiles/sortedBam2.bai:
--------------------------------------------------------------------------------
1 | sortedBam.bam.bai
--------------------------------------------------------------------------------
/bam/test/testFiles/sortedBam2.bam:
--------------------------------------------------------------------------------
1 | sortedBam.bam
--------------------------------------------------------------------------------
/bam/test/testFiles/testBam.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/testFiles/testBam.bam
--------------------------------------------------------------------------------
/bam/test/testFiles/testBam1.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/testFiles/testBam1.bam
--------------------------------------------------------------------------------
/bam/test/testFiles/testEq.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/testFiles/testEq.bam
--------------------------------------------------------------------------------
/bam/test/testFiles/testSam.sam:
--------------------------------------------------------------------------------
1 | @SQ SN:1 LN:247249719
2 | @SQ SN:2 LN:242951149
3 | @SQ SN:3 LN:199501827
4 | @SQ SN:4 LN:191273063
5 |
6 | @SQ SN:5 LN:180857866
7 | @SQ SN:6 LN:170899992
8 | @SQ SN:7 LN:158821424
9 | @SQ SN:8 LN:146274826
10 | @SQ SN:9 LN:140273252
11 | @SQ SN:10 LN:135374737
12 | @SQ SN:11 LN:134452384
13 | @SQ SN:12 LN:132349534
14 | @SQ SN:13 LN:114142980
15 | @SQ SN:14 LN:106368585
16 | @SQ SN:15 LN:100338915
17 | @SQ SN:16 LN:88827254
18 | @SQ SN:17 LN:78774742
19 | @SQ SN:18 LN:76117153
20 | @SQ SN:19 LN:63811651
21 | @SQ SN:20 LN:62435964
22 | @SQ SN:21 LN:46944323
23 | @SQ SN:22 LN:49691432
24 | @SQ SN:X LN:154913754
25 | @RG ID:myID LB:library SM:sample
26 | @RG ID:myID2 SM:sample2 LB:library2
27 | @CO Comment 1
28 | @CO Comment 2
29 | 1:1011:F:255+17M15D20M 73 1 1011 0 5M2D = 1011 0 CCGAA 6>6+4 XT:A:R AM:i:0 NM:i:0 MD:Z:37
30 | 1:1011:F:255+17M15D20M 133 1 1012 0 * = 1011 0 CTGT >>9>
31 | 18:462+29M5I3M:F:295 97 1 75 0 5M 18 757 0 ACGTN ;>>>> XT:A:R AM:i:0 NM:i:2 MD:Z:30A0C5
32 | 18:462+29M5I3M:F:295 97 1 75 0 * 18 757 0 * * AM:i:0
33 | 18:462+29M5I3M:F:295 97 2 75 0 5M 18 757 0 ACGTN * XT:A:R AM:i:0 NM:i:2 MD:Z:30A0C5
34 | 18:462+29M5I3M:F:296 97 1 1751 0 3S2H5M 18 757 0 TGCACGTN 453;>>>>
35 | 18:462+29M5I3M:F:297 97 2 1751 0 3S5M1S3H 18 757 0 TGCACGTNG 453;>>>>5
36 | Y:16597235+13M13I11M:F:181 141 * 0 0 * * 0 0 AACT ==;;
37 | 18:462+29M5I3M:F:298 97 3 75 0 3S5M4H 18 757 0 tgcacgtn 453;>>>>
38 | Y:16597235+13M13I11M:F:181 141 * 0 0 * * 0 0 * *
39 |
--------------------------------------------------------------------------------
/bam/test/testFiles/testSam1.sam:
--------------------------------------------------------------------------------
1 | @SQ SN:1 LN:247249719
2 | @SQ SN:2 LN:242951149
3 | @SQ SN:3 LN:199501827
4 | @SQ SN:4 LN:191273063
5 |
6 | @SQ SN:5 LN:180857866
7 | @SQ SN:6 LN:170899992
8 | @SQ SN:7 LN:158821424
9 | @SQ SN:8 LN:146274826
10 | @SQ SN:9 LN:140273252
11 | @SQ SN:10 LN:135374737
12 | @SQ SN:11 LN:134452384
13 | @SQ SN:12 LN:132349534
14 | @SQ SN:13 LN:114142980
15 | @SQ SN:14 LN:106368585
16 | @SQ SN:15 LN:100338915
17 | @SQ SN:16 LN:88827254
18 | @SQ SN:17 LN:78774742
19 | @SQ SN:18 LN:76117153
20 | @SQ SN:19 LN:63811651
21 | @SQ SN:20 LN:62435964
22 | @SQ SN:21 LN:46944323
23 | @SQ SN:22 LN:49691432
24 | @SQ SN:X LN:154913754
25 | @RG ID:myID LB:library SM:sample
26 | @RG ID:myID2 SM:sample2 LB:library2
27 | @CO Comment 1
28 | @CO Comment 2
29 | 1:1011:F:255+17M15D20M 73 1 1011 0 5M2D = 1011 0 CCGAA 6>6+4 XT:A:R AM:i:0 NM:i:0 MD:Z:37
30 |
--------------------------------------------------------------------------------
/bam/test/testFiles/testSamSOcoord.sam:
--------------------------------------------------------------------------------
1 | @HD SO:coordinate VN:1.0
2 | @SQ SN:1 LN:247249719
3 | @SQ SN:2 LN:242951149
4 | @SQ SN:3 LN:199501827
5 | @SQ SN:4 LN:191273063
6 | @SQ SN:5 LN:180857866
7 | @SQ SN:6 LN:170899992
8 | @SQ SN:7 LN:158821424
9 | @SQ SN:8 LN:146274826
10 | @SQ SN:9 LN:140273252
11 | @SQ SN:10 LN:135374737
12 | @SQ SN:11 LN:134452384
13 | @SQ SN:12 LN:132349534
14 | @SQ SN:13 LN:114142980
15 | @SQ SN:14 LN:106368585
16 | @SQ SN:15 LN:100338915
17 | @SQ SN:16 LN:88827254
18 | @SQ SN:17 LN:78774742
19 | @SQ SN:18 LN:76117153
20 | @SQ SN:19 LN:63811651
21 | @SQ SN:20 LN:62435964
22 | @SQ SN:21 LN:46944323
23 | @SQ SN:22 LN:49691432
24 | @SQ SN:X LN:154913754
25 | 1:1011:F:255+17M15D20M 73 1 1011 0 5M2D = 1011 0 CCGAA 6>6+4 XT:A:R AM:i:0 NM:i:0 MD:Z:37
26 | 1:1011:F:255+17M15D20M 133 1 1012 0 * = 1011 0 CTGT >>9>
27 | 18:462+29M5I3M:F:295 97 1 75 0 5M 18 757 0 ACGTN ;>>>> XT:A:R AM:i:0 NM:i:2 MD:Z:30A0C5
28 | 18:462+29M5I3M:F:295 97 1 75 0 * 18 757 0 * * AM:i:0
29 | 18:462+29M5I3M:F:295 97 2 75 0 5M 18 757 0 ACGTN * XT:A:R AM:i:0 NM:i:2 MD:Z:30A0C5
30 | 18:462+29M5I3M:F:296 97 1 1751 0 3S2H5M 18 757 0 TGCACGTN 453;>>>>
31 | 18:462+29M5I3M:F:297 97 2 1751 0 3S5M1S3H 18 757 0 TGCACGTNG 453;>>>>5
32 | Y:16597235+13M13I11M:F:181 141 * 0 0 * * 0 0 AACT ==;;
33 | 18:462+29M5I3M:F:298 97 3 75 0 3S5M4H 18 757 0 TGCACGTN 453;>>>>
34 | Y:16597235+13M13I11M:F:181 141 * 0 0 * * 0 0 * *
35 |
--------------------------------------------------------------------------------
/bam/test/testFiles/testSamSOinvalid.sam:
--------------------------------------------------------------------------------
1 | @HD SO:junk VN:1.0
2 | @SQ SN:1 LN:247249719
3 | @SQ SN:2 LN:242951149
4 | @SQ SN:3 LN:199501827
5 | @SQ SN:4 LN:191273063
6 | @SQ SN:5 LN:180857866
7 | @SQ SN:6 LN:170899992
8 | @SQ SN:7 LN:158821424
9 | @SQ SN:8 LN:146274826
10 | @SQ SN:9 LN:140273252
11 | @SQ SN:10 LN:135374737
12 | @SQ SN:11 LN:134452384
13 | @SQ SN:12 LN:132349534
14 | @SQ SN:13 LN:114142980
15 | @SQ SN:14 LN:106368585
16 | @SQ SN:15 LN:100338915
17 | @SQ SN:16 LN:88827254
18 | @SQ SN:17 LN:78774742
19 | @SQ SN:18 LN:76117153
20 | @SQ SN:19 LN:63811651
21 | @SQ SN:20 LN:62435964
22 | @SQ SN:21 LN:46944323
23 | @SQ SN:22 LN:49691432
24 | @SQ SN:X LN:154913754
25 | 1:1011:F:255+17M15D20M 73 1 1011 0 5M2D = 1011 0 CCGAA 6>6+4 XT:A:R AM:i:0 NM:i:0 MD:Z:37
26 | 1:1011:F:255+17M15D20M 133 1 1012 0 * = 1011 0 CTGT >>9>
27 | 18:462+29M5I3M:F:295 97 1 75 0 5M 18 757 0 ACGTN ;>>>> XT:A:R AM:i:0 NM:i:2 MD:Z:30A0C5
28 | 18:462+29M5I3M:F:295 97 1 75 0 * 18 757 0 * * AM:i:0
29 | 18:462+29M5I3M:F:295 97 2 75 0 5M 18 757 0 ACGTN * XT:A:R AM:i:0 NM:i:2 MD:Z:30A0C5
30 | 18:462+29M5I3M:F:296 97 1 1751 0 3S2H5M 18 757 0 TGCACGTN 453;>>>>
31 | 18:462+29M5I3M:F:297 97 2 1751 0 3S5M1S3H 18 757 0 TGCACGTNG 453;>>>>5
32 | Y:16597235+13M13I11M:F:181 141 * 0 0 * * 0 0 AACT ==;;
33 | 18:462+29M5I3M:F:298 97 3 75 0 3S5M4H 18 757 0 TGCACGTN 453;>>>>
34 | Y:16597235+13M13I11M:F:181 141 * 0 0 * * 0 0 * *
35 |
--------------------------------------------------------------------------------
/bam/test/testFiles/testSamSOquery.sam:
--------------------------------------------------------------------------------
1 | @HD SO:queryname VN:1.0
2 | @SQ SN:1 LN:247249719
3 | @SQ SN:2 LN:242951149
4 | @SQ SN:3 LN:199501827
5 | @SQ SN:4 LN:191273063
6 | @SQ SN:5 LN:180857866
7 | @SQ SN:6 LN:170899992
8 | @SQ SN:7 LN:158821424
9 | @SQ SN:8 LN:146274826
10 | @SQ SN:9 LN:140273252
11 | @SQ SN:10 LN:135374737
12 | @SQ SN:11 LN:134452384
13 | @SQ SN:12 LN:132349534
14 | @SQ SN:13 LN:114142980
15 | @SQ SN:14 LN:106368585
16 | @SQ SN:15 LN:100338915
17 | @SQ SN:16 LN:88827254
18 | @SQ SN:17 LN:78774742
19 | @SQ SN:18 LN:76117153
20 | @SQ SN:19 LN:63811651
21 | @SQ SN:20 LN:62435964
22 | @SQ SN:21 LN:46944323
23 | @SQ SN:22 LN:49691432
24 | @SQ SN:X LN:154913754
25 | 1:1011:F:255+17M15D20M 73 1 1011 0 5M2D = 1011 0 CCGAA 6>6+4 XT:A:R AM:i:0 NM:i:0 MD:Z:37
26 | 1:1011:F:255+17M15D20M 133 1 1012 0 * = 1011 0 CTGT >>9>
27 | 18:462+29M5I3M:F:295 97 1 75 0 5M 18 757 0 ACGTN ;>>>> XT:A:R AM:i:0 NM:i:2 MD:Z:30A0C5
28 | 18:462+29M5I3M:F:295 97 1 75 0 * 18 757 0 * * AM:i:0
29 | 18:462+29M5I3M:F:295 97 2 75 0 5M 18 757 0 ACGTN * XT:A:R AM:i:0 NM:i:2 MD:Z:30A0C5
30 | 18:462+29M5I3M:F:296 97 1 1751 0 3S2H5M 18 757 0 TGCACGTN 453;>>>>
31 | 18:462+29M5I3M:F:297 97 2 1751 0 3S5M1S3H 18 757 0 TGCACGTNG 453;>>>>5
32 | Y:16597235+13M13I11M:F:181 141 * 0 0 * * 0 0 AACT ==;;
33 | 18:462+29M5I3M:F:298 97 3 75 0 3S5M4H 18 757 0 TGCACGTN 453;>>>>
34 | Y:16597235+13M13I11M:F:181 141 * 0 0 * * 0 0 * *
35 |
--------------------------------------------------------------------------------
/bam/test/testFiles/testShift.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/testFiles/testShift.bam
--------------------------------------------------------------------------------
/bam/test/testFiles/testShift.sam:
--------------------------------------------------------------------------------
1 | @SQ SN:1 LN:247249719
2 | @SQ SN:2 LN:242951149
3 | @SQ SN:3 LN:199501827
4 | @SQ SN:4 LN:191273063
5 | @SQ SN:5 LN:180857866
6 | @SQ SN:6 LN:170899992
7 | @SQ SN:7 LN:158821424
8 | @SQ SN:8 LN:146274826
9 | @SQ SN:9 LN:140273252
10 | @SQ SN:10 LN:135374737
11 | @SQ SN:11 LN:134452384
12 | @SQ SN:12 LN:132349534
13 | @SQ SN:13 LN:114142980
14 | @SQ SN:14 LN:106368585
15 | @SQ SN:15 LN:100338915
16 | @SQ SN:16 LN:88827254
17 | @SQ SN:17 LN:78774742
18 | @SQ SN:18 LN:76117153
19 | @SQ SN:19 LN:63811651
20 | @SQ SN:20 LN:62435964
21 | @SQ SN:21 LN:46944323
22 | @SQ SN:22 LN:49691432
23 | @SQ SN:X LN:154913754
24 | Read1 73 1 10011 0 8M4I2M = 10009 0 GCAACCTTAATTGC ??????????????
25 | Read2 73 1 10011 0 4M4I2M = 10009 0 GCACACACGC ?????????? FZ:Z:abc
26 | Read3 73 1 10011 0 4M4D2M = 10009 0 GCACGC ??????
27 | Read4 73 1 10011 0 8M4I2M = 10009 0 GGCCAACCAACCCC ??????????????
28 | Read5 73 1 10011 0 2M4I8M = 10009 0 GGCCAACCAACCCC ??????????????
29 | Read6 73 1 10011 0 2S6M4I2M = 10009 0 GGCCAACCAACCCC ??????????????
30 | Read7 73 1 10011 0 6M3I7M = 10009 0 GTTCTCCTCTGTGCAA GTTCTCCTCTGTGCAA
31 |
--------------------------------------------------------------------------------
/bam/test/testFiles/testVar.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/bam/test/testFiles/testVar.bam
--------------------------------------------------------------------------------
/copyrights/COPYING:
--------------------------------------------------------------------------------
1 | LICENSE.txt
--------------------------------------------------------------------------------
/copyrights/COPYING.samtools:
--------------------------------------------------------------------------------
1 | ../samtools/COPYING
--------------------------------------------------------------------------------
/copyrights/LICENSE.md5:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
2 | rights reserved.
3 |
4 | License to copy and use this software is granted provided that it
5 | is identified as the "RSA Data Security, Inc. MD5 Message-Digest
6 | Algorithm" in all material mentioning or referencing this software
7 | or this function.
8 |
9 | License is also granted to make and use derivative works provided
10 | that such works are identified as "derived from the RSA Data
11 | Security, Inc. MD5 Message-Digest Algorithm" in all material
12 | mentioning or referencing the derived work.
13 |
14 | RSA Data Security, Inc. makes no representations concerning either
15 | the merchantability of this software or the suitability of this
16 | software for any particular purpose. It is provided "as is"
17 | without express or implied warranty of any kind.
18 |
19 | These notices must be retained in any copies of any part of this
20 | documentation and/or software.
21 | */
22 |
23 | Code included in general/CSG_MD5.h
24 |
--------------------------------------------------------------------------------
/copyrights/LICENSE.twister:
--------------------------------------------------------------------------------
1 | ../general/LICENSE.twister
--------------------------------------------------------------------------------
/copyrights/LICENSE.txt:
--------------------------------------------------------------------------------
1 | ../general/LICENSE.txt
--------------------------------------------------------------------------------
/fastq/FastQStatus.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "FastQStatus.h"
19 |
20 | const char* FastQStatus::enumString[] = {"FASTQ_SUCCESS", "FASTQ_INVALID", "FASTQ_ORDER_ERROR", "FASTQ_OPEN_ERROR", "FASTQ_CLOSE_ERROR", "FASTQ_READ_ERROR", "FASTQ_NO_SEQUENCE_ERROR"};
21 |
22 |
23 | const char* FastQStatus::getStatusString(Status status)
24 | {
25 | return(enumString[status]);
26 | }
27 |
--------------------------------------------------------------------------------
/fastq/FastQStatus.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __FASTQ_STATUS_H__
19 | #define __FASTQ_STATUS_H__
20 |
21 | #include
22 |
23 | /// Status for FastQ operations.
24 | class FastQStatus
25 | {
26 | public:
27 |
28 | /// Return value enum for the FastQFile class methods, indicating
29 | /// success or error codes.
30 | enum Status
31 | {
32 | FASTQ_SUCCESS = 0, ///< indicates method finished successfully.
33 | FASTQ_INVALID, ///< means that the sequence was invalid.
34 | FASTQ_ORDER_ERROR, ///< means the methods are called out of order, like trying to read a file before opening it.
35 | FASTQ_OPEN_ERROR, ///< means the file could not be opened.
36 | FASTQ_CLOSE_ERROR, ///< means the file could not be closed.
37 | FASTQ_READ_ERROR, ///< means that a problem occurred on a read.
38 | FASTQ_NO_SEQUENCE_ERROR ///< means there were no errors, but no sequences read.
39 | };
40 |
41 | /// Get the enum string for the status.
42 | static const char* getStatusString(Status status);
43 |
44 | private:
45 | static const char* enumString[];
46 | };
47 |
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/fastq/Makefile:
--------------------------------------------------------------------------------
1 | # Source File Set
2 | TOOLBASE = FastQFile BaseCount BaseComposition FastQStatus
3 |
4 | include ../Makefiles/Makefile.lib
--------------------------------------------------------------------------------
/fastq/Makefile.depends:
--------------------------------------------------------------------------------
1 | # DO NOT DELETE
2 |
3 | $(OBJDIR_OPT)/FastQFile.o: ../include/InputFile.h ../include/FileType.h
4 | $(OBJDIR_OPT)/FastQFile.o: FastQFile.h ../include/StringBasics.h
5 | $(OBJDIR_OPT)/FastQFile.o: BaseComposition.h ../include/BaseAsciiMap.h
6 | $(OBJDIR_OPT)/FastQFile.o: BaseCount.h FastQStatus.h
7 | $(OBJDIR_OPT)/BaseCount.o: BaseCount.h
8 | $(OBJDIR_OPT)/BaseComposition.o: BaseComposition.h ../include/BaseAsciiMap.h
9 | $(OBJDIR_OPT)/BaseComposition.o: ../include/StringBasics.h
10 | $(OBJDIR_OPT)/BaseComposition.o: ../include/InputFile.h ../include/FileType.h
11 | $(OBJDIR_OPT)/BaseComposition.o: BaseCount.h
12 | $(OBJDIR_OPT)/FastQStatus.o: FastQStatus.h
13 |
14 | $(OBJDIR_DEBUG)/FastQFile.o: ../include/InputFile.h ../include/FileType.h
15 | $(OBJDIR_DEBUG)/FastQFile.o: FastQFile.h ../include/StringBasics.h
16 | $(OBJDIR_DEBUG)/FastQFile.o: BaseComposition.h ../include/BaseAsciiMap.h
17 | $(OBJDIR_DEBUG)/FastQFile.o: BaseCount.h FastQStatus.h
18 | $(OBJDIR_DEBUG)/BaseCount.o: BaseCount.h
19 | $(OBJDIR_DEBUG)/BaseComposition.o: BaseComposition.h
20 | $(OBJDIR_DEBUG)/BaseComposition.o: ../include/BaseAsciiMap.h
21 | $(OBJDIR_DEBUG)/BaseComposition.o: ../include/StringBasics.h
22 | $(OBJDIR_DEBUG)/BaseComposition.o: ../include/InputFile.h
23 | $(OBJDIR_DEBUG)/BaseComposition.o: ../include/FileType.h BaseCount.h
24 | $(OBJDIR_DEBUG)/FastQStatus.o: FastQStatus.h
25 |
26 | $(OBJDIR_PROFILE)/FastQFile.o: ../include/InputFile.h ../include/FileType.h
27 | $(OBJDIR_PROFILE)/FastQFile.o: FastQFile.h ../include/StringBasics.h
28 | $(OBJDIR_PROFILE)/FastQFile.o: BaseComposition.h ../include/BaseAsciiMap.h
29 | $(OBJDIR_PROFILE)/FastQFile.o: BaseCount.h FastQStatus.h
30 | $(OBJDIR_PROFILE)/BaseCount.o: BaseCount.h
31 | $(OBJDIR_PROFILE)/BaseComposition.o: BaseComposition.h
32 | $(OBJDIR_PROFILE)/BaseComposition.o: ../include/BaseAsciiMap.h
33 | $(OBJDIR_PROFILE)/BaseComposition.o: ../include/StringBasics.h
34 | $(OBJDIR_PROFILE)/BaseComposition.o: ../include/InputFile.h
35 | $(OBJDIR_PROFILE)/BaseComposition.o: ../include/FileType.h BaseCount.h
36 | $(OBJDIR_PROFILE)/FastQStatus.o: FastQStatus.h
37 |
--------------------------------------------------------------------------------
/fastq/test/.gitignore:
--------------------------------------------------------------------------------
1 | fastqTest
2 | results/
3 |
--------------------------------------------------------------------------------
/fastq/test/FastQValidatorTest.sh:
--------------------------------------------------------------------------------
1 | ERROR=false
2 |
3 | ./fastqTest > results/fastqTest.txt
4 | diff results/fastqTest.txt expectedResults/ExpectedResultsFastqTestResults.txt
5 | if [ $? -ne 0 ]
6 | then
7 | ERROR=true
8 | fi
9 |
10 | if($ERROR == true)
11 | then
12 | exit 1
13 | fi
14 |
15 |
--------------------------------------------------------------------------------
/fastq/test/Makefile:
--------------------------------------------------------------------------------
1 | TEST_COMMAND = mkdir -p results; ./FastQValidatorTest.sh
2 | EXE=fastqTest
3 | SRCONLY = FastQFileTest.cpp
4 |
5 | include ../../Makefiles/Makefile.test
--------------------------------------------------------------------------------
/fastq/test/README.txt:
--------------------------------------------------------------------------------
1 | Lines 1 - 24 - test that all valid quality string characters are accepted & tests multiple line Raw Sequence and Quality Strings.
2 |
3 | Sequence Identifier Line Validates:
4 | * Line 25: line is at least 2 characters long ('@' and at least 1 for the sequence identifier)
5 | * Line 29: line starts with an '@'
6 | * Line 33 & 37: no space between the '@' & the sequence identifier (which must be at least 1 character)
7 | * Line 41: sequence identifier is unique within the file
8 |
9 | Raw Sequence Line Validates:
10 | * Line 46 & 47: every character is in ACTGNactgn0123.
11 | * Line 51: the raw sequence after it is completely read is at least a configurable minimum length
12 | * Line 56 & 57: assumes all lines are part of the raw sequence until a line begins with a '+' or the end of the file is reached
13 |
14 | Plus Line Validates:
15 | * Line 88: sequence identifier on + line does not match the one on the @ line.
16 | * Line 91: that this line exists for each sequence
17 |
18 | Quality Line Validates:
19 | * Line 63 & 64: each character is > ascii 32
20 | * Line 70: assumes all lines are part of the quality string until the total length of quality characters is >= the raw sequence length or the end of the file is reached
21 | * Line 77: length of the quality string equals the length of the raw sequence
22 |
23 |
24 |
--------------------------------------------------------------------------------
/fastq/test/testFile.txt:
--------------------------------------------------------------------------------
1 | @Valid with comment
2 | ACTGNactng.0123
3 | +
4 | !#"$%&'()*+,-./
5 | @Valid1 with comment
6 | ACTGACTNactngaac
7 | +
8 | 0123456789:;<=>
9 | @
10 | @Valid2
11 | A123.0321.011
12 | +
13 | ?@ABCDEFGHIJK
14 | @Valid3
15 | ACTGACTN
16 | actngACTGACTNactng
17 | +
18 | LMNOPQRSTUVWXYZ
19 | [\]^_'abcde
20 | @Valid4
21 | ACTGACTNactng
22 | ACTGACTNactng
23 | +
24 | fghijklmnopqrstuvwxyz{|}~~
25 | @
26 | ACTGACTNactng
27 | +
28 | ?@ABCDEFGHIJK
29 | Line no start with @
30 | ACTGACTNactng
31 | +
32 | LMNOPQRSTUVWX
33 | @ a
34 | ACTGACTNactng
35 | +
36 | YZ[\]^_'abcde
37 | @
38 | ACTGACTNactng
39 | +
40 | fghijklmnopqr
41 | @Valid
42 | ACTGNactng
43 | +
44 | !#"$%&'()*
45 | @RawError1
46 | ACTNaHtng0
47 | aBZa
48 | +
49 | ACTNactng0aBaZ
50 | @RawError2
51 | aaa
52 | +
53 | aaa
54 | @RawError3
55 | ACTGACTNactng
56 |
57 |
58 | +
59 | ACTGACTNactng
60 | @QualityError1
61 | ACTGCacgnc
62 | +
63 | ac gc
64 | acg n
65 | @QualityError2
66 | ACTGC
67 | acgnc
68 | +
69 | actgc
70 |
71 | @cgnc
72 | @QualityError3
73 | ACTGC
74 | acgnc
75 | +
76 | actgc77
77 | acgnc
78 | @PlusValid1
79 | ACTGCacgnc
80 | +PlusValid1
81 | actgcacgnc
82 | @PlusValid2
83 | ACTGCacgnc
84 | +PlusValid2 Added comment
85 | actgcacgnc
86 | @PlusError1
87 | ACTGCacgnc
88 | +PlusError2
89 | actgcacgnc
90 | @InvalidColor
91 | 0123.0321.011
92 | +
93 | 0123.0321.011
94 | @PlusError2
95 | ACTGCacgnc
--------------------------------------------------------------------------------
/general/BaseQualityHelper.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "BaseQualityHelper.h"
19 |
20 | #include
21 |
22 | baseQualityConvertor bQualityConvertor;
23 |
24 | baseQualityConvertor::baseQualityConvertor()
25 | {
26 | // Create a quick lookup table to speed up conversion of
27 | // base quality values stored as log10 (error rates) into
28 | // fractional error rates
29 | for (int i = 0; i <= 255; i++)
30 | doubleLookup[i] = pow(0.1, i * 0.1);
31 | // doubleLookup[255] = 0.0;
32 | }
33 |
34 | double baseQualityConvertor::toDouble(unsigned char bq)
35 | {
36 | return doubleLookup[bq];
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/general/BaseQualityHelper.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __BASEQUALITY_H__
19 | #define __BASEQUALITY_H__
20 |
21 | class baseQualityConvertor
22 | {
23 | public:
24 | baseQualityConvertor();
25 |
26 | double toDouble(unsigned char baseQuality);
27 |
28 | private:
29 | double doubleLookup[256];
30 | };
31 |
32 | extern baseQualityConvertor bQualityConvertor;
33 |
34 |
35 | #endif
36 |
37 |
38 |
--------------------------------------------------------------------------------
/general/BaseUtilities.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010-2012 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __BASE_UTILITIES_H__
19 | #define __BASE_UTILITIES_H__
20 |
21 | #include
22 | #include
23 |
24 |
25 | /// This class contains static utilities for performing
26 | /// basic operations on bases.
27 | class BaseUtilities
28 | {
29 | public:
30 | /// Returns whether or not the specified bases is
31 | /// an indicator for ambiguity.
32 | /// \return true if base = 'n' or 'N' or '.'
33 | static bool isAmbiguous(char base);
34 |
35 | /// Returns whether or not two bases are equal (case insensitive),
36 | /// if one of the bases is '=', the bases are consided
37 | /// to be equal.
38 | static bool areEqual(char base1, char base2);
39 |
40 | /// Get phred base quality from the specified ascii quality.
41 | static uint8_t getPhredBaseQuality(char charQuality);
42 |
43 | /// Get ascii quality from the specified phred quality.
44 | static char getAsciiQuality(uint8_t phredQuality);
45 |
46 | static void reverseComplement(std::string& sequence);
47 |
48 | /// Character used when the quality is unknown.
49 | static const char UNKNOWN_QUALITY_CHAR = ' ';
50 | /// Int value used when the quality is unknown.
51 | static const uint8_t UNKNOWN_QUALITY_INT = 0xFF;
52 | };
53 |
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/general/Chromosome.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "Chromosome.h"
3 |
4 | Chromosome::Chromosome(GenomeSequence* gs, unsigned int chromosomeIndex)
5 | {
6 | assert(gs);
7 | assert(chromosomeIndex < (unsigned int)gs->getChromosomeCount());
8 |
9 | this->gs = gs;
10 | this->chromosomeIndex = chromosomeIndex;
11 | this->offset = gs->getChromosomeStart((int)chromosomeIndex);
12 | this->chromosomeSize = gs->getChromosomeSize((int)chromosomeIndex);
13 | }
14 |
15 | Chromosome::Chromosome(GenomeSequence* gs, const char* chromosomeName)
16 | {
17 | assert(gs);
18 | this->gs = gs;
19 |
20 | this->chromosomeIndex = gs->getChromosome(chromosomeName);
21 | assert(chromosomeIndex != INVALID_CHROMOSOME_INDEX);
22 |
23 | this->offset = gs->getChromosomeStart((int)chromosomeIndex);
24 | this->chromosomeSize = gs->getChromosomeSize((int)chromosomeIndex);
25 | }
26 |
27 | Chromosome::Chromosome(const char* genomseSequenceFileName, unsigned int chromosomeIndex, bool isColorSpace)
28 | {
29 | std::string s(genomseSequenceFileName);
30 | gs = new GenomeSequence;
31 | assert(gs);
32 | gs->setReferenceName(s);
33 | assert(!gs->open(isColorSpace));
34 | this->chromosomeIndex = chromosomeIndex;
35 | this->offset = gs->getChromosomeStart((int)chromosomeIndex);
36 | this->chromosomeSize = gs->getChromosomeSize((int)chromosomeIndex);
37 | }
38 |
39 | Chromosome::Chromosome(const std::string& genomseSequenceFileName, unsigned int chromosomeIndex, bool isColorSpace)
40 | {
41 | gs = new GenomeSequence;
42 | assert(gs);
43 | gs->setReferenceName(genomseSequenceFileName);
44 | assert(!gs->open(isColorSpace));
45 | this->chromosomeIndex = chromosomeIndex;
46 | this->offset = gs->getChromosomeStart((int)chromosomeIndex);
47 | this->chromosomeSize = gs->getChromosomeSize((int)chromosomeIndex);
48 | }
49 |
--------------------------------------------------------------------------------
/general/Chromosome.h:
--------------------------------------------------------------------------------
1 | #ifndef _CHROMOSOME_H_
2 | #define _CHROMOSOME_H_
3 |
4 | #include "GenomeSequence.h"
5 |
6 | class Chromosome{
7 | public:
8 | explicit Chromosome(GenomeSequence* gs, unsigned int chrosomeIndex);
9 | explicit Chromosome(GenomeSequence* gs, const char* chromosomeName);
10 | explicit Chromosome(const char* genomseSequenceFileName, unsigned int chromosomeIndex, bool isColorSpace);
11 | explicit Chromosome(const std::string& genomseSequenceFileName, unsigned int chromosomeIndex, bool isColorSpace);
12 | genomeIndex_t Length() const
13 | {
14 | return chromosomeSize;
15 | }
16 | // 0-based index
17 | inline char operator[](genomeIndex_t index) const
18 | {
19 | index += offset;
20 | return (*gs)[index];
21 | }
22 | const char* Name() const {
23 | return gs->getChromosomeName(this->chromosomeIndex);
24 | }
25 | private:
26 | GenomeSequence* gs;
27 | int chromosomeIndex;
28 | genomeIndex_t offset; // chromosome index 0 corresponds (*gs)[offset]
29 | genomeIndex_t chromosomeSize; // return the length of the chromosome
30 | };
31 |
32 | #endif /* _CHROMOSOME_H_ */
33 |
--------------------------------------------------------------------------------
/general/Constant.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef _CONSTANT_H_
19 | #define _CONSTANT_H_
20 |
21 | #define COMPAREFUNC (int (*)(const void *, const void *))
22 |
23 | #define BUFSIZE 1024
24 | #define FILENAMELEN 100
25 | #define IDLEN 20
26 |
27 | #define SEPARATORS " \t\n\r\f/"
28 | #define WHITESPACE " \t\n\r\f"
29 |
30 | #define SWTABLESKIP 9
31 | #define SWTABLEMAX 10000
32 |
33 | #define _NAN_ ((double) (6.66666e-66))
34 |
35 | #define QTDTDATA "qtdt.dat"
36 | #define QTDTPED "qtdt.ped"
37 | #define QTDTIBD "qtdt.ibd"
38 | #define QTDTRAW "regress.tbl"
39 | #define GENIHDATAIN "genih.dat"
40 |
41 | #ifndef _WIN32
42 | #define stricmp strcasecmp
43 | #endif
44 |
45 | // Constants for older haplotype handling programs
46 | // Constants for HAPLOXT
47 | #define XT_MAX_ALLELES 50 // Maximum alleles for crosstabulation
48 | #define XT_VECTORSIZE 10000 // Total haplotypes in population
49 | #define XT_POOLTRESH 7 // Threshold for pooling rare alleles
50 | // Simwalk Haplotype Vectors
51 | #define HV_MAXSIZE 100 // Haplotypes in single SimWalk pedigree
52 | #define HV_INFOTRESH 75 // Percentage of loci typed
53 | #define HV_STATELENGTH 100 // Markers per haplotype
54 | #define HV_SKIPLINES 4 // lines to skip at bottom of family tree
55 | // Simwalk Summary Files
56 | #define HT_TABLE_SIZE 1000
57 | #define HT_SKIP_LINES 9
58 |
59 | #endif
60 |
61 |
--------------------------------------------------------------------------------
/general/Error.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "Error.h"
19 |
20 | #include
21 | #include
22 | #include
23 | #include "PhoneHome.h"
24 |
25 | // Declare a dummy class to ensure that compilers recognize this as C++ code
26 | class String;
27 |
28 | void error(const char * msg, ...)
29 | {
30 | va_list ap;
31 |
32 | va_start(ap, msg);
33 |
34 | printf("\nFATAL ERROR - \n");
35 | vprintf(msg, ap);
36 | printf("\n\n");
37 |
38 | va_end(ap);
39 |
40 | PhoneHome::completionStatus("error: Exiting due to Fatal Error");
41 | exit(EXIT_FAILURE);
42 | }
43 |
44 | void warning(const char * msg, ...)
45 | {
46 | va_list ap;
47 |
48 | va_start(ap, msg);
49 |
50 | fprintf(stderr,"\n\aWARNING - \n");
51 | vfprintf(stderr,msg, ap);
52 | fprintf(stderr,"\n");
53 |
54 | va_end(ap);
55 | }
56 |
57 | void numerror(const char * msg , ...)
58 | {
59 | va_list ap;
60 |
61 | va_start(ap, msg);
62 |
63 | printf("\nFATAL NUMERIC ERROR - ");
64 | vprintf(msg, ap);
65 | printf("\n\n");
66 |
67 | va_end(ap);
68 |
69 | exit(EXIT_FAILURE);
70 | }
71 |
--------------------------------------------------------------------------------
/general/Error.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef _ERROR_H_
19 | #define _ERROR_H_
20 |
21 | // #ifdef __cplusplus
22 | // extern "C" {
23 | // #endif
24 |
25 | void error(const char * msg, ...);
26 | void warning(const char * msg, ...);
27 | void numerror(const char * msg, ...);
28 |
29 | // #ifdef __cplusplus
30 | // };
31 | // #endif
32 |
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/general/ErrorHandler.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "ErrorHandler.h"
19 | #include "PhoneHome.h"
20 |
21 | #include
22 | #include
23 |
24 | // Constructor
25 | ErrorHandler::ErrorHandler()
26 | {
27 | }
28 |
29 |
30 | // Destructor
31 | ErrorHandler::~ErrorHandler()
32 | {
33 | }
34 |
35 |
36 | void ErrorHandler::handleError(const char* message,
37 | HandlingType handlingType)
38 | {
39 | // Check the handling type.
40 | switch(handlingType)
41 | {
42 | case(EXCEPTION):
43 | throw(std::runtime_error(message));
44 | break;
45 | case(ABORT):
46 | std::cerr << message << "\nExiting" << std::endl;
47 | PhoneHome::completionStatus("ErrorHandler: Exiting due to Error");
48 | exit(-1);
49 | break;
50 | case(RETURN):
51 | return;
52 | break;
53 | default:
54 | std::cerr << message << "\nUnknown Handle Type: Exiting"
55 | << std::endl;
56 | PhoneHome::completionStatus("Exiting, ErrorHandler::unknown handle type.");
57 | exit(-1);
58 | break;
59 | }
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/general/ErrorHandler.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __ERROR_HANDLER_H__
19 | #define __ERROR_HANDLER_H__
20 |
21 | #include
22 |
23 | /// Class that controls the handling of errors.
24 | class ErrorHandler
25 | {
26 | public:
27 |
28 | /// This specifies how this class should respond to errors.
29 | enum HandlingType {EXCEPTION, ///< throw an exception for the error
30 | ABORT, ///< exit the program on the error
31 | RETURN ///< just return failure on the error
32 | };
33 |
34 | /// Constructor
35 | ErrorHandler();
36 |
37 | /// Destructor
38 | ~ErrorHandler();
39 |
40 | /// Handle an error based on the error handling type.
41 | static void handleError(const char* message,
42 | HandlingType handlingType = EXCEPTION);
43 |
44 | private:
45 | };
46 |
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/general/FileType.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "FileType.h"
19 |
20 | FileType::FileType()
21 | {
22 | };
23 |
24 |
25 | FileType::~FileType()
26 | {
27 | };
28 |
29 |
30 | // Set by the InputFile to inform this class if buffering
31 | // is used. Maybe used by child clases (bgzf) to disable
32 | // tell. NOTE: this class does no buffering, the
33 | // buffering is handled by the calling class.
34 | void FileType::setBuffered(bool buffered)
35 | {
36 | myUsingBuffer = buffered;
37 | }
38 |
39 | //
40 | // one class, BgzfFileTypeRecovery overloads this method because
41 | // it is able to sync on a new record using the checkSignature
42 | // callback function.
43 | //
44 | // For all other classes, this is a NOP (sync fails).
45 | //
46 | bool FileType::attemptRecoverySync(bool (*checkSignature)(void *data) , int length)
47 | {
48 | return false;
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/general/Generic.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "Generic.h"
19 |
20 | #if defined(TEST)
21 |
22 | #include
23 | #include
24 | #include
25 | #include
26 |
27 | //
28 | // g++ -g -o testGeneric -DTEST Generic.cpp
29 | //
30 | int main(int argc, const char **argv)
31 | {
32 | std::vector a;
33 | std::vector< std::pair > b;
34 | std::pair c;
35 |
36 | std::vector::iterator i;
37 |
38 | a.push_back(0);
39 | a.push_back(1);
40 | a.push_back(2);
41 | a.push_back(3);
42 |
43 | std::cout << a;
44 |
45 | c.first = 10;
46 | c.second = 20;
47 | b.push_back(c);
48 | b.push_back(c);
49 | b.push_back(c);
50 |
51 | std::cout << b;
52 |
53 | i = a.begin();
54 |
55 | std::list > l;
56 |
57 | l.push_back(c);
58 |
59 | std::cout << l;
60 |
61 | // std::cout << "iterator i: " << i << std::endl;
62 |
63 | // std::cout << argv;
64 | }
65 |
66 | #endif
67 |
--------------------------------------------------------------------------------
/general/GenotypeLists.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __GENOTYPE_ELIMINATION__
19 | #define __GENOTYPE_ELIMINATION__
20 |
21 | #include "Pedigree.h"
22 |
23 | class GenotypeList
24 | {
25 | public:
26 |
27 | IntArray allele1, allele2;
28 | IntArray alleles;
29 |
30 | bool ignore;
31 | int checked;
32 |
33 | GenotypeList();
34 |
35 | static bool EliminateGenotypes(Pedigree & ped, Family * family, int marker);
36 |
37 | void Dimension(int genotypes);
38 | void Delete(int genotype);
39 |
40 | bool Matches(int genotype, int allele);
41 | bool Matches(int allele);
42 |
43 | int SaveGenotype(int genotype);
44 | void SetGenotype(int genotype, int al1, int al2);
45 |
46 | private:
47 | static void InitializeList(GenotypeList * list, Pedigree & p, Family * f, int marker);
48 | static bool PairwiseCheck(GenotypeList * list, Pedigree & p, Family * f);
49 | static bool FamilyCheck(GenotypeList * list, Pedigree & p, Family * f);
50 |
51 | static bool CheckTrio(GenotypeList * list, int fatid, int motid, int child, int i, int j, int k);
52 | static bool TrimParent(GenotypeList * list, Person & person, int fatid, int motid);
53 | static bool Cleanup(GenotypeList * list, Person & person, int fatid, int motid, int child, int geno);
54 |
55 | static void Print(GenotypeList * List, Pedigree & p, Family * f, int marker);
56 | };
57 |
58 |
59 |
60 | #endif
61 |
--------------------------------------------------------------------------------
/general/GzipFileType.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "GzipFileType.h"
19 | #include
20 | #include
21 |
22 | #ifdef __ZLIB_AVAILABLE__
23 |
24 | GzipFileType::GzipFileType(const char * filename, const char * mode)
25 | {
26 | // If the file is for write and is '-', then write to stdout.
27 | if(((mode[0] == 'w') || (mode[0] == 'W')) &&
28 | ((strcmp(filename, "-") == 0) || (strcmp(filename, "-.gz") == 0)))
29 | {
30 | // Write to stdout.
31 | gzHandle = gzdopen(fileno(stdout), mode);
32 | }
33 | else if(((mode[0] == 'r') || (mode[0] == 'R')) &&
34 | ((strcmp(filename, "-") == 0) || (strcmp(filename, "-.gz") == 0)))
35 | {
36 | // read from stdin
37 | gzHandle = gzdopen(fileno(stdin), mode);
38 | }
39 | else
40 | {
41 | // Open the file.
42 | gzHandle = gzopen(filename, mode);
43 | }
44 | };
45 |
46 | #endif
47 |
48 |
--------------------------------------------------------------------------------
/general/Hash.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __HASH_H__
19 | #define __HASH_H__
20 |
21 | unsigned int hash(const unsigned char * key, unsigned int length, unsigned int initval);
22 |
23 | unsigned int hash_no_case(const unsigned char * key, unsigned int length, unsigned int initval);
24 |
25 | #endif
26 |
27 |
--------------------------------------------------------------------------------
/general/InplaceMerge.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "InplaceMerge.h"
19 |
20 | #if defined(TEST)
21 | #include "iostream"
22 | #include "Generic.h"
23 |
24 | int main(int argc, const char **argv)
25 | {
26 | int a[] = {1,2,3,4,5};
27 | int b[] = {2,4,6,7,10};
28 | int c[] = {3,5,8,10,11};
29 |
30 | std::vector z(15);
31 |
32 | std::copy(a, a+5, z.begin());
33 | std::copy(b, b+5, z.begin() + 5);
34 | std::copy(c, c+5, z.begin() + 10);
35 |
36 | std::vector indeces, counts;
37 |
38 | indeces.push_back(0);
39 | indeces.push_back(5);
40 | indeces.push_back(10);
41 |
42 | counts.push_back(5);
43 | counts.push_back(5);
44 | counts.push_back(5);
45 |
46 | inplace_merge(indeces, counts, 0, 3, z);
47 |
48 | std::cout << z;
49 | }
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/general/Input.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __INPUT_H__
19 | #define __INPUT_H__
20 |
21 | void Input(const char * prompt, int & n, int _default = 0);
22 | void Input(const char * prompt, double & d, double _default = 0.0);
23 | void Input(const char * prompt, char & c, char _default = 'A');
24 | void Input(const char * prompt, char * s, const char * _default = "");
25 | void Input(const char * prompt, bool & b, bool _default);
26 |
27 | void InputBounds(const char * prompt, int & n, int min, int max,
28 | int _default = 0);
29 | void InputBounds(const char * prompt, double & d, double min, double max,
30 | double _default = 0);
31 |
32 | extern int InputPromptWidth;
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/general/LICENSE.twister:
--------------------------------------------------------------------------------
1 | Mersenne twister code is included in the file Random.cpp
2 |
3 | COPYRIGHT NOTICE FOR MERSENNE TWISTER
4 | =====================================
5 |
6 | Mersenne twister coded by Takuji Nishimura and Makoto Matsumoto.
7 |
8 | Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
9 | All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions
13 | are met:
14 |
15 | 1. Redistributions of source code must retain the above copyright
16 | notice, this list of conditions and the following disclaimer.
17 |
18 | 2. Redistributions in binary form must reproduce the above copyright
19 | notice, this list of conditions and the following disclaimer in the
20 | documentation and/or other materials provided with the distribution.
21 |
22 | 3. The names of its contributors may not be used to endorse or promote
23 | products derived from this software without specific prior written
24 | permission.
25 |
26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
30 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 |
38 |
--------------------------------------------------------------------------------
/general/LongLongCounter.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "LongLongCounter.h"
19 |
20 | LongCounter::LongCounter() : LongHash()
21 | {
22 | SetAllowDuplicateKeys(false);
23 | }
24 |
25 | void LongCounter::IncrementCount(long long key)
26 | {
27 | unsigned int slot = Find(key);
28 |
29 | if (slot == LH_NOTFOUND)
30 | Add(key, 1);
31 | else if (Object(slot) == -1)
32 | Delete(slot);
33 | else
34 | Object(slot)++;
35 | }
36 |
37 | void LongCounter::DecrementCount(long long key)
38 | {
39 | unsigned int slot = Find(key);
40 |
41 | if (slot == LH_NOTFOUND)
42 | Add(key, -1);
43 | else if (Object(slot) == 1)
44 | Delete(slot);
45 | else
46 | Object(slot)--;
47 | }
48 |
49 | int LongCounter::GetCount(long long key)
50 | {
51 | unsigned int slot = Find(key);
52 |
53 | if (slot == LH_NOTFOUND)
54 | return 0;
55 | else
56 | return Object(slot)--;
57 | }
58 |
59 |
60 |
--------------------------------------------------------------------------------
/general/LongLongCounter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __LONGLONGCOUNTER_H_
19 | #define __LONGLONGCOUNTER_H_
20 |
21 | #include "LongHash.h"
22 |
23 | class LongCounter : public LongHash
24 | {
25 | public:
26 | LongCounter();
27 |
28 | void IncrementCount(long long key);
29 | void DecrementCount(long long key);
30 | int GetCount(long long key);
31 | };
32 |
33 | #endif
34 |
35 |
36 |
--------------------------------------------------------------------------------
/general/MapFunction.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "MapFunction.h"
19 | #include "MathConstant.h"
20 |
21 | #include
22 |
23 | double DistanceToRecombination(double distance)
24 | {
25 | return (1.0 - exp(-2.0 * distance)) * 0.5;
26 | }
27 |
28 | double RecombinationToDistance(double recombination)
29 | {
30 | return (log(max(1.0 - 2 * recombination, 1e-7)) * -0.5);
31 | }
32 |
33 | double KosambiDistanceToRecombination(double distance)
34 | {
35 | double e_to_4x = exp(4.0 * distance);
36 |
37 | return (0.5 *(e_to_4x - 1.0) / (e_to_4x + 1.0));
38 | }
39 |
40 | double RecombinationToKosambiDistance(double theta)
41 | {
42 | return 0.25 * log((1.0 + 2*theta) / max(1.0 - 2.0*theta, 1e-7));
43 | }
44 |
--------------------------------------------------------------------------------
/general/MapFunction.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __MAPFUNCTION_H__
19 | #define __MAPFUNCTION_H__
20 |
21 | double DistanceToRecombination(double distance);
22 | double RecombinationToDistance(double recombination);
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/general/MemoryInfo.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "MemoryInfo.h"
19 |
20 | String & MemoryInfo(double bytes)
21 | {
22 | static String info;
23 |
24 | if (bytes < 1024)
25 | return info = "<1.0 kb";
26 |
27 | if (bytes < 1024. * 1024.)
28 | info.printf("%.1f kb", (bytes + 1023) / 1024.);
29 | else if (bytes < 1024. * 1024. * 1024.)
30 | info.printf("%.1f mb", (bytes + 1024. * 1024. - 1) / (1024. * 1024.));
31 | else if (bytes < 1024. * 1024. * 1024. * 1024.)
32 | info.printf("%.1f gb", bytes / (1024. * 1024. * 1024.));
33 | else
34 | info.printf("%.1f tb", bytes / (1024. * 1024. * 1024. * 1024.));
35 |
36 | return info;
37 | }
38 |
--------------------------------------------------------------------------------
/general/MemoryInfo.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __MEMORYINFO_H__
19 | #define __MEMORYINFO_H__
20 |
21 | #include "StringBasics.h"
22 |
23 | String & MemoryInfo(double bytes);
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/general/PedigreeAlleleFreq.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __ALLELEFREQUENCIES_H__
19 | #define __ALLELEFREQUENCIES_H__
20 |
21 | #include "Pedigree.h"
22 |
23 | int CountAlleles(Pedigree & ped, int marker);
24 | void LumpAlleles(Pedigree & ped, int marker, double threshold, bool reorder);
25 |
26 | #define FREQ_ALL 0
27 | #define FREQ_FOUNDERS 1
28 | #define FREQ_EQUAL 2
29 |
30 | // Returns true if frequencies estimated, false if previous information okay
31 | bool EstimateFrequencies(Pedigree & ped, int marker, int estimator);
32 |
33 | #endif
34 |
35 |
36 |
--------------------------------------------------------------------------------
/general/Performance.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 Regents of the University of Michigan
3 | *
4 | * Permission is hereby granted, free of charge, to any person
5 | * obtaining a copy of this software and associated documentation
6 | * files (the "Software"), to deal in the Software without
7 | * restriction, including without limitation the rights to use,
8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the
10 | * Software is furnished to do so, subject to the following
11 | * conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be
14 | * included in all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 | * OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef _PERFORMANCE_H
27 | #define _PERFORMANCE_H
28 |
29 | #include
30 | #include
31 |
32 | class Timing
33 | {
34 | timeval startInterval;
35 | timeval endInterval;
36 | public:
37 | Timing()
38 | {
39 | start();
40 | }
41 | void start();
42 | void end();
43 | double interval();
44 | };
45 |
46 | inline void Timing::start()
47 | {
48 | gettimeofday(&startInterval, NULL);
49 | }
50 |
51 | inline void Timing::end()
52 | {
53 | gettimeofday(&endInterval, NULL);
54 | }
55 |
56 | ///
57 | /// Return time interval between start() and end()
58 | /// @return elapsed time in seconds
59 | ///
60 | inline double Timing::interval()
61 | {
62 | return (endInterval.tv_sec + (endInterval.tv_usec/1000000.0)) -
63 | (startInterval.tv_sec + (startInterval.tv_usec/1000000.0));
64 | }
65 |
66 | #endif
67 |
--------------------------------------------------------------------------------
/general/QuickIndex.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __QUICKINDEX_H__
19 | #define __QUICKINDEX_H__
20 |
21 | #include "MathVector.h"
22 | #include "StringArray.h"
23 | #include "StringHash.h"
24 | #include "IntArray.h"
25 | #include "StringMap.h"
26 |
27 | class QuickIndex : public IntArray
28 | {
29 | public:
30 | QuickIndex();
31 | QuickIndex(const IntArray & source_data)
32 | {
33 | Index(source_data);
34 | }
35 | QuickIndex(const StringArray & source_data)
36 | {
37 | Index(source_data);
38 | }
39 | QuickIndex(const Vector & source_data)
40 | {
41 | Index(source_data);
42 | }
43 |
44 | void Index(const IntArray & source_data);
45 | void Index(const StringArray & source_data);
46 | void Index(const Vector & source_data);
47 | void IndexCounts(const StringIntMap & source_data);
48 | void IndexCounts(const StringIntHash & source_data);
49 |
50 | private:
51 | const void * source;
52 | int datatype;
53 |
54 | bool IsBefore(int i, int j);
55 | void Sort();
56 | };
57 |
58 | #endif
59 |
60 |
--------------------------------------------------------------------------------
/general/Sort.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __SORT_H__
19 | #define __SORT_H__
20 |
21 | #include "Constant.h"
22 |
23 | #include
24 |
25 | void QuickSort(void *base, size_t nelem, size_t width,
26 | int (*cmp)(const void *, const void *));
27 |
28 | void QuickSort2(void *base, void * base2, size_t nelem, size_t width,
29 | int (*cmp)(const void *, const void *));
30 |
31 | void * BinarySearch(const void *key, const void *base,
32 | size_t nelem, size_t width,
33 | int (*cmp)(const void *, const void *));
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/general/String.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include
19 |
20 | #include "String.h"
21 | #include
22 |
23 | #ifdef OBSOLETE
24 |
25 | std::vector *csg::string::split(char splitChar)
26 | {
27 | std::vector *result = new std::vector;
28 | csg::string word;
29 |
30 | for (size_t i = 0; ipush_back(word);
35 | word.clear();
36 | }
37 | else
38 | word.push_back((*this)[i]);
39 | }
40 | if (word.size()>0) result->push_back(word);
41 | return result;
42 | }
43 |
44 |
45 | #if defined(TEST)
46 |
47 | int main(int argc, const char **argv)
48 | {
49 | csg::string string("abcdef:abcdefghijk");
50 |
51 | std::vector *result = string.split(':');
52 |
53 | for (int i=0; isize(); i++)
54 | {
55 | std::cout << i << "\t" << (*result)[i] << std::endl;
56 | }
57 | delete result; // suck
58 |
59 | }
60 | #endif
61 |
62 | #endif
63 |
--------------------------------------------------------------------------------
/general/StringAlias.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __STRINGALIAS_H__
19 | #define __STRINGALIAS_H__
20 |
21 | #include "StringArray.h"
22 | #include "StringHash.h"
23 |
24 | class StringAlias
25 | {
26 | public:
27 | StringAlias() {}
28 | virtual ~StringAlias() {}
29 |
30 | void SetAlias(String & string, String & alias);
31 |
32 | const String & GetAlias(const String & string) const;
33 | int GetAliases(StringArray & list) const;
34 |
35 | bool ReadFromFile(const char * filename);
36 | bool ReadFromFile(IFILE & input);
37 |
38 | private:
39 | StringIntHash lookup;
40 | StringArray aliases;
41 | };
42 |
43 | #endif
44 |
45 |
--------------------------------------------------------------------------------
/general/UnitTest.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __UNITTEST_H
19 | #define __UNITTEST_H
20 |
21 | #include
22 | #include
23 |
24 | class UnitTest
25 | {
26 | protected:
27 | std::string m_title;
28 | int m_failures;
29 | int m_testNum;
30 |
31 | public:
32 | UnitTest(const char *title) : m_title(title), m_failures(0), m_testNum(0) {;};
33 | void test();
34 | int getPassCount() {return m_testNum - m_failures;}
35 | int getFailureCount() {return m_failures;}
36 | const std::string getTitle() const {return m_title;}
37 | };
38 |
39 | std::ostream &operator << (std::ostream &stream, UnitTest &test)
40 | {
41 | stream << test.getTitle() << " PASS: " << test.getPassCount() <<
42 | " FAIL: " << test.getFailureCount() << std::endl;
43 | return stream;
44 | }
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/general/obj/README.txt:
--------------------------------------------------------------------------------
1 | This contains the objects for the above directory.
--------------------------------------------------------------------------------
/general/test/Chromosome_test.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include
19 |
20 | #include "Chromosome.h"
21 |
22 |
23 | TEST(ChromosomeTest, staticLookupTest)
24 | {
25 | // GenomeSequence *gs = NULL;
26 | // Chromosome c(gs, 0U);
27 | // quick sanity check...
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/general/test/baseUtilitiesTest/.gitignore:
--------------------------------------------------------------------------------
1 | baseUtilitiesTest
2 |
3 |
--------------------------------------------------------------------------------
/general/test/baseUtilitiesTest/BaseUtilitiesTest.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 | #include "BaseUtilitiesTest.h"
18 | #include
19 | #include
20 |
21 | int main(int argc, char ** argv)
22 | {
23 | testReverseComplement();
24 | }
25 |
26 | void testReverseComplement()
27 | {
28 | // Test odd number of bases.
29 | std::string testString = "ACGTAACCTTGGG";
30 | std::string expectedReverse = "CCCAAGGTTACGT";
31 |
32 | BaseUtilities::reverseComplement(testString);
33 | assert(testString == expectedReverse);
34 |
35 | // Test even number of bases.
36 | testString = "ACGTAACCTGGG";
37 | expectedReverse = "CCCAGGTTACGT";
38 |
39 | BaseUtilities::reverseComplement(testString);
40 | assert(testString == expectedReverse);
41 | }
42 |
--------------------------------------------------------------------------------
/general/test/baseUtilitiesTest/BaseUtilitiesTest.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 | #include
18 | #include "BaseUtilities.h"
19 |
20 | void testReverseComplement();
21 |
--------------------------------------------------------------------------------
/general/test/baseUtilitiesTest/Makefile:
--------------------------------------------------------------------------------
1 | EXE = baseUtilitiesTest
2 | TOOLBASE = BaseUtilitiesTest
3 |
4 | TEST_COMMAND= ./baseUtilitiesTest
5 |
6 | include ../../../Makefiles/Makefile.test
--------------------------------------------------------------------------------
/general/test/cigar/.gitignore:
--------------------------------------------------------------------------------
1 | cigarRollerTest
2 |
--------------------------------------------------------------------------------
/general/test/cigar/CigarRollerTest.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 | #include "CigarRoller.h"
18 |
19 |
20 | class CigarRollerTest
21 | {
22 | public:
23 | int test();
24 |
25 |
26 | private:
27 | };
28 |
--------------------------------------------------------------------------------
/general/test/cigar/Makefile:
--------------------------------------------------------------------------------
1 | PATH_TO_BASE=../../..
2 | EXE = cigarRollerTest
3 | TOOLBASE = CigarRollerTest
4 | TEST_COMMAND= mkdir -p results; \
5 | ./cigarRollerTest
6 |
7 | include $(PATH_TO_BASE)/Makefiles/Makefile.test
--------------------------------------------------------------------------------
/general/test/dbsnp/.gitignore:
--------------------------------------------------------------------------------
1 | dbsnpTest
2 | results/
3 |
--------------------------------------------------------------------------------
/general/test/dbsnp/Makefile:
--------------------------------------------------------------------------------
1 | PATH_TO_BASE=../../..
2 | EXE = dbsnpTest
3 | SRCONLY = Main.cpp
4 |
5 | TEST_COMMAND=@mkdir -p results; ./dbsnpTest 2> results/results.txt && diff expected/results.txt results/results.txt
6 |
7 | include ../../../Makefiles/Makefile.test
--------------------------------------------------------------------------------
/general/test/dbsnp/expected/results.txt:
--------------------------------------------------------------------------------
1 |
2 | Standard VCF DBSNP test
3 | Load dbSNP file 'testFiles/dbsnp.vcf': (as text file) GenomeSequence::populateDBSNP: ignored 1 SNP positions due to invalid format of line.
4 | DONE!
5 | dbsnp 10232: 0
6 | dbsnp 10233: 1
7 | dbsnp 10234: 0
8 |
9 | GZIP VCF DBSNP test
10 | Load dbSNP file 'testFiles/dbsnp.vcf.gz': (as text file) GenomeSequence::populateDBSNP: ignored 1 SNP positions due to invalid format of line.
11 | DONE!
12 | dbsnp 10232: 0
13 | dbsnp 10233: 1
14 | dbsnp 10234: 0
15 |
--------------------------------------------------------------------------------
/general/test/dbsnp/testFiles/chr1_partial-bs.umfa:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/general/test/dbsnp/testFiles/chr1_partial-bs.umfa
--------------------------------------------------------------------------------
/general/test/dbsnp/testFiles/dbsnp.vcf.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/general/test/dbsnp/testFiles/dbsnp.vcf.gz
--------------------------------------------------------------------------------
/general/test/gtest.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 Regents of the University of Michigan
3 | *
4 | * Permission is hereby granted, free of charge, to any person
5 | * obtaining a copy of this software and associated documentation
6 | * files (the "Software"), to deal in the Software without
7 | * restriction, including without limitation the rights to use,
8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the
10 | * Software is furnished to do so, subject to the following
11 | * conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be
14 | * included in all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 | * OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include
27 | #include
28 | #include
29 | #include
30 |
31 | class GlobalTestEnvironment : public ::testing::Environment {
32 | public:
33 | virtual ~GlobalTestEnvironment();
34 | virtual void SetUp();
35 | virtual void TearDown();
36 | //public:
37 | //
38 | };
39 |
40 | GlobalTestEnvironment::~GlobalTestEnvironment()
41 | {
42 | }
43 |
44 | void GlobalTestEnvironment::SetUp()
45 | {
46 |
47 | }
48 |
49 | void GlobalTestEnvironment::TearDown()
50 | {
51 | }
52 |
53 |
54 | ::testing::Environment* const globalEnvironment = ::testing::AddGlobalTestEnvironment(new GlobalTestEnvironment);
55 |
56 | int main(int argc, char **argv) {
57 | ::testing::InitGoogleTest(&argc, argv);
58 | return RUN_ALL_TESTS();
59 | }
60 |
--------------------------------------------------------------------------------
/general/test/inputFileTest/.gitignore:
--------------------------------------------------------------------------------
1 | inputFileTest
2 | results/
3 |
--------------------------------------------------------------------------------
/general/test/inputFileTest/InputFileTest.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 | #include
18 | #include "InputFile.h"
19 |
20 |
21 | class IFILE_Test : public InputFile
22 | {
23 | public:
24 | void test();
25 |
26 | static const int TEST_FILE_SIZE;
27 | static const int BGZF_TEST_FILE_SIZE;
28 | static const std::string TEST_FILE_CONTENTS;
29 |
30 | private:
31 | void testAll(const char* extension);
32 | void test_readFromFile(const char* extension);
33 | void test_readTilChar(const char* extension);
34 |
35 | // Tested together because they are used to test each other.
36 | void test_ifeof_ifrewind(const char* extension);
37 |
38 | // Tested together to verify they can be successfully be called after the
39 | // other has been called.
40 | void test_ifread_ifgetc(const char* extension);
41 |
42 | void test_ifclose(const char* extension);
43 |
44 | void test_ifseek(const char* extension);
45 |
46 | void test_noExistRead(const char *extension);
47 |
48 | void openFile(const char* extension);
49 | void openLargeFile(const char* extension);
50 | void openNoExistFile(const char* extension);
51 |
52 | // Buffer used for reading into.
53 | static const int MAX_TEST_BUFFER_SIZE = 100;
54 | char myTestBuffer[MAX_TEST_BUFFER_SIZE];
55 |
56 | };
57 |
--------------------------------------------------------------------------------
/general/test/inputFileTest/Makefile:
--------------------------------------------------------------------------------
1 | EXE = inputFileTest
2 | TOOLBASE = InputFileTest
3 |
4 | ifeq ($(ZLIB_AVAIL), 0)
5 | TEST_COMMAND= mkdir -p results && \
6 | ./inputFileTest > results/results.log && \
7 | diff data/InputFileTest.txt results/bgzfFile.glf && \
8 | diff data/InputFileTest.txt results/defaultFile.glf && \
9 | diff data/InputFileTest.txt results/defaultFile.gz && \
10 | diff data/InputFileTest.txt results/gzipFile.glf && \
11 | diff data/InputFileTest.txt results/InputFileTest.glf && \
12 | diff data/InputFileTest.txt results/uncompressedFile.glf && \
13 | diff data/textFile.txt results/textFile.gz && \
14 | diff data/textFile.txt results/textFile1.gz && \
15 | diff results/results.log expected/resultsNoZlib.log
16 | else
17 | TEST_COMMAND= mkdir -p results && \
18 | ./inputFileTest > results/results.log && \
19 | diff data/InputFileTest.bam results/bgzfFile.glf && \
20 | diff data/InputFileTest.txt results/defaultFile.glf && \
21 | diff data/InputFileTest.gz results/defaultFile.gz && \
22 | diff data/InputFileTest.gz results/gzipFile.glf && \
23 | diff data/InputFileTest.txt results/InputFileTest.glf && \
24 | diff data/InputFileTest.txt results/uncompressedFile.glf && \
25 | diff data/textFile.gz results/textFile.gz && \
26 | diff data/textFile.gz results/textFile1.gz && \
27 | diff results/results.log expected/results.log
28 | endif
29 |
30 |
31 | include ../../../Makefiles/Makefile.test
--------------------------------------------------------------------------------
/general/test/inputFileTest/data/InputFileTest.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/general/test/inputFileTest/data/InputFileTest.bam
--------------------------------------------------------------------------------
/general/test/inputFileTest/data/InputFileTest.glf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/general/test/inputFileTest/data/InputFileTest.glf
--------------------------------------------------------------------------------
/general/test/inputFileTest/data/InputFileTest.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/general/test/inputFileTest/data/InputFileTest.gz
--------------------------------------------------------------------------------
/general/test/inputFileTest/data/InputFileTest.txt:
--------------------------------------------------------------------------------
1 | ABCDabcd1234
2 | EFGefg567
3 | hijklHIJKL8910
--------------------------------------------------------------------------------
/general/test/inputFileTest/data/InputFileTest2.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/general/test/inputFileTest/data/InputFileTest2.gz
--------------------------------------------------------------------------------
/general/test/inputFileTest/data/InputFileTest2.txt:
--------------------------------------------------------------------------------
1 | ABCDEFG abcdefg
2 | 123456 hijklm
3 | 1
4 | NOP QRST UVW
5 |
6 | XYZ 789
7 | @#$
--------------------------------------------------------------------------------
/general/test/inputFileTest/data/InputFileTestLarge.bam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/general/test/inputFileTest/data/InputFileTestLarge.bam
--------------------------------------------------------------------------------
/general/test/inputFileTest/data/InputFileTestLarge.glf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/general/test/inputFileTest/data/InputFileTestLarge.glf
--------------------------------------------------------------------------------
/general/test/inputFileTest/data/InputFileTestLarge.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/general/test/inputFileTest/data/InputFileTestLarge.gz
--------------------------------------------------------------------------------
/general/test/inputFileTest/data/textFile.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/general/test/inputFileTest/data/textFile.gz
--------------------------------------------------------------------------------
/general/test/inputFileTest/data/textFile.txt:
--------------------------------------------------------------------------------
1 | Hello
2 | Hello.3 -2How are you?
3 | Bye
4 | 3.125z99z-99Good Bye!
5 |
--------------------------------------------------------------------------------
/general/test/inputFileTest/expected/results.log:
--------------------------------------------------------------------------------
1 |
2 | UncompressedFileType Tests:
3 | Passed test_readFromFile
4 | Passed test_readTilChar
5 | Passed test_ifeof_ifrewind
6 | Passed test_ifread_ifgetc
7 | Passed test_ifclose
8 | Passed test_ifseek
9 |
10 | GzipFileType Tests:
11 | Passed test_readFromFile
12 | Passed test_readTilChar
13 | Passed test_ifeof_ifrewind
14 | Passed test_ifread_ifgetc
15 | Passed test_ifclose
16 | Passed test_ifseek
17 |
18 | BgzfFileType Tests:
19 | Passed test_readFromFile
20 | Passed test_readTilChar
21 | Passed test_ifeof_ifrewind
22 | Passed test_ifread_ifgetc
23 | Passed test_ifclose
24 | Passed test_ifseek
25 |
26 | .glf file Tests:
27 | Passed test_readFromFile
28 | Passed test_readTilChar
29 | Passed test_ifeof_ifrewind
30 | Passed test_ifread_ifgetc
31 | Passed test_ifclose
32 | Passed test_ifseek
33 |
34 | Additional Tests:
35 |
--------------------------------------------------------------------------------
/general/test/inputFileTest/expected/resultsNoZlib.log:
--------------------------------------------------------------------------------
1 |
2 | UncompressedFileType Tests:
3 | Passed test_readFromFile
4 | Passed test_readTilChar
5 | Passed test_ifeof_ifrewind
6 | Passed test_ifread_ifgetc
7 | Passed test_ifclose
8 | Passed test_ifseek
9 |
10 | Additional Tests:
11 |
--------------------------------------------------------------------------------
/general/test/memoryMapArrayTest/.gitignore:
--------------------------------------------------------------------------------
1 | memoryMapArrayTest
2 |
--------------------------------------------------------------------------------
/general/test/memoryMapArrayTest/Makefile:
--------------------------------------------------------------------------------
1 | PATH_TO_BASE=../../..
2 | EXE = memoryMapArrayTest
3 | TOOLBASE = MemoryMapArrayTest
4 | TEST_COMMAND= mkdir -p results; \
5 | ./memoryMapArrayTest
6 |
7 | include $(PATH_TO_BASE)/Makefiles/Makefile.test
8 |
9 | obj/MemoryMapArrayTest.o: ../../MemoryMapArray.h
10 |
--------------------------------------------------------------------------------
/general/test/memoryMapArrayTest/MemoryMapArrayTest.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 | #include
18 | #include
19 |
20 | class UnitTest
21 | {
22 | protected:
23 | std::string m_title;
24 | int m_failures;
25 | int m_testNum;
26 |
27 | public:
28 | UnitTest(const char *title) : m_title(title), m_failures(0), m_testNum(0) {;};
29 | void test();
30 | int getPassCount() {return m_testNum - m_failures;}
31 | int getFailureCount() {return m_failures;}
32 | const std::string getTitle() const {return m_title;}
33 | };
34 |
35 | std::ostream &operator << (std::ostream &stream, UnitTest &test)
36 | {
37 | stream << test.getTitle() << " PASS: " << test.getPassCount() <<
38 | " FAIL: " << test.getFailureCount() << std::endl;
39 | return stream;
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/general/test/nonOverlapRegions/.gitignore:
--------------------------------------------------------------------------------
1 | nonOverlapRegionsTest
2 |
--------------------------------------------------------------------------------
/general/test/nonOverlapRegions/Makefile:
--------------------------------------------------------------------------------
1 | EXE = nonOverlapRegionsTest
2 | TOOLBASE = NonOverlapRegionsTest
3 |
4 | TEST_COMMAND= ./nonOverlapRegionsTest 2> results/NonOverlapRegionsTest.txt && diff results/NonOverlapRegionsTest.txt expectedNonOverlapRegionsTest.txt
5 |
6 | include ../../../Makefiles/Makefile.test
--------------------------------------------------------------------------------
/general/test/nonOverlapRegions/NonOverlapRegionsTest.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __NONOVERLAP_REGIONS_TEST_H__
19 | #define __NONOVERLAP_REGIONS_TEST_H__
20 |
21 | class NonOverlapRegionsTest
22 | {
23 | public:
24 | void test();
25 |
26 | private:
27 | void testChrom();
28 | void testPos();
29 | };
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/general/test/nonOverlapRegions/expectedNonOverlapRegionsTest.txt:
--------------------------------------------------------------------------------
1 | NonOverlapRegionPos::add: Invalid Range, start must be < end, but 40 >= 40
2 | NonOverlapRegionPos::add: Invalid Range, start must be < end, but 40 >= 38
3 |
--------------------------------------------------------------------------------
/general/test/nonOverlapRegions/results/.gitignore:
--------------------------------------------------------------------------------
1 | *.txt
--------------------------------------------------------------------------------
/general/test/packedVectorTest/.gitignore:
--------------------------------------------------------------------------------
1 | packedVectorTest
2 |
--------------------------------------------------------------------------------
/general/test/packedVectorTest/Makefile:
--------------------------------------------------------------------------------
1 | PATH_TO_BASE=../../..
2 | EXE = packedVectorTest
3 | TOOLBASE = PackedVectorTest
4 | TEST_COMMAND= ./packedVectorTest
5 |
6 | include $(PATH_TO_BASE)/Makefiles/Makefile.test
7 |
8 | obj/PackedVectorTest.o: PackedVectorTest.cpp ../../PackedVector.h
9 |
--------------------------------------------------------------------------------
/general/test/packedVectorTest/PackedVectorTest.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/general/test/packedVectorTest/PackedVectorTest.h
--------------------------------------------------------------------------------
/general/test/referenceSequenceTest/.gitignore:
--------------------------------------------------------------------------------
1 | referenceSequenceTest
2 |
--------------------------------------------------------------------------------
/general/test/referenceSequenceTest/Makefile:
--------------------------------------------------------------------------------
1 | PATH_TO_BASE=../../..
2 | EXE = referenceSequenceTest
3 | TOOLBASE = ReferenceSequenceTest
4 | TEST_COMMAND= ./referenceSequenceTest
5 |
6 | include $(PATH_TO_BASE)/Makefiles/Makefile.test
7 |
8 | obj/PackedVectorTest.o: ReferenceSequenceTest.cpp ../../ReferenceSequence.h
9 |
--------------------------------------------------------------------------------
/general/test/referenceSequenceTest/ReferenceSequenceTest.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/general/test/referenceSequenceTest/ReferenceSequenceTest.h
--------------------------------------------------------------------------------
/general/test/reusableVector/.gitignore:
--------------------------------------------------------------------------------
1 | reusableVectorTest
2 |
--------------------------------------------------------------------------------
/general/test/reusableVector/Makefile:
--------------------------------------------------------------------------------
1 | EXE = reusableVectorTest
2 | TOOLBASE = ReusableVectorTest
3 |
4 | TEST_COMMAND= ./reusableVectorTest
5 |
6 | include ../../../Makefiles/Makefile.test
--------------------------------------------------------------------------------
/general/test/reusableVector/ReusableVectorTest.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #ifndef __REUSABLE_VECTOR_TEST_H__
19 | #define __REUSABLE_VECTOR_TEST_H__
20 |
21 | class ReusableVectorTestDataType;
22 |
23 | class ReusableVectorTest
24 | {
25 | public:
26 | void test();
27 |
28 | private:
29 | void testReuse();
30 | bool testInvalidGetIndex(ReusableVector& testVector, int index);
31 | };
32 |
33 |
34 | class ReusableVectorTestDataType
35 | {
36 | public:
37 | ReusableVectorTestDataType();
38 | ~ReusableVectorTestDataType();
39 |
40 | void clear() {}
41 |
42 | static int ourValue;
43 |
44 | int myValue;
45 |
46 | static int ourNumDestructs;
47 |
48 |
49 | private:
50 | ReusableVectorTestDataType(const ReusableVectorTestDataType& other);
51 | };
52 |
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/general/test/string/.gitignore:
--------------------------------------------------------------------------------
1 | stringTest
2 |
--------------------------------------------------------------------------------
/general/test/string/Makefile:
--------------------------------------------------------------------------------
1 | EXE = stringTest
2 | TOOLBASE = StringTest
3 |
4 | TEST_COMMAND= mkdir -p results && \
5 | ./stringTest
6 |
7 | include ../../../Makefiles/Makefile.test
--------------------------------------------------------------------------------
/general/test/string/StringTest.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 | #include "StringBasics.h"
18 |
19 |
20 | void testAsInteger();
21 | void testReadLine();
22 | void testMethod(String temp);
23 |
--------------------------------------------------------------------------------
/general/test/string/testFiles/testFile.txt:
--------------------------------------------------------------------------------
1 | Hello, I am a testFile.
2 | This is my 2nd line.
3 | ThirdLine.
--------------------------------------------------------------------------------
/general/test/test_memmap_data.txt:
--------------------------------------------------------------------------------
1 | This is a test file for testing memmap.cpp - it does not have anything
2 | useful or interesting in it.
3 | If the size of this file changes, be sure to update memmap::test in
4 | memmap.cpp...
5 |
--------------------------------------------------------------------------------
/general/test/trimSequence/.gitignore:
--------------------------------------------------------------------------------
1 | trimSequence
--------------------------------------------------------------------------------
/general/test/trimSequence/Makefile:
--------------------------------------------------------------------------------
1 | PATH_TO_BASE=../../..
2 | EXE = trimSequence
3 | SRCONLY = TrimSequence.cpp
4 | TEST_COMMAND= ./trimSequence
5 |
6 | include $(PATH_TO_BASE)/Makefiles/Makefile.test
--------------------------------------------------------------------------------
/glf/GlfException.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "GlfException.h"
19 |
20 | GlfException::GlfException()
21 | : myStatus()
22 | {
23 | myStatus.setStatus(GlfStatus::UNKNOWN, "Failed operating on a GLF.");
24 | }
25 |
26 |
27 | GlfException::GlfException(const std::string& errorMsg)
28 | : myStatus()
29 | {
30 | myStatus.setStatus(GlfStatus::UNKNOWN, errorMsg.c_str());
31 | }
32 |
33 | GlfException::GlfException(GlfStatus::Status status,
34 | const std::string& errorMsg)
35 | : myStatus()
36 | {
37 | myStatus.setStatus(status, errorMsg.c_str());
38 | }
39 |
40 | GlfException::GlfException(const GlfStatus& status)
41 | : myStatus()
42 | {
43 | myStatus.addError(status);
44 | }
45 |
46 | GlfException::~GlfException() throw()
47 | {
48 | }
49 |
50 | const char* GlfException::what() const throw()
51 | {
52 | return(myStatus.getStatusMessage());
53 | }
54 |
--------------------------------------------------------------------------------
/glf/Makefile:
--------------------------------------------------------------------------------
1 | TOOLBASE = GlfException GlfFile GlfHeader GlfRecord GlfRefSection GlfStatus
2 |
3 | include ../Makefiles/Makefile.lib
--------------------------------------------------------------------------------
/glf/test/.gitignore:
--------------------------------------------------------------------------------
1 | glfTest
--------------------------------------------------------------------------------
/glf/test/Main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "ReadFiles.h"
19 | #include "WriteFiles.h"
20 | //#include "SamFileTest.h"
21 |
22 | int main(int argc, char ** argv)
23 | {
24 | testReadGlf();
25 | testWrite();
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/glf/test/Makefile:
--------------------------------------------------------------------------------
1 | EXE = glfTest
2 |
3 | SRCONLY = Main.cpp
4 | TOOLBASE = ReadFiles Validate WriteFiles
5 |
6 | TEST_COMMAND = ./glfTest
7 |
8 | include ../../Makefiles/Makefile.test
--------------------------------------------------------------------------------
/glf/test/ReadFiles.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "ReadFiles.h"
19 | #include "Validate.h"
20 | #include "GlfException.h"
21 | #include
22 |
23 | void testReadGlf()
24 | {
25 | GlfFile inGlf;
26 | assert(inGlf.openForRead("testFiles/testGlf.glf"));
27 |
28 | // Read the GLF Header.
29 | GlfHeader glfHeader;
30 | assert(inGlf.readHeader(glfHeader));
31 |
32 | validateHeader(glfHeader);
33 |
34 | // TODO, validate the rest of the file.
35 | // GlfRecord glfRecord;
36 | // assert(inGlf.ReadRecord(glfHeader, glfRecord) == true);
37 | // validateRead1(glfRecord);
38 |
39 | // Try opening a file that doesn't exist.
40 | bool exceptionCaught = false;
41 | try
42 | {
43 | inGlf.openForRead("testFiles/unknown");
44 | }
45 | catch(GlfException e)
46 | {
47 | exceptionCaught = true;
48 | }
49 | assert(exceptionCaught);
50 |
51 |
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/glf/test/ReadFiles.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | void testReadGlf();
19 |
--------------------------------------------------------------------------------
/glf/test/Validate.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "Validate.h"
19 | #include
20 |
21 | //const std::string GLF_HEADER_TEXT = "";
22 |
23 | void validateRead1(GlfRecord& glfRecord)
24 | {
25 | //////////////////////////////////////////
26 | // Validate Record 1
27 | // Create record structure for validating.
28 | }
29 |
30 |
31 | void validateHeader(GlfHeader& glfHeader)
32 | {
33 | ////////////////////////////////////////////////////////
34 | // Get the text from the header and verify it is the expected value.
35 | std::string textString = "DUMMY";
36 | assert(glfHeader.getHeaderTextString(textString));
37 | assert(textString == GLF_HEADER_TEXT);
38 | }
39 |
--------------------------------------------------------------------------------
/glf/test/Validate.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "GlfFile.h"
19 |
20 | void validateRead1(GlfRecord& glfRecord);
21 |
22 | void validateHeader(GlfHeader& glfHeader);
23 |
24 | const std::string GLF_HEADER_TEXT = "";
25 |
--------------------------------------------------------------------------------
/glf/test/results/.gitignore:
--------------------------------------------------------------------------------
1 | MyTestOut*
--------------------------------------------------------------------------------
/glf/test/testFiles/testGlf.glf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/glf/test/testFiles/testGlf.glf
--------------------------------------------------------------------------------
/include/.gitignore:
--------------------------------------------------------------------------------
1 | *.h
--------------------------------------------------------------------------------
/samtools/COPYING:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2008-2009 Genome Research Ltd.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/samtools/Makefile:
--------------------------------------------------------------------------------
1 | TOOLBASE = bgzf knetfile
2 | HDRONLY = khash.h bam.h
3 |
4 | include ../Makefiles/Makefile.lib
--------------------------------------------------------------------------------
/samtools/Makefile.depends:
--------------------------------------------------------------------------------
1 | # DO NOT DELETE
2 |
--------------------------------------------------------------------------------
/samtools/README.txt:
--------------------------------------------------------------------------------
1 | These files are based on samtools version 981. (retrieved 7/26/11)
2 |
--------------------------------------------------------------------------------
/samtools/knetfile.h:
--------------------------------------------------------------------------------
1 | #ifndef KNETFILE_H
2 | #define KNETFILE_H
3 |
4 | #include
5 | #include
6 |
7 | #ifndef _WIN32
8 | #define netread(fd, ptr, len) read(fd, ptr, len)
9 | #define netwrite(fd, ptr, len) write(fd, ptr, len)
10 | #define netclose(fd) close(fd)
11 | #else
12 | #include
13 | #define netread(fd, ptr, len) recv(fd, ptr, len, 0)
14 | #define netwrite(fd, ptr, len) send(fd, ptr, len, 0)
15 | #define netclose(fd) closesocket(fd)
16 | #endif
17 |
18 | // FIXME: currently I/O is unbuffered
19 |
20 | #define KNF_TYPE_LOCAL 1
21 | #define KNF_TYPE_FTP 2
22 | #define KNF_TYPE_HTTP 3
23 |
24 | typedef struct knetFile_s {
25 | int type, fd;
26 | int64_t offset;
27 | char *host, *port;
28 |
29 | // the following are for FTP only
30 | int ctrl_fd, pasv_ip[4], pasv_port, max_response, no_reconnect, is_ready;
31 | char *response, *retr, *size_cmd;
32 | int64_t seek_offset; // for lazy seek
33 | int64_t file_size;
34 |
35 | // the following are for HTTP only
36 | char *path, *http_host;
37 | } knetFile;
38 |
39 | #define knet_tell(fp) ((fp)->offset)
40 | #define knet_fileno(fp) ((fp)->fd)
41 |
42 | #ifdef __cplusplus
43 | extern "C" {
44 | #endif
45 |
46 | #ifdef _WIN32
47 | int knet_win32_init();
48 | void knet_win32_destroy();
49 | #endif
50 |
51 | // Pass in non-zero to make knetfile silent (no messages), pass in
52 | // 0 to keep any messages (default is 0).
53 | void knet_silent(int silent);
54 |
55 | knetFile *knet_open(const char *fn, const char *mode);
56 |
57 | /*
58 | This only works with local files.
59 | */
60 | knetFile *knet_dopen(int fd, const char *mode);
61 |
62 | /*
63 | If ->is_ready==0, this routine updates ->fd; otherwise, it simply
64 | reads from ->fd.
65 | */
66 | ssize_t knet_read(knetFile *fp, void *buf, size_t len);
67 |
68 | /*
69 | This routine only sets ->offset and ->is_ready=0. It does not
70 | communicate with the FTP server.
71 | */
72 | off_t knet_seek(knetFile *fp, off_t off, int whence);
73 | int knet_close(knetFile *fp);
74 |
75 | #ifdef __cplusplus
76 | }
77 | #endif
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------
/vcf/Makefile:
--------------------------------------------------------------------------------
1 | TOOLBASE = VcfFile VcfFileReader VcfFileWriter VcfGenotypeField VcfGenotypeFormat VcfGenotypeSample VcfHeader VcfHelper VcfRecord VcfRecordField VcfRecordFilter VcfRecordGenotype VcfRecordInfo VcfSubsetSamples VcfRecordDiscardRules
2 | HDRONLY =
3 |
4 | include ../Makefiles/Makefile.lib
5 |
--------------------------------------------------------------------------------
/vcf/VcfHelper.cpp:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * Copyright (C) 2011 Regents of the University of Michigan,
4 | * Hyun Min Kang, Matthew Flickenger, Matthew Snyder,
5 | * and Goncalo Abecasis
6 | *
7 | * This program is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program. If not, see .
19 | */
20 |
21 | #include "VcfHelper.h"
22 |
23 | void VcfHelper::parseString(const std::string& inputString,
24 | char delim,
25 | ReusableVector& outputVector)
26 | {
27 | if(inputString.empty())
28 | {
29 | // Nothing to parse, so just return.
30 | return;
31 | }
32 | std::string* outputStringPtr = &(outputVector.getNextEmpty());
33 | for(unsigned int i = 0; i < inputString.size(); i++)
34 | {
35 | if(inputString[i] == delim)
36 | {
37 | // Get a new string to write into and continue
38 | // to the next character.
39 | outputStringPtr = &(outputVector.getNextEmpty());
40 | }
41 | else
42 | {
43 | // Append the character.
44 | outputStringPtr->push_back(inputString[i]);
45 | }
46 | }
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/vcf/VcfHelper.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Regents of the University of Michigan,
3 | * Hyun Min Kang, Matthew Flickenger, Matthew Snyder,
4 | * and Goncalo Abecasis
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 |
20 |
21 | #ifndef __VCF_HELPER_H__
22 | #define __VCF_HELPER_H__
23 |
24 | #include
25 | #include "ReusableVector.h"
26 |
27 | /// This header file provides helper methods for dealing with VCF Files.
28 | class VcfHelper
29 | {
30 | public:
31 | /// Parse the string at the specified delimiters into
32 | /// the specified reusable vector.
33 | static void parseString(const std::string& inputString,
34 | char delim,
35 | ReusableVector& outputVector);
36 | };
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/vcf/VcfRecordField.cpp:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * Copyright (C) 2011 Regents of the University of Michigan,
4 | * Hyun Min Kang, Matthew Flickenger, Matthew Snyder,
5 | * and Goncalo Abecasis
6 | *
7 | * This program is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program. If not, see .
19 | */
20 | #include "VcfRecordField.h"
21 |
--------------------------------------------------------------------------------
/vcf/VcfRecordField.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Regents of the University of Michigan,
3 | * Hyun Min Kang, Matthew Flickenger, Matthew Snyder,
4 | * and Goncalo Abecasis
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 |
20 |
21 | #ifndef __VCF_RECORD_FIELD_H__
22 | #define __VCF_RECORD_FIELD_H__
23 |
24 | #include "InputFile.h"
25 |
26 | /// This header file provides interface to read/write VCF files.
27 | class VcfRecordField
28 | {
29 | public:
30 | /// Default Constructor, initializes the variables.
31 | VcfRecordField() {}
32 | /// Destructor
33 | virtual ~VcfRecordField() {}
34 |
35 | /// Read this field from the file up until the next \t,\n, or EOF.
36 | /// Reads the \t, \n, or EOF.
37 | /// \param filePtr IFILE to read from.
38 | /// \return true if the field was successfully read from the specified
39 | /// filePtr, false if not.
40 | virtual bool read(IFILE filePtr) = 0;
41 |
42 | /// Write this field to the file, without printing the
43 | // starting/trailing '\t'.
44 | /// \return true if the field was successfully written to the specified
45 | /// filePtr, false if not.
46 | virtual bool write(IFILE filePtr) = 0;
47 |
48 | protected:
49 |
50 | private:
51 | VcfRecordField(const VcfRecordField& field);
52 | VcfRecordField& operator=(const VcfRecordField& field);
53 | };
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/vcf/test/.gitignore:
--------------------------------------------------------------------------------
1 | vcfTest
2 |
--------------------------------------------------------------------------------
/vcf/test/Main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "VcfFileTest.h"
19 | #include "VcfHeaderTest.h"
20 |
21 |
22 | int main(int argc, char ** argv)
23 | {
24 | testVcfHeader();
25 | testVcfFile();
26 | }
27 |
--------------------------------------------------------------------------------
/vcf/test/Makefile:
--------------------------------------------------------------------------------
1 | EXE = vcfTest
2 | TOOLBASE = VcfFileTest VcfHeaderTest
3 | SRCONLY = Main.cpp
4 | TEST_COMMAND = ./vcfTest && diff results/vcfHeader.vcf expected/vcfHeader.vcf && diff results/vcfHeaderAddedFirst.vcf expected/vcfHeader.vcf && diff results/vcfHeaderAddedLast.vcf expected/vcfHeader.vcf && diff results/vcfHeaderAddedMiddle.vcf expected/vcfHeader.vcf && diff results/vcfFile.vcf testFiles/vcfFile.vcf && diff results/vcfFileNoInfo.vcf expected/vcfFileNoInfo.vcf && diff results/vcfFileNoInfoBGZF.vcf expected/vcfFileNoInfoBGZF.vcf && diff results/vcfFileNoInfoKeepGT.vcf expected/vcfFileNoInfoKeepGT.vcf && diff results/vcfFileNoInfoKeepGQHQ.vcf expected/vcfFileNoInfoKeepGQHQ.vcf
5 |
6 | include ../../Makefiles/Makefile.test
--------------------------------------------------------------------------------
/vcf/test/VcfFileTest.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011-2013 Regents of the University of Michigan
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | void testVcfFile();
19 | void testVcfReadFile();
20 | void testVcfWriteFile();
21 | void testVcfReadSection();
22 | void testVcfReadSectionNoIndex();
23 | void testVcfReadSectionBadIndex();
24 |
--------------------------------------------------------------------------------
/vcf/test/expected/vcfFileNoInfo.vcf:
--------------------------------------------------------------------------------
1 | ##fileformat=VCFv4.1
2 | ##fileDate=20090805
3 | ##source=myImputationProgramV3.1
4 | ##reference=file:///seq/references/1000GenomesPilot-NCBI36.fasta
5 | ##contig=
6 | ##phasing=partial
7 | ##INFO=
8 | ##INFO=
9 | ##INFO=
10 | ##INFO=
11 | ##INFO=
12 | ##INFO=
13 | ##FILTER=
14 | ##FILTER=
15 | ##FORMAT=
16 | ##FORMAT=
17 | ##FORMAT=
18 | ##FORMAT=
19 | #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT NA00001 NA00002 NA00003
20 | 20 14370 rs6054257 G A 29 PASS . GT:GQ:DP:HQ 0|0:48:1:51,51 1|0:48:8:51,51 1/1:43:5:.,.
21 | 20 17330 . T A 3 q10 . GT:GQ:DP:HQ 0/0:49:3:58,50 0|1:3:5:65,3 0/0:41:3:.,.
22 | 20 1110696 rs6040355 A G,T 67 PASS . GT:GQ:DP:HQ 1|2:21:6:23,27 2|1:2:0:18,2 2/2:35:4:65,3
23 | 20 1230237 . T . 47 PASS . GT:GQ:DP:HQ 0|0:54:7:56,60 0|0:48:4:51,51 0/0:61:2:65,3
24 | 20 1234567 microsat1 GTC G,GTCT 50 PASS . GT 0/1 0/2 1/1
25 | 20 1234568 microsat1 GTC G,GTCT 50 PASS . GQ:DP 35:4 17:2 40:3
26 | 20 1234569 microsat1 GTC G 50 PASS . GT:GQ:DP 0|1:35:4 0|. 1|1:40:3
27 |
--------------------------------------------------------------------------------
/vcf/test/expected/vcfFileNoInfoBGZF.vcf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/vcf/test/expected/vcfFileNoInfoBGZF.vcf
--------------------------------------------------------------------------------
/vcf/test/expected/vcfFileNoInfoKeepGQHQ.vcf:
--------------------------------------------------------------------------------
1 | ##fileformat=VCFv4.1
2 | ##fileDate=20090805
3 | ##source=myImputationProgramV3.1
4 | ##reference=file:///seq/references/1000GenomesPilot-NCBI36.fasta
5 | ##contig=
6 | ##phasing=partial
7 | ##INFO=
8 | ##INFO=
9 | ##INFO=
10 | ##INFO=
11 | ##INFO=
12 | ##INFO=
13 | ##FILTER=
14 | ##FILTER=
15 | ##FORMAT=
16 | ##FORMAT=
17 | ##FORMAT=
18 | ##FORMAT=
19 | #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT NA00001 NA00002 NA00003
20 | 20 14370 rs6054257 G A 29 PASS . GQ:HQ 48:51,51 48:51,51 43:.,.
21 | 20 17330 . T A 3 q10 . GQ:HQ 49:58,50 3:65,3 41:.,.
22 | 20 1110696 rs6040355 A G,T 67 PASS . GQ:HQ 21:23,27 2:18,2 35:65,3
23 | 20 1230237 . T . 47 PASS . GQ:HQ 54:56,60 48:51,51 61:65,3
24 | 20 1234567 microsat1 GTC G,GTCT 50 PASS .
25 | 20 1234568 microsat1 GTC G,GTCT 50 PASS . GQ 35 17 40
26 | 20 1234569 microsat1 GTC G 50 PASS . GQ 35 . 40
27 |
--------------------------------------------------------------------------------
/vcf/test/expected/vcfFileNoInfoKeepGT.vcf:
--------------------------------------------------------------------------------
1 | ##fileformat=VCFv4.1
2 | ##fileDate=20090805
3 | ##source=myImputationProgramV3.1
4 | ##reference=file:///seq/references/1000GenomesPilot-NCBI36.fasta
5 | ##contig=
6 | ##phasing=partial
7 | ##INFO=
8 | ##INFO=
9 | ##INFO=
10 | ##INFO=
11 | ##INFO=
12 | ##INFO=
13 | ##FILTER=
14 | ##FILTER=
15 | ##FORMAT=
16 | ##FORMAT=
17 | ##FORMAT=
18 | ##FORMAT=
19 | #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT NA00001 NA00002 NA00003
20 | 20 14370 rs6054257 G A 29 PASS . GT 0|0 1|0 1/1
21 | 20 17330 . T A 3 q10 . GT 0/0 0|1 0/0
22 | 20 1110696 rs6040355 A G,T 67 PASS . GT 1|2 2|1 2/2
23 | 20 1230237 . T . 47 PASS . GT 0|0 0|0 0/0
24 | 20 1234567 microsat1 GTC G,GTCT 50 PASS . GT 0/1 0/2 1/1
25 | 20 1234568 microsat1 GTC G,GTCT 50 PASS .
26 | 20 1234569 microsat1 GTC G 50 PASS . GT 0|1 0|. 1|1
27 |
--------------------------------------------------------------------------------
/vcf/test/expected/vcfHeader.vcf:
--------------------------------------------------------------------------------
1 | ##fileformat=VCFv4.1
2 | ##fileDate=20090805
3 | ##source=myImputationProgramV3.1
4 | ##reference=file:///seq/references/1000GenomesPilot-NCBI36.fasta
5 | ##contig=
6 | ##phasing=partial
7 | ##INFO=
8 | ##INFO=
9 | ##INFO=
10 | ##INFO=
11 | ##INFO=
12 | ##INFO=
13 | ##FILTER=
14 | ##FILTER=
15 | ##FORMAT=
16 | ##FORMAT=
17 | ##FORMAT=
18 | ##FORMAT=
19 | #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT NA00001 NA00002 NA00003
20 |
--------------------------------------------------------------------------------
/vcf/test/results/.gitignore:
--------------------------------------------------------------------------------
1 | *vcf
2 |
--------------------------------------------------------------------------------
/vcf/test/testFiles/exclude2.txt:
--------------------------------------------------------------------------------
1 | NA00002
2 |
--------------------------------------------------------------------------------
/vcf/test/testFiles/excludeIDs.txt:
--------------------------------------------------------------------------------
1 | rs6054257
2 | microsat1
--------------------------------------------------------------------------------
/vcf/test/testFiles/includeIDs.txt:
--------------------------------------------------------------------------------
1 | rs6040355
2 | .
3 |
--------------------------------------------------------------------------------
/vcf/test/testFiles/subset1.txt:
--------------------------------------------------------------------------------
1 | NA00002;NA00001
2 |
--------------------------------------------------------------------------------
/vcf/test/testFiles/subset2.txt:
--------------------------------------------------------------------------------
1 | NA00002
2 | NA00003
3 | NA00100
4 |
--------------------------------------------------------------------------------
/vcf/test/testFiles/testTabix.vcf:
--------------------------------------------------------------------------------
1 | ##fileformat=VCFv4.0
2 | ##filedate=20110211
3 | ##source=glfMultiples
4 | ##minDepth=2526
5 | ##maxDepth=2526000
6 | ##minMapQuality=0
7 | ##minPosterior=0.5000
8 | ##contig=
9 | ##INFO=
10 | ##INFO=
11 | ##INFO=
12 | ##INFO=
13 | ##INFO=
14 | ##INFO=
15 | ##INFO=
16 | ##FILTER=
17 | ##FILTER=
18 | ##FORMAT=
19 | ##FORMAT=
20 | ##FORMAT=
21 | ##FORMAT=
22 | ##FORMAT=
23 | #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT P1 P2 P3 P4 P5 P6
24 | 1 32768 r1 A G 100 PASS . GT:DP:GQ:GL 0/1:0:5:0,0,0 1/0:0:5:0,0,0 0/0:0:5:0,0,0 0/1:1:7:19,3,0 0/0:2:11:0,6,22 0/1:1:5:12,3,0
25 | 1 65537 r2 T G 100 PASS . GT:DP:GQ:GL 0/0:0:13:0,0,0 0/0:38:100:0,114,226 0/1:1:16:0,3,20 0/0:39:100:0,117,255 0/0:35:100:0,102,255 0/0:29:100:0,87,255
26 | 3 32768 r1 GAA G 100 PASS . GT:DP:GQ:GL 0/1:0:5:0,0,0 1/0:0:5:0,0,0 0/0:0:5:0,0,0 0/1:1:7:19,3,0 0/0:2:11:0,6,22 0/1:1:5:12,3,0
27 | 3 32780 r2 T G 100 PASS . GT:DP:GQ:GL 0/0:0:13:0,0,0 0/0:38:100:0,114,226 0/1:1:16:0,3,20 0/0:39:100:0,117,255 0/0:35:100:0,102,255 0/0:29:100:0,87,255
28 |
--------------------------------------------------------------------------------
/vcf/test/testFiles/testTabix.vcf.bgzf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/vcf/test/testFiles/testTabix.vcf.bgzf
--------------------------------------------------------------------------------
/vcf/test/testFiles/testTabix.vcf.bgzf.tbi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/vcf/test/testFiles/testTabix.vcf.bgzf.tbi
--------------------------------------------------------------------------------
/vcf/test/testFiles/testTabixBadIndex.vcf.bgzf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/vcf/test/testFiles/testTabixBadIndex.vcf.bgzf
--------------------------------------------------------------------------------
/vcf/test/testFiles/testTabixBadIndex.vcf.bgzf.tbi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/statgen/libStatGen/fae4fca874b3b78bf9b61c0eae080c15edd976a4/vcf/test/testFiles/testTabixBadIndex.vcf.bgzf.tbi
--------------------------------------------------------------------------------
/vcf/test/testFiles/vcfFile.vcf:
--------------------------------------------------------------------------------
1 | ##fileformat=VCFv4.1
2 | ##fileDate=20090805
3 | ##source=myImputationProgramV3.1
4 | ##reference=file:///seq/references/1000GenomesPilot-NCBI36.fasta
5 | ##contig=
6 | ##phasing=partial
7 | ##INFO=
8 | ##INFO=
9 | ##INFO=
10 | ##INFO=
11 | ##INFO=
12 | ##INFO=
13 | ##FILTER=
14 | ##FILTER=
15 | ##FORMAT=
16 | ##FORMAT=
17 | ##FORMAT=
18 | ##FORMAT=
19 | #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT NA00001 NA00002 NA00003
20 | 20 14370 rs6054257 G A 29 PASS NS=3;DP=14;AF=0.5;DB;H2 GT:GQ:DP:HQ 0|0:48:1:51,51 1|0:48:8:51,51 1/1:43:5:.,.
21 | 20 17330 . T A 3 q10 NS=3;DP=11;AF=0.017 GT:GQ:DP:HQ 0/0:49:3:58,50 0|1:3:5:65,3 0/0:41:3:.,.
22 | 20 1110696 rs6040355 A G,T 67 PASS NS=2;DP=10;AF=0.333,0.667;AA=T;DB GT:GQ:DP:HQ 1|2:21:6:23,27 2|1:2:0:18,2 2/2:35:4:65,3
23 | 20 1230237 . T . 47 PASS NS=3;DP=13;AA=T GT:GQ:DP:HQ 0|0:54:7:56,60 0|0:48:4:51,51 0/0:61:2:65,3
24 | 20 1234567 microsat1 GTC G,GTCT 50 PASS NS=3;DP=9;AA=G GT 0/1 0/2 1/1
25 | 20 1234568 microsat1 GTC G,GTCT 50 PASS . GQ:DP 35:4 17:2 40:3
26 | 20 1234569 microsat1 GTC G 50 PASS NS=3;DP=9;AA=G GT:GQ:DP 0|1:35:4 0|. 1|1:40:3
27 |
--------------------------------------------------------------------------------