diff --git a/Makefile b/Makefile index 35fa6bb6811f4588d283d36ee32a4e57b5d14d12..5493351ffd79472ee3536a8c0cca1118e8402ff3 100644 --- a/Makefile +++ b/Makefile @@ -61,6 +61,19 @@ UTIL_SUBDIRS = $(SRC_DIR)/utils/lineFileUtilities \ $(SRC_DIR)/utils/genomeFile BUILT_OBJECTS = $(OBJ_DIR)/*.o +# BUILT_OBJECTS = $(OBJ_DIR)/bedtools.o \ +# $(OBJ_DIR)/BamAncillary.o \ +# $(OBJ_DIR)/Fasta.o \ +# $(OBJ_DIR)/bedFile.o \ +# $(OBJ_DIR)/bedFilePE.o \ +# $(OBJ_DIR)/bedGraphFile.o \ +# $(OBJ_DIR)/chromsweep.o \ +# $(OBJ_DIR)/fileType.o \ +# $(OBJ_DIR)/gzstream.o \ +# $(OBJ_DIR)/sequenceUtils.o \ +# $(OBJ_DIR)/split.o \ +# $(OBJ_DIR)/intersectBed.o \ +# $(OBJ_DIR)/intersectMain.o \ all: [ -d $(OBJ_DIR) ] || mkdir -p $(OBJ_DIR) @@ -82,6 +95,7 @@ all: done @echo "- Building main bedtools binary." + gcc $(CXXFLAGS) -c src/bedtools.cpp -o obj/bedtools.o @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/bedtools $(BUILT_OBJECTS) -L$(UTIL_DIR)/BamTools/lib/ -lbamtools $(LIBS) diff --git a/src/annotateBed/Makefile b/src/annotateBed/Makefile index 6eb7f8cdc543c5ef5377031e5d3af1265593ed08..23bad93dc1a29a23adef5230d60aa257076bb3d3 100644 --- a/src/annotateBed/Makefile +++ b/src/annotateBed/Makefile @@ -18,14 +18,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= annotateBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/annotateBed/annotateMain.cpp b/src/annotateBed/annotateMain.cpp index 07b2f198864ec187a16ffa35c1a7dc2967a69b0d..8ae9e98cdc2ece98023326a7319ecee5c2c1bea0 100644 --- a/src/annotateBed/annotateMain.cpp +++ b/src/annotateBed/annotateMain.cpp @@ -15,15 +15,15 @@ using namespace std; // define the version -#define PROGRAM_NAME "annotateBed" +#define PROGRAM_NAME "bedtools annotate" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void annotate_help(void); -int main(int argc, char* argv[]) { +int annotate_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -56,7 +56,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) annotate_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -133,20 +133,18 @@ int main(int argc, char* argv[]) { return 0; } else { - ShowHelp(); + annotate_help(); + return 0; } } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void annotate_help(void) { - cerr << "Summary: Annotates the depth & breadth of coverage of features from multiple files" << endl; + cerr << "\nTool: bedtools annotate (aka annotateBed)" << endl; + cerr << "Summary: Annotates the depth & breadth of coverage of features from mult. files" << endl; cerr << "\t on the intervals in -i." << endl << endl; - cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -i <bed/gff/vcf> -files FILE1 FILE2 .. FILEn" << endl << endl; + cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -i <bed/gff/vcf> -files FILE1 FILE2..FILEn" << endl << endl; cerr << "Options: " << endl; diff --git a/src/bamToBed/Makefile b/src/bamToBed/Makefile index 65741ae8f4e4e5bef22438b5b2f45746e22ab5fa..5cf20cd2433cd4388f15944feb5af55ab19f5224 100644 --- a/src/bamToBed/Makefile +++ b/src/bamToBed/Makefile @@ -25,14 +25,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= bamToBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ -L$(UTILITIES_DIR)/BamTools/lib/ -lbamtools $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/bamToBed/bamToBed.cpp b/src/bamToBed/bamToBed.cpp index 4a4c56c662a5d953191698534e74185808326baf..bcae2c7a1eddac02d747a092f35a2dd2dcb1a35d 100644 --- a/src/bamToBed/bamToBed.cpp +++ b/src/bamToBed/bamToBed.cpp @@ -26,14 +26,14 @@ using namespace std; // define our program name -#define PROGRAM_NAME "bamToBed" +#define PROGRAM_NAME "bedtools bamtobed" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void bamtobed_help(void); void ConvertBamToBed(const string &bamFile, bool useEditDistance, const string &bamTag, bool writeBed12, bool obeySplits, const string &color, @@ -52,10 +52,10 @@ void ParseCigarBed12(const vector<CigarOp> &cigar, vector<int> &blockStarts, vector<int> &blockEnds, int &alignmentEnd); string BuildCigarString(const vector<CigarOp> &cigar); -bool IsCorrectMappingForBEDPE (const BamAlignment &bam); +bool bamtobed_IsCorrectMappingForBEDPE (const BamAlignment &bam); -int main(int argc, char* argv[]) { +int bamtobed_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -88,7 +88,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) bamtobed_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -178,16 +178,15 @@ int main(int argc, char* argv[]) { ConvertBamToBedpe(bamFile, useEditDistance); // BEDPE } else { - ShowHelp(); + bamtobed_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void bamtobed_help(void) { + + cerr << "\nTool: bedtools bamtobed (aka bamToBed)" << endl; cerr << "Summary: Converts BAM alignments to BED6 or BEDPE format." << endl << endl; @@ -605,7 +604,7 @@ void PrintBedPE(const BamAlignment &bam1, const BamAlignment &bam2, const RefVec // deprecated. -bool IsCorrectMappingForBEDPE (const BamAlignment &bam) { +bool bamtobed_IsCorrectMappingForBEDPE (const BamAlignment &bam) { if ( (bam.RefID == bam.MateRefID) && (bam.InsertSize > 0) ) { return true; diff --git a/src/bed12ToBed6/Makefile b/src/bed12ToBed6/Makefile index e2e1288341db4dac6b027061d9815b3b35bf9b80..fd6fac5e51183c52f8a9d31406232042f8058fc6 100644 --- a/src/bed12ToBed6/Makefile +++ b/src/bed12ToBed6/Makefile @@ -18,15 +18,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= bed12ToBed6 -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all - -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/bed12ToBed6/bed12ToBed6.cpp b/src/bed12ToBed6/bed12ToBed6.cpp index d6aae22adb5e3166f5018036de178c4283fbb38e..fc1884e931cdaad92ed53ebf320b6f3ebae42298 100644 --- a/src/bed12ToBed6/bed12ToBed6.cpp +++ b/src/bed12ToBed6/bed12ToBed6.cpp @@ -22,21 +22,21 @@ using namespace std; // define our program name -#define PROGRAM_NAME "bed12ToBed6" +#define PROGRAM_NAME "bedtools bed12tobed6" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void bed12tobed6_help(void); void DetermineBedInput(BedFile *bed); void ProcessBed(istream &bedInput, BedFile *bed); bool addBlockNums = false; -int main(int argc, char* argv[]) { +int bed12tobed6_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -54,7 +54,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) bed12tobed6_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -88,17 +88,16 @@ int main(int argc, char* argv[]) { DetermineBedInput(bed); } else { - ShowHelp(); + bed12tobed6_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void bed12tobed6_help(void) { + cerr << "\nTool: bedtools bed12tobed6 (aka bed12ToBed6)" << endl; + cerr << "Summary: Splits BED12 features into discrete BED6 features." << endl << endl; cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -i <bed12>" << endl << endl; diff --git a/src/bedToBam/Makefile b/src/bedToBam/Makefile index f6e18c0c1df051d8b33d214db1cbdf8d5ef389aa..0666e314475bd1a63060f704e3338932ac7e62f3 100644 --- a/src/bedToBam/Makefile +++ b/src/bedToBam/Makefile @@ -25,15 +25,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= bedToBam -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all - -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ -L$(UTILITIES_DIR)/BamTools/lib/ -lbamtools $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/bedToBam/bedToBam.cpp b/src/bedToBam/bedToBam.cpp index a689533cb1322ed1d571243dde87e25c2f0e09f0..2334622656717cfefa9792cd4d2131ac2312aca0 100644 --- a/src/bedToBam/bedToBam.cpp +++ b/src/bedToBam/bedToBam.cpp @@ -29,22 +29,22 @@ using namespace std; // define our program name -#define PROGRAM_NAME "bedToBam" +#define PROGRAM_NAME "bedtools bedtobam" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void bedtobam_help(void); void ProcessBed(BedFile *bed, GenomeFile *genome, bool isBED12, int mapQual, bool uncompressedBam); void ConvertBedToBam(const BED &bed, BamAlignment &bam, map<string, int> &chromToId, bool isBED12, int mapQual, int lineNum); void MakeBamHeader(const string &genomeFile, RefVector &refs, string &header, map<string, int> &chromToInt); -int reg2bin(int beg, int end); +int bedtobam_reg2bin(int beg, int end); -int main(int argc, char* argv[]) { +int bedtobam_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -70,7 +70,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) bedtobam_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -131,16 +131,15 @@ int main(int argc, char* argv[]) { ProcessBed(bed, genome, isBED12, mapQual, uncompressedBam); } else { - ShowHelp(); + bedtobam_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void bedtobam_help(void) { + + cerr << "\nTool: bedtools bedtobam (aka bedToBam)" << endl; cerr << "Summary: Converts feature records to BAM format." << endl << endl; @@ -154,10 +153,10 @@ void ShowHelp(void) { cerr << "\t-bed12\t" << "The BED file is in BED12 format. The BAM CIGAR" << endl; cerr << "\t\tstring will reflect BED \"blocks\"." << endl << endl; - cerr << "\t-ubam\t" << "Write uncompressed BAM output. Default is to write compressed BAM." << endl << endl; + cerr << "\t-ubam\t" << "Write uncompressed BAM output. Default writes compressed BAM." << endl << endl; cerr << "Notes: " << endl; - cerr << "\t(1) BED files must be at least BED4 to be amenable to BAM (needs name field)." << endl << endl; + cerr << "\t(1) BED files must be at least BED4 to create BAM (needs name field)." << endl << endl; // end the program here @@ -211,7 +210,7 @@ void ConvertBedToBam(const BED &bed, BamAlignment &bam, map<string, int, std::le bam.Name = bed.name; bam.Position = bed.start; - bam.Bin = reg2bin(bed.start, bed.end); + bam.Bin = bedtobam_reg2bin(bed.start, bed.end); // hard-code the sequence and qualities. int bedLength = bed.end - bed.start; @@ -341,7 +340,7 @@ void MakeBamHeader(const string &genomeFile, RefVector &refs, string &header, /* Taken directly from the SAMTools spec calculate bin given an alignment in [beg,end) (zero-based, half-close, half-open) */ -int reg2bin(int beg, int end) { +int bedtobam_reg2bin(int beg, int end) { --end; if (beg>>14 == end>>14) return ((1<<15)-1)/7 + (beg>>14); if (beg>>17 == end>>17) return ((1<<12)-1)/7 + (beg>>17); diff --git a/src/bedToIgv/Makefile b/src/bedToIgv/Makefile index 3ad616b9c5019e9de5699753067ef2b5105c8ea8..50ea2daebf58d5e0b6f7229cd2dc4071e5830941 100644 --- a/src/bedToIgv/Makefile +++ b/src/bedToIgv/Makefile @@ -24,15 +24,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= bedToIgv -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all - -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/bedToIgv/bedToIgv.cpp b/src/bedToIgv/bedToIgv.cpp index 9697d8085301235fb08c83e06a1fa7933787cff8..562062d31d41331987ffdaade75521ccae848c23 100644 --- a/src/bedToIgv/bedToIgv.cpp +++ b/src/bedToIgv/bedToIgv.cpp @@ -22,13 +22,13 @@ using namespace std; // define our program name -#define PROGRAM_NAME "bedToIgv" +#define PROGRAM_NAME "bedtools igv" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void bedtoigv_help(void); void DetermineBedInput(BedFile *bed, string path, string sortType, string session, bool collapse, bool useNames, string imageType, int slop); @@ -36,7 +36,7 @@ void ProcessBed(istream &bedInput, BedFile *bed, string path, string sortType, s bool collapse, bool useNames, string imageType, int slop); -int main(int argc, char* argv[]) { +int bedtoigv_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -62,7 +62,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) bedtoigv_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -139,16 +139,15 @@ int main(int argc, char* argv[]) { DetermineBedInput(bed, imagePath, sortType, session, collapse, useNames, imageType, slop); } else { - ShowHelp(); + bedtoigv_help(); } + return 0; } -void ShowHelp(void) { +void bedtoigv_help(void) { - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; + cerr << "\nTool: bedtools igv (aka bedToIgv)" << endl; cerr << "Summary: Creates a batch script to create IGV images " << endl; cerr << " at each interval defined in a BED/GFF/VCF file." << endl << endl; @@ -182,9 +181,9 @@ void ShowHelp(void) { cerr << "\t\tDefault is png." << endl << endl; cerr << "Notes: " << endl; - cerr << "\t(1) The resulting script is meant to be run from within the IGV GUI version 1.5 or later." << endl; - cerr << "\t(2) Unless you use the -sess option, it is assumed that prior to running the script, " << endl; - cerr << "\t\tyou have loaded the proper genome, tracks and data files." << endl << endl; + cerr << "\t(1) The resulting script is meant to be run from within IGV." << endl; + cerr << "\t(2) Unless you use the -sess option, it is assumed that prior to " << endl; + cerr << "\t\trunning the script, you've loaded the proper genome and tracks." << endl << endl; // end the program here diff --git a/src/bedpeToBam/Makefile b/src/bedpeToBam/Makefile index b2f7d128400b9f8354d2dc5b394c3ffe424cd5ff..592d68e6de7547d6d8fcfbde28abae08052ab4b3 100644 --- a/src/bedpeToBam/Makefile +++ b/src/bedpeToBam/Makefile @@ -26,15 +26,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= bedpeToBam -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all - -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ -L$(UTILITIES_DIR)/BamTools/lib/ -lbamtools $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/bedpeToBam/bedpeToBam.cpp b/src/bedpeToBam/bedpeToBam.cpp index 06e9af88453664534b241347c5e8f39811bfe548..374e3fa91829245e9c9a4c9b7dd8efb70a2d04a8 100644 --- a/src/bedpeToBam/bedpeToBam.cpp +++ b/src/bedpeToBam/bedpeToBam.cpp @@ -29,27 +29,23 @@ using namespace std; // define our program name -#define PROGRAM_NAME "bedpeToBam" +#define PROGRAM_NAME "bedpetobam" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) -//ROYDEN -//NEED TO ADD A IS TYPE12+ check or fail -//END ROYDEN - // function declarations -void ShowHelp(void); +void bedpetobam_help(void); void ProcessBedPE(BedFilePE *bedpe, GenomeFile *genome, int mapQual, bool uncompressedBam); void ConvertBedPEToBam(const BEDPE &bedpe, BamAlignment &bam1,BamAlignment &bam2, map<string, int> &chromToId, int mapQual, int lineNum); -void MakeBamHeader(const string &genomeFile, RefVector &refs, string &header, map<string, int> &chromToInt); -int reg2bin(int beg, int end); +void bedpetobam_MakeBamHeader(const string &genomeFile, RefVector &refs, string &header, map<string, int> &chromToInt); +int bedpetobam_reg2bin(int beg, int end); -int main(int argc, char* argv[]) { +int bedpetobam_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -75,7 +71,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) bedpetobam_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -133,16 +129,15 @@ int main(int argc, char* argv[]) { ProcessBedPE(bedpe, genome, mapQual, uncompressedBam); } else { - ShowHelp(); + bedpetobam_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void bedpetobam_help(void) { + + cerr << "\nTool: bedtools bedpetobam (aka bedpeToBam)" << endl; cerr << "Summary: Converts feature records to BAM format." << endl << endl; @@ -153,10 +148,10 @@ void ShowHelp(void) { cerr << "\t-mapq\t" << "Set the mappinq quality for the BAM records." << endl; cerr << "\t\t(INT) Default: 255" << endl << endl; - cerr << "\t-ubam\t" << "Write uncompressed BAM output. Default is to write compressed BAM." << endl << endl; + cerr << "\t-ubam\t" << "Write uncompressed BAM output. Default writes compressed BAM." << endl << endl; cerr << "Notes: " << endl; - cerr << "\t(1) BED files must be at least BED4 to be amenable to BAM (needs name field)." << endl << endl; + cerr << "\t(1) BED files must be at least BED4 to create BAM (needs name field)." << endl << endl; // end the program here @@ -171,7 +166,7 @@ void ProcessBedPE(BedFilePE *bedpe, GenomeFile *genome, int mapQual, bool uncom RefVector refs; string bamHeader; map<string, int, std::less<string> > chromToId; - MakeBamHeader(genome->getGenomeFileName(), refs, bamHeader, chromToId); + bedpetobam_MakeBamHeader(genome->getGenomeFileName(), refs, bamHeader, chromToId); // set compression mode BamWriter::CompressionMode compressionMode = BamWriter::Compressed; @@ -218,10 +213,10 @@ void ConvertBedPEToBam(const BEDPE &bedpe, BamAlignment &bam1,BamAlignment &bam2 bam1.Name = bedpe.name; bam1.Position = bedpe.start1; - bam1.Bin = reg2bin(bedpe.start1, bedpe.end1); + bam1.Bin = bedpetobam_reg2bin(bedpe.start1, bedpe.end1); bam2.Name = bedpe.name; bam2.Position = bedpe.start2; - bam2.Bin = reg2bin(bedpe.start2, bedpe.end2); + bam2.Bin = bedpetobam_reg2bin(bedpe.start2, bedpe.end2); // hard-code the sequence and qualities. int bedpeLength1 = bedpe.end1 - bedpe.start1; @@ -294,7 +289,7 @@ void ConvertBedPEToBam(const BEDPE &bedpe, BamAlignment &bam1,BamAlignment &bam2 } -void MakeBamHeader(const string &genomeFile, RefVector &refs, string &header, +void bedpetobam_MakeBamHeader(const string &genomeFile, RefVector &refs, string &header, map<string, int, std::less<string> > &chromToId) { // make a genome map of the genome file. @@ -333,7 +328,7 @@ void MakeBamHeader(const string &genomeFile, RefVector &refs, string &header, /* Taken directly from the SAMTools spec calculate bin given an alignment in [beg,end) (zero-based, half-close, half-open) */ -int reg2bin(int beg, int end) { +int bedpetobam_reg2bin(int beg, int end) { --end; if (beg>>14 == end>>14) return ((1<<15)-1)/7 + (beg>>14); if (beg>>17 == end>>17) return ((1<<12)-1)/7 + (beg>>17); diff --git a/src/bedpeToBam/notes.txt b/src/bedpeToBam/notes.txt new file mode 100644 index 0000000000000000000000000000000000000000..b7c406467c80a19c87eb2d5f54bab48424b398cf --- /dev/null +++ b/src/bedpeToBam/notes.txt @@ -0,0 +1,44 @@ +Public Member Functions BamAlignment (void) constructor BamAlignment (const BamAlignment &other) copy constructor ~BamAlignment (void) destructor +bool IsDuplicate (void) const +bool IsFailedQC (void) const +bool IsFirstMate (void) const +bool IsMapped (void) const +bool IsMateMapped (void) const +bool IsMateReverseStrand (void) const +bool IsPaired (void) const +bool IsPrimaryAlignment (void) const +bool IsProperPair (void) const +bool IsReverseStrand (void) const +bool IsSecondMate (void) const +void SetIsDuplicate (bool ok) Sets value of "PCR duplicate" flag to ok. +void SetIsFailedQC (bool ok) Sets "failed quality control" flag to ok. +void SetIsFirstMate (bool ok) Sets "alignment is first mate" flag to ok. +void SetIsMapped (bool ok) Sets "alignment is mapped" flag to ok. +void SetIsMateMapped (bool ok) Sets "alignment's mate is mapped" flag to ok. +void SetIsMateReverseStrand (bool ok) Sets "alignment's mate mapped to reverse strand" flag to ok. +void SetIsPaired (bool ok) Sets "alignment part of paired-end read" flag to ok. +void SetIsPrimaryAlignment (bool ok) Sets "position is primary alignment" flag to ok. +void SetIsProperPair (bool ok) Sets "alignment is part of read that satisfied paired-end resolution" flag to ok. +void SetIsReverseStrand (bool ok) Sets "alignment mapped to reverse strand" flag to ok. +void SetIsSecondMate (bool ok) Sets "alignment is second mate on read" flag to ok. +void SetIsMateUnmapped (bool ok) Complement of using SetIsMateMapped(). +void SetIsSecondaryAlignment (bool ok) Complement of using SetIsPrimaryAlignment(). +void SetIsUnmapped (bool ok) Complement of using SetIsMapped(). +bool AddTag (const std::string &tag, const std::string &type, const std::string &value) Adds a field with string data to the BAM tags. +bool AddTag (const std::string &tag, const std::string &type, const uint32_t &value) Adds a field with unsigned integer data to the BAM tags. +bool AddTag (const std::string &tag, const std::string &type, const int32_t &value) Adds a field with signed integer data to the BAM tags. +bool AddTag (const std::string &tag, const std::string &type, const float &value) Adds a field with floating-point data to the BAM tags. +bool EditTag (const std::string &tag, const std::string &type, const std::string &value) Edits a BAM tag field containing string data. +bool EditTag (const std::string &tag, const std::string &type, const uint32_t &value) Edits a BAM tag field containing unsigned integer data. +bool EditTag (const std::string &tag, const std::string &type, const int32_t &value) Edits a BAM tag field containing signed integer data. +bool EditTag (const std::string &tag, const std::string &type, const float &value) Edits a BAM tag field containing floating-point data. +bool GetTag (const std::string &tag, std::string &destination) const Retrieves the string value associated with a BAM tag. +bool GetTag (const std::string &tag, uint32_t &destination) const Retrieves the unsigned integer value associated with a BAM tag. +bool GetTag (const std::string &tag, int32_t &destination) const Retrieves the signed integer value associated with a BAM tag. +bool GetTag (const std::string &tag, float &destination) const Retrieves the floating-point value associated with a BAM tag. +bool GetTagType (const std::string &tag, char &type) const Retrieves the BAM tag type-code associated with requested tag name. +bool GetEditDistance (uint32_t &editDistance) const Retrieves value of edit distance tag ("NM"). +bool GetReadGroup (std::string &readGroup) const Retrieves value of read group tag ("RG"). +bool RemoveTag (const std::string &tag) Removes field from BAM tags. +bool BuildCharData (void) Populates alignment string fields (read name, bases, qualities, tag data). +int GetEndPosition (bool usePadded=false, bool zeroBased=true) const Calculates alignment end position, based on starting position and CIGAR data. \ No newline at end of file diff --git a/src/bedtools.cpp b/src/bedtools.cpp index a76ed33cc75dfbcd52b4b8929de6dc6d6b5a64d0..965da00718b52c3203fac3af27cf7b061613d4b6 100644 --- a/src/bedtools.cpp +++ b/src/bedtools.cpp @@ -21,51 +21,158 @@ using namespace std; // define our program name #define PROGRAM_NAME "bedtools" +// colors for the term's menu +#define RESET "\e[m" +#define GREEN "\e[1;32m" +#define BLUE "\e[1;34m" +#define RED "\e[1;31m" + // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) +int annotate_main(int argc, char* argv[]);// +int bamtobed_main(int argc, char* argv[]);// +int bed12tobed6_main(int argc, char* argv[]); // +int bedtobam_main(int argc, char* argv[]);// +int bedtoigv_main(int argc, char* argv[]);// +int bedpetobam_main(int argc, char* argv[]);// +int closest_main(int argc, char* argv[]); // +int complement_main(int argc, char* argv[]);// +int coverage_main(int argc, char* argv[]); // +int fastafrombed_main(int argc, char* argv[]);// +int flank_main(int argc, char* argv[]); // +int genomecoverage_main(int argc, char* argv[]);// +int getoverlap_main(int argc, char* argv[]);// +int intersect_main(int argc, char* argv[]); // +int links_main(int argc, char* argv[]);// +int maskfastafrombed_main(int argc, char* argv[]);// +int merge_main(int argc, char* argv[]); // +int multibamcov_main(int argc, char* argv[]);// +int multiintersect_main(int argc, char* argv[]);// +int nuc_main(int argc, char* argv[]);// +int pairtobed_main(int argc, char* argv[]);// +int pairtopair_main(int argc, char* argv[]);// +int shuffle_main(int argc, char* argv[]); // +int slop_main(int argc, char* argv[]); // +int sort_main(int argc, char* argv[]); // +int subtract_main(int argc, char* argv[]); // +int tagbam_main(int argc, char* argv[]);// +int unionbedgraphs_main(int argc, char* argv[]);// +int window_main(int argc, char* argv[]); // -int intersect_main(int argc, char* argv[]); -int coverage_main(int argc, char* argv[]); -int merge_main(int argc, char* argv[]); -int substract_main(int argc, char* argv[]); - -static int help() +int bedtools_help() { - cerr << "\n"; - cerr << "Program: " << PROGRAM_NAME << " (Tools for genome arithmetic.)\n"; - cerr << "Version: " << "2.15.5" << "\n"; - cerr << "Author: " << "Aaron Quinlan (aaronquinlan@gmail.com)" << "\n\n"; - cerr << "Usage: bedtools <tool> [options]\n"; - - cerr << "\n-Genome arithmetic tools:\n"; - cerr << " intersect Find overlapping/intersecting intervals b/w two files.\n"; - cerr << " coverage Compute the coverage of one set of intervals over another.\n"; - cerr << " merge Combine overlapping or nearby intervals into a single interval.\n"; - cerr << " subtract Remove intervals based on overlaps b/w two files.\n"; - - cerr << "\n-Format conversion tools:\n"; - cerr << " intersect Find overlapping/intersecting intervals b/w two files.\n"; - - cerr << "\n-Fasta tools:\n"; - cerr << " intersect Find overlapping/intersecting intervals b/w two files.\n"; + cout << "\n"; + cout << PROGRAM_NAME << ": flexible tools for genome arithmetic and analysis.\n"; + cout << "Version: " << "2.15.5" << "\n"; + cout << "Authors: " << "Aaron Quinlan and others (see THANKS)" << "\n\n"; + cout << "Usage: bedtools <tool> [options]\n"; + + cout << "\nGenome arithmetic:" << endl; + cout << RED << " intersect " << RESET << "Find exactly overlapping intervals.\n"; + cout << RED << " window " << RESET << "Find overlapping intervals within a \"window\".\n"; + cout << RED << " closest " << RESET << "Find overlapping or nearby intervals.\n"; + cout << RED << " coverage " << RESET << "Compute the coverage over defined intervals.\n"; + cout << RED << " genomecov " << RESET << "Compute the coverage over an entire genome.\n"; + cout << RED << " merge " << RESET << "Combine overlapping/nearby intervals into a single interval.\n"; + cout << RED << " complement " << RESET << "Extract intervals _not_ represented by an interval file.\n"; + cout << RED << " subtract " << RESET << "Remove intervals based on overlaps b/w two files.\n"; + cout << RED << " slop " << RESET << "Adjust the size of intervals.\n"; + cout << RED << " flank " << RESET << "Create new intervals from the flanks of existing intervals.\n"; + cout << RED << " sort " << RESET << "Order the intervals in a file.\n"; + cout << RED << " shuffle " << RESET << "Randomly redistrubute intervals in a genome.\n"; + cout << RED << " annotate " << RESET << "Annotate coverage of features from multiple files.\n"; - cerr << "\n"; + cout << "\nMulti-way file comparisons:" << endl; + cout << RED << " multiinter " << RESET << "Identifies common intervals among multiple interval files.\n"; + cout << RED << " unionbedg " << RESET << "Combines coverage intervals from multiple BEDGRAPH files.\n"; + + cout << "\nPaired-end manipulation:" << endl; + cout << RED << " pairtobed " << RESET << "Find pairs that overlap intervals in various ways.\n"; + cout << RED << " pairtopair " << RESET << "Find pairs that overlap other pairs in various ways.\n"; + + cout << "\nFormat conversion:\n"; + cout << RED << " bamtobed " << RESET << "Convert BAM alignments to BED (& other) formats.\n"; + cout << RED << " bedtobam " << RESET << "Convert intervals to BAM records.\n"; + cout << RED << " bedpetobam " << RESET << "Convert BEDPE intervals to BAM records.\n"; + cout << RED << " bed12tobed6 " << RESET << "Breaks BED12 intervals into discrete BED6 intervals.\n"; + + cout << "\nFasta manipulation:\n"; + cout << RED << " getfasta " << RESET << "Use intervals to extract sequences from a FASTA file.\n"; + cout << RED << " maskfasta " << RESET << "Use intervals to mask sequences from a FASTA file.\n"; + cout << RED << " nuc " << RESET << "Profile the nucleotide content of intervals in a FASTA file.\n"; + + cout << "\nBAM focused tools:\n"; + cout << RED << " multicov " << RESET << "Counts coverage from multiple BAMs at specific intervals.\n"; + cout << RED << " tag " << RESET << "Annotate BAM alignments based on overlaps with interval files.\n"; + + cout << "\nMiscellaneous tools:\n"; + cout << RED << " overlap " << RESET << "Computes the amount of overlap from two intervals.\n"; + cout << RED << " igv " << RESET << "Create an IGV snapshot batch script.\n"; + cout << RED << " links " << RESET << "Create a HTML page of links to UCSC locations.\n"; + + cout << "\nGeneral help:\n"; + cout << RED << " faq " << RESET << "Frequently asked questions.\n"; + + cout << "\n"; return 1; } int main(int argc, char *argv[]) { // make sure the user at least entered a sub_command - if (argc < 2) return help(); + if (argc < 2) return bedtools_help(); + + // genome arithmetic tools + if (strcmp(argv[1], "intersect") == 0) return intersect_main(argc-1, argv+1); + else if (strcmp(argv[1], "window") == 0) return window_main(argc-1, argv+1); + else if (strcmp(argv[1], "closest") == 0) return closest_main(argc-1, argv+1); + else if (strcmp(argv[1], "coverage") == 0) return coverage_main(argc-1, argv+1); + else if (strcmp(argv[1], "genomecov") == 0) return genomecoverage_main(argc-1, argv+1); + else if (strcmp(argv[1], "merge") == 0) return merge_main(argc-1, argv+1); + else if (strcmp(argv[1], "complement") == 0) return complement_main(argc-1, argv+1); + else if (strcmp(argv[1], "subtract") == 0) return subtract_main(argc-1, argv+1); + else if (strcmp(argv[1], "slop") == 0) return slop_main(argc-1, argv+1); + else if (strcmp(argv[1], "flank") == 0) return flank_main(argc-1, argv+1); + else if (strcmp(argv[1], "sort") == 0) return sort_main(argc-1, argv+1); + else if (strcmp(argv[1], "shuffle") == 0) return shuffle_main(argc-1, argv+1); + else if (strcmp(argv[1], "annotate") == 0) return annotate_main(argc-1, argv+1); + + // Multi-way file comparisonstools + else if (strcmp(argv[1], "multiinter") == 0) return multiintersect_main(argc-1, argv+1); + else if (strcmp(argv[1], "unionbedg") == 0) return unionbedgraphs_main(argc-1, argv+1); + + // paired-end conversion tools + else if (strcmp(argv[1], "pairtobed") == 0) return pairtobed_main(argc-1, argv+1); + else if (strcmp(argv[1], "pairtopair") == 0) return pairtopair_main(argc-1, argv+1); + + // format conversion tools + else if (strcmp(argv[1], "bamtobed") == 0) return bamtobed_main(argc-1, argv+1); + else if (strcmp(argv[1], "bedtobam") == 0) return bedtobam_main(argc-1, argv+1); + else if (strcmp(argv[1], "bedpetobam") == 0) return bedpetobam_main(argc-1, argv+1); + else if (strcmp(argv[1], "bed12tobed6") == 0) return bed12tobed6_main(argc-1, argv+1); + + // BAM-specific tools + else if (strcmp(argv[1], "multicov") == 0) return multibamcov_main(argc-1, argv+1); + else if (strcmp(argv[1], "tag") == 0) return tagbam_main(argc-1, argv+1); + + // fasta tools + else if (strcmp(argv[1], "getfasta") == 0) return fastafrombed_main(argc-1, argv+1); + else if (strcmp(argv[1], "maskfasta") == 0) return maskfastafrombed_main(argc-1, argv+1); + else if (strcmp(argv[1], "nuc") == 0) return nuc_main(argc-1, argv+1); + + // misc. tools + else if (strcmp(argv[1], "overlap") == 0) return getoverlap_main(argc-1, argv+1); + else if (strcmp(argv[1], "igv") == 0) return bedtoigv_main(argc-1, argv+1); + else if (strcmp(argv[1], "links") == 0) return links_main(argc-1, argv+1); + + // help + else if (strcmp(argv[1], "-h") == 0) return bedtools_help(); + else if (strcmp(argv[1], "--help") == 0) return bedtools_help(); - // spawn the proper tool. - if (strcmp(argv[1], "intersect") == 0) return intersect_main(argc-1, argv+1); - else if (strcmp(argv[1], "coverage") == 0) return coverage_main(argc-1, argv+1); - else if (strcmp(argv[1], "merge") == 0) return merge_main(argc-1, argv+1); - else if (strcmp(argv[1], "subtract") == 0) return subtract_main(argc-1, argv+1); + // unknown else { - fprintf(stderr, "[main] unrecognized command '%s'\n", argv[1]); + cerr << "error: unrecognized command: " << argv[1] << endl << endl; return 1; } return 0; diff --git a/src/closestBed/Makefile b/src/closestBed/Makefile index 00cfd889d6af6d88b6eeb88826859f9999cc38b6..859bfcf118cee4a81741f10e3729ac3445cc072a 100644 --- a/src/closestBed/Makefile +++ b/src/closestBed/Makefile @@ -16,14 +16,10 @@ EXT_OBJECTS=$(patsubst %,$(OBJ_DIR)/%,$(_EXT_OBJECTS)) BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= closestBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/closestBed/closestMain.cpp b/src/closestBed/closestMain.cpp index 0128af24fc6edbb4fa20558e56a1b541774be9b1..e4f1b7a51def47bf2a8095da7c278e53b7c356b5 100644 --- a/src/closestBed/closestMain.cpp +++ b/src/closestBed/closestMain.cpp @@ -15,15 +15,15 @@ using namespace std; // define our program name -#define PROGRAM_NAME "closestBed" +#define PROGRAM_NAME "bedtools closest" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void closest_help(void); -int main(int argc, char* argv[]) { +int closest_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -58,7 +58,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) closest_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -144,19 +144,16 @@ int main(int argc, char* argv[]) { diffStrand, tieMode, reportDistance, signDistance, strandedDistMode, ignoreOverlaps, printHeader); delete bc; - return 0; } else { - ShowHelp(); + closest_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Authors: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; - cerr << "\t Erik Arner, Riken" << endl << endl; +void closest_help(void) { + + cerr << "\nTool: bedtools closest (aka closestBed)" << endl; cerr << "Summary: For each feature in A, finds the closest " << endl; cerr << "\t feature (upstream or downstream) in B." << endl << endl; @@ -164,12 +161,12 @@ void ShowHelp(void) { cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -a <bed/gff/vcf> -b <bed/gff/vcf>" << endl << endl; cerr << "Options: " << endl; - cerr << "\t-s\t" << "Require same strandedness. That is, find the closest feature in B" << endl; - cerr << "\t\tthat overlaps A on the _same_ strand." << endl; + cerr << "\t-s\t" << "Req. same strandedness. That is, find the closest feature in" << endl; + cerr << "\t\tB that overlaps A on the _same_ strand." << endl; cerr << "\t\t- By default, overlaps are reported without respect to strand." << endl << endl; - cerr << "\t-S\t" << "Require opposite strandedness. That is, find the closest feature in B" << endl; - cerr << "\t\tthat overlaps A on the _opposite_ strand." << endl; + cerr << "\t-S\t" << "Req. opposite strandedness. That is, find the closest feature" << endl; + cerr << "\t\tin B that overlaps A on the _opposite_ strand." << endl; cerr << "\t\t- By default, overlaps are reported without respect to strand." << endl << endl; cerr << "\t-d\t" << "In addition to the closest feature in B, " << endl; @@ -178,17 +175,19 @@ void ShowHelp(void) { cerr << "\t-D\t" << "Like -d, report the closest feature in B, and its distance to A" << endl; cerr << "\t\tas an extra column. Unlike -d, use negative distances to report" << endl; - cerr << "\t\tupstream features. You must specify which orientation defines \"upstream\"." << endl; - cerr << "\t\tThe options are:" << endl; + cerr << "\t\tupstream features." << endl; + cerr << "\t\tThe options for defining which orientation is \"upstream\" are:" << endl; cerr << "\t\t- \"ref\" Report distance with respect to the reference genome. " << endl; cerr << "\t\t B features with a lower (start, stop) are upstream" << endl; cerr << "\t\t- \"a\" Report distance with respect to A." << endl; - cerr << "\t\t When A is on the - strand, \"upstream\" means B has a higher (start,stop)." << endl; + cerr << "\t\t When A is on the - strand, \"upstream\" means B has a" << endl; + cerr << "\t\t higher (start,stop)." << endl; cerr << "\t\t- \"b\" Report distance with respect to B." << endl; - cerr << "\t\t When B is on the - strand, \"upstream\" means A has a higher (start,stop)." << endl << endl; + cerr << "\t\t When B is on the - strand, \"upstream\" means A has a" << endl; + cerr << "\t\t higher (start,stop)." << endl << endl; - cerr << "\t-io\t" << "Ignore features in B that overlap A. That is, we want close, but " << endl; - cerr << "\t\tnot touching features only." << endl << endl; + cerr << "\t-io\t" << "Ignore features in B that overlap A. That is, we want close," << endl; + cerr << "\t\tyet not touching features only." << endl << endl; cerr << "\t-t\t" << "How ties for closest feature are handled. This occurs when two" << endl; cerr << "\t\tfeatures in B have exactly the same \"closeness\" with A." << endl; diff --git a/src/complementBed/Makefile b/src/complementBed/Makefile index 2f542063e48f88b4aad550cbc8136f0739709f41..bc56b4dd173a35d04af8654f56178b74cca5df0c 100644 --- a/src/complementBed/Makefile +++ b/src/complementBed/Makefile @@ -24,14 +24,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= complementBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/complementBed/complementMain.cpp b/src/complementBed/complementMain.cpp index 7eb34d5f5f3745eac2b9340ddc258464afc431af..98b1a786b7cdd5d3cf97640edb5f9839b4f9e42a 100644 --- a/src/complementBed/complementMain.cpp +++ b/src/complementBed/complementMain.cpp @@ -15,16 +15,16 @@ using namespace std; // define our program name -#define PROGRAM_NAME "complementBed" +#define PROGRAM_NAME "bedtools complement" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void complement_help(void); -int main(int argc, char* argv[]) { +int complement_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -45,7 +45,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) complement_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -73,25 +73,23 @@ int main(int argc, char* argv[]) { // make sure we have both input files if (!haveBed || !haveGenome) { - cerr << endl << "*****" << endl << "*****ERROR: Need -i BED file and -g Genome file. " << endl << "*****" << endl; + cerr << endl << "*****" << endl << "*****ERROR: Need -i BED file and -g genome file. " << endl << "*****" << endl; showHelp = true; } if (!showHelp) { BedComplement *bc = new BedComplement(bedFile, genomeFile); bc->ComplementBed(); - return 0; } else { - ShowHelp(); + complement_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void complement_help(void) { + cerr << "\nTool: bedtools complement (aka complementBed)" << endl; + cerr << "Summary: Returns the base pair complement of a feature file." << endl << endl; cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -i <bed/gff/vcf> -g <genome>" << endl << endl; diff --git a/src/coverageBed/Makefile b/src/coverageBed/Makefile index 48ccb37fa903f4c79e2ee69aa957237b09295744..ea5d777bc0680972e8cbdc8e58f3fbca9e501b55 100644 --- a/src/coverageBed/Makefile +++ b/src/coverageBed/Makefile @@ -24,14 +24,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= coverageBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ -L$(UTILITIES_DIR)/BamTools/lib/ -lbamtools $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/coverageBed/coverageMain.cpp b/src/coverageBed/coverageMain.cpp index 6a01fdc6521298b59954f404eef43a8d711efacc..a0b839f8ed0b7ef4c9da612fae306b5d4e76f5a4 100644 --- a/src/coverageBed/coverageMain.cpp +++ b/src/coverageBed/coverageMain.cpp @@ -15,15 +15,15 @@ using namespace std; // define the version -#define PROGRAM_NAME "coverageBed" +#define PROGRAM_NAME "bedtools coverage" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void coverage_help(void); -int main(int argc, char* argv[]) { +int coverage_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -55,7 +55,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) coverage_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -123,19 +123,17 @@ int main(int argc, char* argv[]) { BedCoverage *bg = new BedCoverage(bedAFile, bedBFile, sameStrand, diffStrand, writeHistogram, bamInput, obeySplits, eachBase, countsOnly); delete bg; - return 0; } else { - ShowHelp(); + coverage_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void coverage_help(void) { + cerr << "\nTool: bedtools coverage (aka coverageBed)" << endl; + cerr << "Summary: Returns the depth and breadth of coverage of features from A" << endl; cerr << "\t on the intervals in B." << endl << endl; @@ -149,8 +147,8 @@ void ShowHelp(void) { cerr << "\t\toverlap B on the _same_ strand." << endl; cerr << "\t\t- By default, overlaps are counted without respect to strand." << endl << endl; - cerr << "\t-S\t" << "Require different strandedness. That is, only report hits in A that" << endl; - cerr << "\t\toverlap B on the _opposite_ strand." << endl; + cerr << "\t-S\t" << "Require different strandedness. That is, only report hits in A" << endl; + cerr << "\t\tthat overlap B on the _opposite_ strand." << endl; cerr << "\t\t- By default, overlaps are counted without respect to strand." << endl << endl; cerr << "\t-hist\t" << "Report a histogram of coverage for each feature in B" << endl; diff --git a/src/fastaFromBed/Makefile b/src/fastaFromBed/Makefile index 3cd9e892da53c4c6fa6a91b9435ba037594657e2..701a660492978d67b8f3562f865d38cd1faf0905 100644 --- a/src/fastaFromBed/Makefile +++ b/src/fastaFromBed/Makefile @@ -25,14 +25,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= fastaFromBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/fastaFromBed/fastaFromBedMain.cpp b/src/fastaFromBed/fastaFromBedMain.cpp index c31676d93228329dad44141c43b5d790aa8471d9..06bce7754e7e1af3a431a604f539857267ee8811 100644 --- a/src/fastaFromBed/fastaFromBedMain.cpp +++ b/src/fastaFromBed/fastaFromBedMain.cpp @@ -15,16 +15,16 @@ using namespace std; // define our program name -#define PROGRAM_NAME "fastaFromBed" +#define PROGRAM_NAME "bedtools getfasta" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void fastafrombed_help(void); -int main(int argc, char* argv[]) { +int fastafrombed_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -56,7 +56,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) fastafrombed_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -107,19 +107,16 @@ int main(int argc, char* argv[]) { Bed2Fa *b2f = new Bed2Fa(useNameOnly, fastaDbFile, bedFile, fastaOutFile, useFasta, useStrand); delete b2f; - - return 0; } else { - ShowHelp(); + fastafrombed_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void fastafrombed_help(void) { + + cerr << "\nTool: bedtools getfasta (aka fastaFromBed)" << endl; cerr << "Summary: Extract DNA sequences into a fasta file based on feature coordinates." << endl << endl; @@ -134,12 +131,10 @@ void ShowHelp(void) { cerr << "\t-tab\tWrite output in TAB delimited format." << endl; cerr << "\t\t- Default is FASTA format." << endl << endl; - cerr << "\t-s\tForce strandedness. If the feature occupies the antisense strand," << endl; - cerr << "\t\tthe sequence will be reverse complemented." << endl; + cerr << "\t-s\tForce strandedness. If the feature occupies the antisense," << endl; + cerr << "\t\tstrand, the sequence will be reverse complemented." << endl; cerr << "\t\t- By default, strand information is ignored." << endl << endl; - - // end the program here exit(1); diff --git a/src/flankBed/Makefile b/src/flankBed/Makefile index 1da2069305eca0bb9b6c64c40b3b5f3defc37aae..bc53291bf943fce1c92736ed3c066c1f4aed91d8 100644 --- a/src/flankBed/Makefile +++ b/src/flankBed/Makefile @@ -24,14 +24,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= flankBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/flankBed/flankBedMain.cpp b/src/flankBed/flankBedMain.cpp index 062839e6a377298ce849bd209ea5d9e093df46f5..5600cec0acae200fc58c6b5ad8e3c14f70da69de 100644 --- a/src/flankBed/flankBedMain.cpp +++ b/src/flankBed/flankBedMain.cpp @@ -15,16 +15,16 @@ using namespace std; // define our program name -#define PROGRAM_NAME "flankBed" +#define PROGRAM_NAME "bedtools flank" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void flank_help(void); -int main(int argc, char* argv[]) { +int flank_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -54,7 +54,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) flank_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -137,15 +137,14 @@ int main(int argc, char* argv[]) { return 0; } else { - ShowHelp(); + flank_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void flank_help(void) { + + cerr << "\nTool: bedtools flank (aka flankBed)" << endl; cerr << "Summary: Creates flanking interval(s) for each BED/GFF/VCF feature." << endl << endl; @@ -155,10 +154,12 @@ void ShowHelp(void) { cerr << "\t-b\t" << "Create flanking intervak using -b base pairs in each direction." << endl; cerr << "\t\t- (Integer) or (Float, e.g. 0.1) if used with -pct." << endl << endl; - cerr << "\t-l\t" << "The number of base pairs that a flank should start from orig. start coordinate." << endl; + cerr << "\t-l\t" << "The number of base pairs that a flank should start from" << endl; + cerr << "\t\torig. start coordinate." << endl; cerr << "\t\t- (Integer) or (Float, e.g. 0.1) if used with -pct." << endl << endl; - cerr << "\t-r\t" << "The number of base pairs that a flank should end from orig. end coordinate." << endl; + cerr << "\t-r\t" << "The number of base pairs that a flank should end from" << endl; + cerr << "\t\torig. end coordinate." << endl; cerr << "\t\t- (Integer) or (Float, e.g. 0.1) if used with -pct." << endl << endl; cerr << "\t-s\t" << "Define -l and -r based on strand." << endl; diff --git a/src/genomeCoverageBed/Makefile b/src/genomeCoverageBed/Makefile index 4194fdb581eecaef89964490ddb8c4f146270593..a77257674c3ff69d7f0d348e85c0bbc197ed0c34 100644 --- a/src/genomeCoverageBed/Makefile +++ b/src/genomeCoverageBed/Makefile @@ -24,14 +24,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= genomeCoverageBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ -L$(UTILITIES_DIR)/BamTools/lib/ -lbamtools $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/genomeCoverageBed/genomeCoverageMain.cpp b/src/genomeCoverageBed/genomeCoverageMain.cpp index a316e45acd1bb28ed0571695cf175652a3420d97..43cb0246f6ec85ffe00891fb7792cc92a724acdd 100644 --- a/src/genomeCoverageBed/genomeCoverageMain.cpp +++ b/src/genomeCoverageBed/genomeCoverageMain.cpp @@ -15,16 +15,16 @@ Licenced under the GNU General Public License 2.0 license. using namespace std; // define our program name -#define PROGRAM_NAME "genomeCoverageBed" +#define PROGRAM_NAME "bedtools genomecov" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void genomecoverage_help(void); -int main(int argc, char* argv[]) { +int genomecoverage_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -64,7 +64,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) genomecoverage_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -205,21 +205,17 @@ int main(int argc, char* argv[]) { eachBaseZeroBased, add_gb_track_line, gb_track_opts); delete bc; - - return 0; } else { - ShowHelp(); + genomecoverage_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Authors: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; - cerr << " Assaf Gordon, CSHL" << endl << endl; +void genomecoverage_help(void) { + cerr << "\nTool: bedtools genomecov (aka genomeCoverageBed)" << endl; + cerr << "Summary: Compute the coverage of a feature file among a genome." << endl << endl; cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -i <bed/gff/vcf> -g <genome>" << endl << endl; diff --git a/src/getOverlap/Makefile b/src/getOverlap/Makefile index be9ff2faed3acf0d5ab32c2690d058ae0acb9526..6767447bcb3ba3dbd3900ed0721ee93616f32360 100644 --- a/src/getOverlap/Makefile +++ b/src/getOverlap/Makefile @@ -19,15 +19,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= getOverlap -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all - -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/getOverlap/getOverlap.cpp b/src/getOverlap/getOverlap.cpp index 20bb597bffae49b32446fd9b789567f9f8ae336f..ec981a2db065ce1feca85c13ec9238e4527d8866 100644 --- a/src/getOverlap/getOverlap.cpp +++ b/src/getOverlap/getOverlap.cpp @@ -28,11 +28,11 @@ using namespace std; // function declarations -void ShowHelp(void); +void getoverlap_help(void); void DetermineInput(string &inFile, short &s1Col, short &e1Col, short &s2Col, short &e2Col); void ComputeOverlaps(istream &input, short &s1Col, short &e1Col, short &s2Col, short &e2Col); -int main(int argc, char* argv[]) { +int getoverlap_main(int argc, char* argv[]) { // input files string inFile = "stdin"; @@ -53,7 +53,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) getoverlap_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -92,7 +92,7 @@ int main(int argc, char* argv[]) { if (posColumns.size() != 4) { cerr << endl << "*****" << endl << "*****ERROR: Please specify 4, comma-separated position columns. " << endl << "*****" << endl; - ShowHelp(); + getoverlap_help(); } else { short s1, e1, s2, e2; @@ -105,16 +105,15 @@ int main(int argc, char* argv[]) { } } else { - ShowHelp(); + getoverlap_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void getoverlap_help(void) { + cerr << "\nTool: bedtools overlap (aka getOverlap)" << endl; + cerr << "Summary: Computes the amount of overlap (positive values)" << endl; cerr << "\t or distance (negative values) between genome features" << endl; cerr << "\t and reports the result at the end of the same line." << endl << endl; diff --git a/src/intersectBed/Makefile b/src/intersectBed/Makefile index 71cba93dd95b06e319ad3d2621874859985373fc..a6919d99c1af7e4c7677af53101fd4a43dfab9af 100644 --- a/src/intersectBed/Makefile +++ b/src/intersectBed/Makefile @@ -25,17 +25,13 @@ EXT_OBJECTS=$(patsubst %,$(OBJ_DIR)/%,$(_EXT_OBJECTS)) BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= intersectBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ -L$(UTILITIES_DIR)/BamTools/lib/ -lbamtools $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp - @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) + @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(DFLAGS) $(INCLUDES) $(EXT_OBJECTS): @$(MAKE) --no-print-directory -C $(UTILITIES_DIR)/bedFile/ diff --git a/src/intersectBed/intersectMain.cpp b/src/intersectBed/intersectMain.cpp index f1af974ad2aed7a00c36514ece89bf3fa29b91fe..d5602e7c8363172b4ccef15bd043c747901940ee 100644 --- a/src/intersectBed/intersectMain.cpp +++ b/src/intersectBed/intersectMain.cpp @@ -224,15 +224,14 @@ int intersect_main(int argc, char* argv[]) { } else { intersect_help(); + return 0; } } void intersect_help(void) { - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; - + cerr << "\nTool: bedtools intersect (aka intersectBed)" << endl; + cerr << "Summary: Report overlaps between two feature files." << endl << endl; cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -a <bed/gff/vcf> -b <bed/gff/vcf>" << endl << endl; @@ -241,7 +240,7 @@ void intersect_help(void) { cerr << "\t-abam\t" << "The A input file is in BAM format. Output will be BAM as well." << endl << endl; - cerr << "\t-ubam\t" << "Write uncompressed BAM output. Default is to write compressed BAM." << endl << endl; + cerr << "\t-ubam\t" << "Write uncompressed BAM output. Default writes compressed BAM." << endl << endl; cerr << "\t-bed\t" << "When using BAM input (-abam), write output as BED. The default" << endl; cerr << "\t\tis to write output in BAM when using -abam." << endl << endl; @@ -281,18 +280,17 @@ void intersect_help(void) { cerr << "\t\t- In other words, if -f is 0.90 and -r is used, this requires" << endl; cerr << "\t\t that B overlap 90% of A and A _also_ overlaps 90% of B." << endl << endl; - cerr << "\t-s\t" << "Require same strandedness. That is, only report hits in B that" << endl; - cerr << "\t\toverlap A on the _same_ strand." << endl; + cerr << "\t-s\t" << "Require same strandedness. That is, only report hits in B" << endl; + cerr << "\t\tthat overlap A on the _same_ strand." << endl; cerr << "\t\t- By default, overlaps are reported without respect to strand." << endl << endl; - cerr << "\t-S\t" << "Require different strandedness. That is, only report hits in B that" << endl; - cerr << "\t\toverlap A on the _opposite_ strand." << endl; + cerr << "\t-S\t" << "Require different strandedness. That is, only report hits in B" << endl; + cerr << "\t\tthat overlap A on the _opposite_ strand." << endl; cerr << "\t\t- By default, overlaps are reported without respect to strand." << endl << endl; cerr << "\t-split\t" << "Treat \"split\" BAM or BED12 entries as distinct BED intervals." << endl << endl; - cerr << "\t-sorted\t" << "Use the \"chromsweep\" algorithm for sorted (-k1,1 -k2,2n) input" << endl; - cerr << "\t\tNOTE: this will trust, but not enforce that data is sorted. Caveat emptor." << endl << endl; + cerr << "\t-sorted\t" << "Use the \"chromsweep\" algorithm for sorted (-k1,1 -k2,2n) input" << endl << endl; cerr << "\t-header\t" << "Print the header from the A file prior to results." << endl << endl; diff --git a/src/linksBed/Makefile b/src/linksBed/Makefile index 75317bf20e885fc00e7af6506f90e159474b42d0..7c354db999788cdbea989a044531080b412f6a8c 100644 --- a/src/linksBed/Makefile +++ b/src/linksBed/Makefile @@ -18,14 +18,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= linksBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/linksBed/linksMain.cpp b/src/linksBed/linksMain.cpp index f4e5500d68686694b9262285f43d9608bf05828c..8009d8842cbec9b8ff72b6a24132f05dd5351216 100644 --- a/src/linksBed/linksMain.cpp +++ b/src/linksBed/linksMain.cpp @@ -15,16 +15,16 @@ using namespace std; // define our program name -#define PROGRAM_NAME "linksBed" +#define PROGRAM_NAME "bedtools links" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void links_help(void); -int main(int argc, char* argv[]) { +int links_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -47,7 +47,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) links_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -93,19 +93,17 @@ int main(int argc, char* argv[]) { if (!showHelp) { BedLinks *bl = new BedLinks(bedFile, base, org, db); delete bl; - return 0; } else { - ShowHelp(); + links_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void links_help(void) { + cerr << "\nTool: bedtools links (aka linksBed)" << endl; + cerr << "Summary: Creates HTML links to an UCSC Genome Browser from a feature file." << endl << endl; cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -i <bed/gff/vcf> > out.html" << endl << endl; diff --git a/src/maskFastaFromBed/Makefile b/src/maskFastaFromBed/Makefile index 9b65fc5255774fab8ecf831aae62226066064058..3b5ec085d3f8560f5cff365748ed123999159a70 100644 --- a/src/maskFastaFromBed/Makefile +++ b/src/maskFastaFromBed/Makefile @@ -17,14 +17,10 @@ EXT_OBJECTS=$(patsubst %,$(OBJ_DIR)/%,$(_EXT_OBJECTS)) BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= maskFastaFromBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/maskFastaFromBed/maskFastaFromBedMain.cpp b/src/maskFastaFromBed/maskFastaFromBedMain.cpp index 7fce56bbbe913fca5384b19dba4e5fb86ad99e82..5bb73908a5d307a0fe90fb3b83eee1bc04035a0d 100644 --- a/src/maskFastaFromBed/maskFastaFromBedMain.cpp +++ b/src/maskFastaFromBed/maskFastaFromBedMain.cpp @@ -15,16 +15,16 @@ using namespace std; // define our program name -#define PROGRAM_NAME "maskFastaFromBed" +#define PROGRAM_NAME "bedtools maskfasta" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void maskfastafrombed_help(void); -int main(int argc, char* argv[]) { +int maskfastafrombed_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -55,7 +55,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) maskfastafrombed_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -113,24 +113,20 @@ int main(int argc, char* argv[]) { MaskFastaFromBed *maskFasta = new MaskFastaFromBed(fastaInFile, bedFile, fastaOutFile, softMask, maskChar); delete maskFasta; - return 0; } else { - ShowHelp(); + maskfastafrombed_help(); } + return 0; } -void ShowHelp(void) { - - - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void maskfastafrombed_help(void) { + cerr << "\nTool: bedtools maskfasta (aka maskFastaFromBed)" << endl; + cerr << "Summary: Mask a fasta file based on feature coordinates." << endl << endl; - cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -fi <fasta> -out <fasta> -bed <bed/gff/vcf>" << endl << endl; + cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -fi <fasta> -fo <fasta> -bed <bed/gff/vcf>" << endl << endl; cerr << "Options:" << endl; cerr << "\t-fi\tInput FASTA file" << endl; @@ -138,8 +134,8 @@ void ShowHelp(void) { cerr << "\t-fo\tOutput FASTA file" << endl; cerr << "\t-soft\tEnforce \"soft\" masking. That is, instead of masking with Ns," << endl; cerr << "\t\tmask with lower-case bases." << endl; - cerr << "\t-mc\tReplace masking character. That is, instead of masking with Ns, use another character." << endl; - + cerr << "\t-mc\tReplace masking character. That is, instead of masking" << endl; + cerr << "\t\twith Ns, use another character." << endl << endl; // end the program here exit(1); diff --git a/src/mergeBed/Makefile b/src/mergeBed/Makefile index c6a08b6dae4f95bdfeb7dbefc43de0354698fd1a..345571e282a22181384ac876c8d3f7da35f73e2f 100644 --- a/src/mergeBed/Makefile +++ b/src/mergeBed/Makefile @@ -18,14 +18,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= mergeBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/mergeBed/mergeMain.cpp b/src/mergeBed/mergeMain.cpp index 03ee935511763992ad5503f2c34d2222570c2516..b91d4e1fac3f8ef06a2165157352a18c062a06f8 100644 --- a/src/mergeBed/mergeMain.cpp +++ b/src/mergeBed/mergeMain.cpp @@ -15,16 +15,16 @@ using namespace std; // define our program name -#define PROGRAM_NAME "mergeBed" +#define PROGRAM_NAME "bedtools merge" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void merge_help(void); -int main(int argc, char* argv[]) { +int merge_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -51,7 +51,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) merge_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -112,19 +112,17 @@ int main(int argc, char* argv[]) { if (!showHelp) { BedMerge *bm = new BedMerge(bedFile, numEntries, maxDistance, forceStrand, reportNames, reportScores, scoreOp); delete bm; - return 0; } else { - ShowHelp(); + merge_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; - +void merge_help(void) { + + cerr << "\nTool: bedtools merge (aka mergeBed)" << endl; + cerr << "Summary: Merges overlapping BED/GFF/VCF entries into a single interval." << endl << endl; cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -i <bed/gff/vcf>" << endl << endl; diff --git a/src/multiBamCov/Makefile b/src/multiBamCov/Makefile index 9313ab959e995bdeea6427c29eb42924045826c1..cf992632b30f53501abcfd00e371415cce440ef3 100644 --- a/src/multiBamCov/Makefile +++ b/src/multiBamCov/Makefile @@ -22,14 +22,10 @@ EXT_OBJECTS=$(patsubst %,$(OBJ_DIR)/%,$(_EXT_OBJECTS)) BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= multiBamCov -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ -L$(UTILITIES_DIR)/BamTools/lib/ -lbamtools $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/multiBamCov/multiBamCovMain.cpp b/src/multiBamCov/multiBamCovMain.cpp index 69b340dc975ba4c9cc7d8215bb03ea14e5e881a8..6b3c1b8544391d2ba45f1cb5756612aba8076060 100644 --- a/src/multiBamCov/multiBamCovMain.cpp +++ b/src/multiBamCov/multiBamCovMain.cpp @@ -15,16 +15,16 @@ using namespace std; // define our program name -#define PROGRAM_NAME "multiBamCov" +#define PROGRAM_NAME "bedtools multicov" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void multibamcov_help(void); -int main(int argc, char* argv[]) { +int multibamcov_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -53,7 +53,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) multibamcov_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -107,19 +107,17 @@ int main(int argc, char* argv[]) { MultiCovBam *mc = new MultiCovBam(bamFiles, bedFile, minQual, properOnly, keepDuplicates, keepFailedQC); mc->CollectCoverage(); delete mc; - return 0; } else { - ShowHelp(); + multibamcov_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void multibamcov_help(void) { + cerr << "\nTool: bedtools multicov (aka multiBamCov)" << endl; + cerr << "Summary: Counts sequence coverage for multiple bams at specific loci." << endl << endl; cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -bams aln.1.bam aln.2.bam ... aln.n.bam -bed <bed/gff/vcf>" << endl << endl; @@ -132,12 +130,12 @@ void ShowHelp(void) { cerr << "\t-q\t" << "Minimum mapping quality allowed. Default is 0." << endl << endl; - cerr << "\t-D\t" << "Include duplicate-marked reads. Default is to count non-duplicates only" << endl << endl; + cerr << "\t-D\t" << "Include duplicate reads. Default counts non-duplicates only" << endl << endl; - cerr << "\t-F\t" << "Include failed-QC reads. Default is to count pass-QC reads only" << endl << endl; + cerr << "\t-F\t" << "Include failed-QC reads. Default counts pass-QC reads only" << endl << endl; - cerr << "\t-p\t" << "Only count proper pairs. Default is to count all alignments with MAPQ" << endl; - cerr << "\t\t" << "greater than the -q argument, regardless of the BAM FLAG field." << endl << endl; + cerr << "\t-p\t" << "Only count proper pairs. Default counts all alignments with" << endl; + cerr << "\t\t" << "MAPQ > -q argument, regardless of the BAM FLAG field." << endl << endl; // end the program here exit(1); diff --git a/src/multiIntersectBed/Makefile b/src/multiIntersectBed/Makefile index a076f3b411dbb81a4083f95b88edc03350799d84..4dfe6113c6fc55af5548037ca531da6e6e0cc43c 100644 --- a/src/multiIntersectBed/Makefile +++ b/src/multiIntersectBed/Makefile @@ -23,14 +23,10 @@ EXT_OBJECTS=$(patsubst %,$(OBJ_DIR)/%,$(_EXT_OBJECTS)) BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= multiIntersectBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/multiIntersectBed/multiIntersectBedMain.cpp b/src/multiIntersectBed/multiIntersectBedMain.cpp index 5b4b627b3f5cda39450147dbf5000c83d2b6abd1..d67bdb4cc34032a10b79579dfd26887247599630 100644 --- a/src/multiIntersectBed/multiIntersectBedMain.cpp +++ b/src/multiIntersectBed/multiIntersectBedMain.cpp @@ -26,7 +26,7 @@ using namespace std; // define our program name -#define PROGRAM_NAME "multiIntersectBed" +#define PROGRAM_NAME "bedtools multiinter" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) @@ -37,11 +37,10 @@ using namespace std; std::string stl_basename(const std::string& path); // function declarations -void ShowHelp(void); -void ShowExamples(void); +void multiintersect_help(void); +void multiintersect_examples(void); - -int main(int argc, char* argv[]) +int multiintersect_main(int argc, char* argv[]) { bool haveFiles = false; bool haveTitles = false; @@ -59,7 +58,7 @@ int main(int argc, char* argv[]) //Parse command line options if(argc <= 1) - ShowHelp(); + multiintersect_help(); for(int i = 1; i < argc; i++) { int parameterLength = (int)strlen(argv[i]); @@ -71,7 +70,7 @@ int main(int argc, char* argv[]) } if(showHelp == true) { - ShowHelp(); + multiintersect_help(); exit(1); } @@ -132,8 +131,8 @@ int main(int argc, char* argv[]) cluster = true; } else if(PARAMETER_CHECK("-examples", 9, parameterLength)) { - ShowHelp(); - ShowExamples(); + multiintersect_help(); + multiintersect_examples(); exit(1); } } @@ -163,15 +162,14 @@ int main(int argc, char* argv[]) mbi.MultiIntersect(); else mbi.Cluster(); + + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Authors: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; - cerr << " Assaf Gordon" << endl << endl; +void multiintersect_help(void) { + cerr << "\nTool: bedtools multiinter (aka multiIntersectBed)" << endl; + cerr << "Summary: Identifies common intervals among multiple" << endl; cerr << "\t BED/GFF/VCF files." << endl << endl; @@ -180,12 +178,12 @@ void ShowHelp(void) { cerr << "Options: " << endl; - cerr << "\t-cluster\t\t" << "Invoke Ryan's algorithm." << endl << endl; + cerr << "\t-cluster\t" << "Invoke Ryan Layers's clustering algorithm." << endl << endl; cerr << "\t-header\t\t" << "Print a header line." << endl; cerr << "\t\t\t(chrom/start/end + names of each file)." << endl << endl; - cerr << "\t-names\t\t" << "A list of names (one / file) to describe each file in -i." << endl; + cerr << "\t-names\t\t" << "A list of names (one/file) to describe each file in -i." << endl; cerr << "\t\t\tThese names will be printed in the header line." << endl << endl; cerr << "\t-g\t\t" << "Use genome file to calculate empty regions." << endl; @@ -196,14 +194,14 @@ void ShowHelp(void) { cerr << "\t\t\t- Requires the '-g FILE' parameter.\n" << endl; cerr << "\t-filler TEXT\t" << "Use TEXT when representing intervals having no value." << endl; - cerr << "\t\t\t- Default is '0', but you can use 'N/A' or any other text." << endl << endl; + cerr << "\t\t\t- Default is '0', but you can use 'N/A' or any text." << endl << endl; cerr << "\t-examples\t" << "Show detailed usage examples." << endl << endl; } -void ShowExamples() +void multiintersect_examples() { cerr << "Example usage:\n\n" \ "== Input files: ==\n" \ diff --git a/src/nucBed/Makefile b/src/nucBed/Makefile index b824c458f891bd43434113957283e84e8374c8bf..95ba76f0686626313adc221d47c83365595fdcd4 100644 --- a/src/nucBed/Makefile +++ b/src/nucBed/Makefile @@ -24,14 +24,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= nucBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/nucBed/nucBedMain.cpp b/src/nucBed/nucBedMain.cpp index f92ddd883d6bca862bc2beea51a7a1f0d8825ad6..a56cf814f6059f289480aac3efd3a304087b6ff1 100644 --- a/src/nucBed/nucBedMain.cpp +++ b/src/nucBed/nucBedMain.cpp @@ -15,16 +15,16 @@ using namespace std; // define our program name -#define PROGRAM_NAME "nucBed" +#define PROGRAM_NAME "bedtools nuc" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void nuc_help(void); -int main(int argc, char* argv[]) { +int nuc_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -53,7 +53,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) nuc_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -101,20 +101,17 @@ int main(int argc, char* argv[]) { NucBed *nuc = new NucBed(fastaDbFile, bedFile, printSeq, hasPattern, pattern, forceStrand); delete nuc; - - return 0; } else { - ShowHelp(); + nuc_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void nuc_help(void) { + cerr << "\nTool: bedtools nuc (aka nucBed)" << endl; + cerr << "Summary: Profiles the nucleotide content of intervals in a fasta file." << endl << endl; cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -fi <fasta> -bed <bed/gff/vcf>" << endl << endl; @@ -124,11 +121,12 @@ void ShowHelp(void) { cerr << "\t-bed\tBED/GFF/VCF file of ranges to extract from -fi" << endl << endl; cerr << "\t-s\tProfile the sequence according to strand." << endl << endl; cerr << "\t-seq\tPrint the extracted sequence" << endl << endl; - cerr << "\t-pattern\tReport the number of times a user-defined sequence is observed (case-insensitive)." << endl << endl; + cerr << "\t-pattern\tReport the number of times a user-defined sequence" << endl; + cerr << "\t\t\tis observed (case-insensitive)." << endl << endl; cerr << "Output format: " << endl; - cerr << "\tThe following information will be reported after each original BED entry:" << endl; + cerr << "\tThe following information will be reported after each BED entry:" << endl; cerr << "\t 1) %AT content" << endl; cerr << "\t 2) %GC content" << endl; cerr << "\t 3) Number of As observed" << endl; @@ -138,9 +136,9 @@ void ShowHelp(void) { cerr << "\t 7) Number of Ns observed" << endl; cerr << "\t 8) Number of other bases observed" << endl; cerr << "\t 9) The length of the explored sequence/interval." << endl; - cerr << "\t 10) The sequence extracted from the FASTA file. (optional, if -seq is used)" << endl; - cerr << "\t 11) The number of times a user defined pattern was observed. (optional, if -pattern is used.)" << endl; - + cerr << "\t 10) The seq. extracted from the FASTA file. (opt., if -seq is used)" << endl; + cerr << "\t 11) The number of times a user's pattern was observed." << endl; + cerr << "\t (opt., if -pattern is used.)" << endl << endl; // end the program here exit(1); diff --git a/src/pairToBed/Makefile b/src/pairToBed/Makefile index 9d94beb499169cbaec07b1ee36ea5f28ed44ac14..015b2aa53df949c94efcdcbdc8279b035be6e2ec 100644 --- a/src/pairToBed/Makefile +++ b/src/pairToBed/Makefile @@ -24,14 +24,10 @@ EXT_OBJECTS=$(patsubst %,$(OBJ_DIR)/%,$(_EXT_OBJECTS)) BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= pairToBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ -L$(UTILITIES_DIR)/BamTools/lib/ -lbamtools $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/pairToBed/pairToBedMain.cpp b/src/pairToBed/pairToBedMain.cpp index 38b8714a13ec6ba0638882961757fb2c0c90c08d..d84ed33f506dbaa578f802ee24f3a7a9f485f4e0 100644 --- a/src/pairToBed/pairToBedMain.cpp +++ b/src/pairToBed/pairToBedMain.cpp @@ -15,15 +15,15 @@ using namespace std; // define our program name -#define PROGRAM_NAME "pairToBed" +#define PROGRAM_NAME "bedtools pairtobed" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void pairtobed_help(void); -int main(int argc, char* argv[]) { +int pairtobed_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -60,7 +60,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) pairtobed_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -160,20 +160,18 @@ int main(int argc, char* argv[]) { searchType, sameStrand, diffStrand, inputIsBam, outputIsBam, uncompressedBam, useEditDistance); delete bi; - return 0; } else { - ShowHelp(); + pairtobed_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; - +void pairtobed_help(void) { + + cerr << "\nTool: bedtools pairtobed (aka pairToBed)" << endl; + cerr << "Summary: Report overlaps between a BEDPE file and a BED/GFF/VCF file." << endl << endl; cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -a <bedpe> -b <bed/gff/vcf>" << endl << endl; @@ -183,7 +181,7 @@ void ShowHelp(void) { cerr << "\t-abam\t" << "The A input file is in BAM format. Output will be BAM as well." << endl; cerr << "\t\t- Requires BAM to be grouped or sorted by query." << endl << endl; - cerr << "\t-ubam\t" << "Write uncompressed BAM output. Default is to write compressed BAM." << endl << endl; + cerr << "\t-ubam\t" << "Write uncompressed BAM output. Default writes compressed BAM." << endl << endl; cerr << "\t\tis to write output in BAM when using -abam." << endl << endl; cerr << "\t-bedpe\t" << "When using BAM input (-abam), write output as BEDPE. The default" << endl; diff --git a/src/pairToPair/Makefile b/src/pairToPair/Makefile index 4d75faaa4c6e850b86c08a89c920a2f543c331e8..0e994bb902837ed3b6b6831a9577eaf346ee03ce 100644 --- a/src/pairToPair/Makefile +++ b/src/pairToPair/Makefile @@ -18,14 +18,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= pairToPair -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/pairToPair/pairToPairMain.cpp b/src/pairToPair/pairToPairMain.cpp index 7f5761d01f25d40438d0f9a2a3fdd54d737ab245..5182df655aafec4c0d6aafcf8c0e8679d4cd2993 100644 --- a/src/pairToPair/pairToPairMain.cpp +++ b/src/pairToPair/pairToPairMain.cpp @@ -15,15 +15,15 @@ using namespace std; // define our program name -#define PROGRAM_NAME "pairToPair" +#define PROGRAM_NAME "bedtools pairtopair" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void pairtopair_help(void); -int main(int argc, char* argv[]) { +int pairtopair_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -58,7 +58,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) pairtopair_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -140,16 +140,16 @@ int main(int argc, char* argv[]) { return 0; } else { - ShowHelp(); + pairtopair_help(); } + return 0; } -void ShowHelp(void) { - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void pairtopair_help(void) { + cerr << "\nTool: bedtools pairtopair (aka pairToPair)" << endl; + cerr << "Summary: Report overlaps between two paired-end BED files (BEDPE)." << endl << endl; cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -a <BEDPE> -b <BEDPE>" << endl << endl; @@ -162,13 +162,14 @@ void ShowHelp(void) { cerr << "\t\tneither\tReport overlaps if neither end of A overlaps B." << endl; cerr << "\t\teither\tReport overlaps if either ends of A overlap B." << endl; cerr << "\t\tboth\tReport overlaps if both ends of A overlap B." << endl; - cerr << "\t\tnotboth\tReport overlaps if one or neither of ends of A overlap B." << endl; + cerr << "\t\tnotboth\tReport overlaps if one or neither of A's overlap B." << endl; cerr << "\t\t- Default = both." << endl << endl; cerr << "\t-slop \t" << "The amount of slop (in b.p.). to be added to each footprint." << endl; - cerr << "\t\t*Note*: Slop is subtracted from start1 and start2 and added to end1 and end2." << endl << endl; - + cerr << "\t\t*Note*: Slop is subtracted from start1 and start2" << endl; + cerr << "\t\t\tand added to end1 and end2." << endl << endl; + cerr << "\t-ss\t" << "Add slop based to each BEDPE footprint based on strand." << endl; cerr << "\t\t- If strand is \"+\", slop is only added to the end coordinates." << endl; cerr << "\t\t- If strand is \"-\", slop is only added to the start coordinates." << endl; diff --git a/src/shuffleBed/Makefile b/src/shuffleBed/Makefile index 0265ae05dc87aed9923a70c257b846858d6db569..a20290cda2d51aabf1dca37b765bae3a925d14c6 100644 --- a/src/shuffleBed/Makefile +++ b/src/shuffleBed/Makefile @@ -24,14 +24,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= shuffleBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/shuffleBed/shuffleBedMain.cpp b/src/shuffleBed/shuffleBedMain.cpp index d731d1a712a752a633e58d13bbaafcdc922bfc1f..38f3dacfc57e899b9401a62e240dc801d422db73 100644 --- a/src/shuffleBed/shuffleBedMain.cpp +++ b/src/shuffleBed/shuffleBedMain.cpp @@ -15,16 +15,16 @@ using namespace std; // define our program name -#define PROGRAM_NAME "shuffleBed" +#define PROGRAM_NAME "bedtools shuffle" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void shuffle_help(void); -int main(int argc, char* argv[]) { +int shuffle_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -54,7 +54,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) shuffle_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -129,16 +129,15 @@ int main(int argc, char* argv[]) { return 0; } else { - ShowHelp(); + shuffle_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void shuffle_help(void) { + cerr << "\nTool: bedtools shuffle (aka shuffleBed)" << endl; + cerr << "Summary: Randomly permute the locations of a feature file among a genome." << endl << endl; cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -i <bed/gff/vcf> -g <genome>" << endl << endl; diff --git a/src/slopBed/Makefile b/src/slopBed/Makefile index aed0b82d0d02fbd6cb6fb086aef7f3dc0733399c..9f8881064ee920f4e07eb4680f983f4a4633883e 100644 --- a/src/slopBed/Makefile +++ b/src/slopBed/Makefile @@ -24,14 +24,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= slopBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/slopBed/slopBedMain.cpp b/src/slopBed/slopBedMain.cpp index b5f148e56dc6aab8aa714a1f7cc45ba8f01ded44..c7d870f1b803482754cfd57faf3f9cdffb4f25e8 100644 --- a/src/slopBed/slopBedMain.cpp +++ b/src/slopBed/slopBedMain.cpp @@ -15,16 +15,16 @@ using namespace std; // define our program name -#define PROGRAM_NAME "slopBed" +#define PROGRAM_NAME "bedtools slop" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void slop_help(void); -int main(int argc, char* argv[]) { +int slop_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -54,7 +54,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) slop_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -136,22 +136,21 @@ int main(int argc, char* argv[]) { return 0; } else { - ShowHelp(); + slop_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void slop_help(void) { + cerr << "\nTool: bedtools slop (aka slopBed)" << endl; + cerr << "Summary: Add requested base pairs of \"slop\" to each feature." << endl << endl; cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -i <bed/gff/vcf> -g <genome> [-b <int> or (-l and -r)]" << endl << endl; cerr << "Options: " << endl; - cerr << "\t-b\t" << "Increase the BED/GFF/VCF entry by -b base pairs in each direction." << endl; + cerr << "\t-b\t" << "Increase the BED/GFF/VCF entry -b base pairs in each direction." << endl; cerr << "\t\t- (Integer) or (Float, e.g. 0.1) if used with -pct." << endl << endl; cerr << "\t-l\t" << "The number of base pairs to subtract from the start coordinate." << endl; diff --git a/src/sortBed/Makefile b/src/sortBed/Makefile index c675e68aa40425ab48cd29799a4548b4e1641075..55037c045aadcc84f4f1c0d0de38eb118d5120a5 100644 --- a/src/sortBed/Makefile +++ b/src/sortBed/Makefile @@ -18,14 +18,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= sortBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/sortBed/sortMain.cpp b/src/sortBed/sortMain.cpp index e58faa207fd66e97b8c51555a405f56120083469..767c9b65f8b6b9c7bcb09680be8c905fee378efb 100644 --- a/src/sortBed/sortMain.cpp +++ b/src/sortBed/sortMain.cpp @@ -15,16 +15,16 @@ using namespace std; // define our program name -#define PROGRAM_NAME "sortBed" +#define PROGRAM_NAME "bedtools sort" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void sort_help(void); -int main(int argc, char* argv[]) { +int sort_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -51,7 +51,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) sort_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -135,15 +135,15 @@ int main(int argc, char* argv[]) { return 0; } else { - ShowHelp(); + sort_help(); } + return 0; } -void ShowHelp(void) { +void sort_help(void) { - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; + cerr << "\nTool: bedtools sort (aka sortBed)" << endl; + cerr << "Summary: Sorts a feature file in various and useful ways." << endl << endl; cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -i <bed/gff/vcf>" << endl << endl; diff --git a/src/subtractBed/Makefile b/src/subtractBed/Makefile index f67ac7b666bf3ed697b4e282bcc0c13708e33903..4d11368aba26a36e80ff7fef392e83ae428d80b0 100644 --- a/src/subtractBed/Makefile +++ b/src/subtractBed/Makefile @@ -22,14 +22,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= subtractBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/subtractBed/subtractMain.cpp b/src/subtractBed/subtractMain.cpp index 58b4b412045027c64fc66bd3efc333dd11cbdcff..8ea557d52f73a513243a79a544050bb847706dd2 100644 --- a/src/subtractBed/subtractMain.cpp +++ b/src/subtractBed/subtractMain.cpp @@ -15,16 +15,16 @@ using namespace std; // define our program name -#define PROGRAM_NAME "subtractBed" +#define PROGRAM_NAME "bedtools subtract" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void subtract_help(void); -int main(int argc, char* argv[]) { +int subtract_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -54,7 +54,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) subtract_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -112,16 +112,15 @@ int main(int argc, char* argv[]) { return 0; } else { - ShowHelp(); + subtract_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void subtract_help(void) { + cerr << "\nTool: bedtools subtract (aka subtractBed)" << endl; + cerr << "Summary: Removes the portion(s) of an interval that is overlapped" << endl; cerr << "\t by another feature(s)." << endl << endl; @@ -132,8 +131,8 @@ void ShowHelp(void) { cerr << "\t\t- Default is 1E-9 (i.e., 1bp)." << endl; cerr << "\t\t- (FLOAT) (e.g. 0.50)" << endl << endl; - cerr << "\t-s\t" << "Require same strandedness. That is, only subtract hits in B that" << endl; - cerr << "\t\toverlap A on the _same_ strand." << endl; + cerr << "\t-s\t" << "Require same strandedness. That is, only subtract hits in B" << endl; + cerr << "\t\tthat overlap A on the _same_ strand." << endl; cerr << "\t\t- By default, overlaps are subtracted without respect to strand." << endl << endl; cerr << "\t-S\t" << "Force strandedness. That is, only subtract hits in B that" << endl; diff --git a/src/tagBam/Makefile b/src/tagBam/Makefile index 35b97a2cc093abd757eef86be6c3a53f0ff69ebf..6b48cc33395d235cf9ca92d663bc48346b9e891c 100644 --- a/src/tagBam/Makefile +++ b/src/tagBam/Makefile @@ -24,14 +24,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= tagBam -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ -L$(UTILITIES_DIR)/BamTools/lib/ -lbamtools $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/tagBam/tagBamMain.cpp b/src/tagBam/tagBamMain.cpp index b4c750dcfdd36bc0c6f79c4da7cc8072ea3b82d1..1a98528092e248d5cd01f073b47d044aaece9eb8 100644 --- a/src/tagBam/tagBamMain.cpp +++ b/src/tagBam/tagBamMain.cpp @@ -15,15 +15,15 @@ using namespace std; // define the version -#define PROGRAM_NAME "tagBam" +#define PROGRAM_NAME "bedtools tag" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void tagbam_help(void); -int main(int argc, char* argv[]) { +int tagbam_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -62,7 +62,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) tagbam_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -188,16 +188,15 @@ int main(int argc, char* argv[]) { return 0; } else { - ShowHelp(); + tagbam_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void tagbam_help(void) { + cerr << "\nTool: bedtools tag (aka tagBam)" << endl; + cerr << "Summary: Annotates a BAM file based on overlaps with multiple BED/GFF/VCF files" << endl; cerr << "\t on the intervals in -i." << endl << endl; diff --git a/src/unionBedGraphs/Makefile b/src/unionBedGraphs/Makefile index bca92f26e0c9ab1ed2d6ce567a39968d62e3b82a..56622af088641b36548c1dcc57eead49bc07afac 100755 --- a/src/unionBedGraphs/Makefile +++ b/src/unionBedGraphs/Makefile @@ -23,14 +23,10 @@ EXT_OBJECTS=$(patsubst %,$(OBJ_DIR)/%,$(_EXT_OBJECTS)) BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= unionBedGraphs -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/unionBedGraphs/unionBedGraphsMain.cpp b/src/unionBedGraphs/unionBedGraphsMain.cpp index b140b013d84b74ce2d5a2c27337431072b07d21c..69c7546ba51b1cbbb92cdd33c4469147d3126553 100644 --- a/src/unionBedGraphs/unionBedGraphsMain.cpp +++ b/src/unionBedGraphs/unionBedGraphsMain.cpp @@ -26,7 +26,7 @@ using namespace std; // define our program name -#define PROGRAM_NAME "unionBedGraphs" +#define PROGRAM_NAME "bedtools unionbedg" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) @@ -34,14 +34,14 @@ using namespace std; //STLized version of basename() // (because POSIX basename() modifies the input string pointer) // Additionally: removes any extension the basename might have. -std::string stl_basename(const std::string& path); +std::string ubg_stl_basename(const std::string& path); // function declarations -void ShowHelp(void); -void ShowExamples(void); +void unionbedgraphs_help(void); +void unionbedgraphs_showexamples(void); -int main(int argc, char* argv[]) +int unionbedgraphs_main(int argc, char* argv[]) { bool haveFiles = false; bool haveTitles = false; @@ -58,7 +58,7 @@ int main(int argc, char* argv[]) //Parse command line options if(argc <= 1) - ShowHelp(); + unionbedgraphs_help(); for(int i = 1; i < argc; i++) { int parameterLength = (int)strlen(argv[i]); @@ -70,7 +70,7 @@ int main(int argc, char* argv[]) } if(showHelp == true) { - ShowHelp(); + unionbedgraphs_help(); exit(1); } @@ -128,8 +128,8 @@ int main(int argc, char* argv[]) printEmptyRegions = true; } else if(PARAMETER_CHECK("-examples", 9, parameterLength)) { - ShowHelp(); - ShowExamples(); + unionbedgraphs_help(); + unionbedgraphs_showexamples(); exit(1); } } @@ -156,15 +156,14 @@ int main(int argc, char* argv[]) if (printHeader) ubg.PrintHeader(); ubg.Union(); + + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Authors: Assaf Gordon, CSHL" << endl; - cerr << " Aaron Quinlan (aaronquinlan@gmail.com)" << endl << endl; +void unionbedgraphs_help(void) { + cerr << "\nTool: bedtools unionbedg (aka unionBedGraphs)" << endl; + cerr << "Summary: Combines multiple BedGraph files into a single file," << endl; cerr << "\t allowing coverage comparisons between them." << endl << endl; @@ -177,7 +176,7 @@ void ShowHelp(void) { cerr << "\t-header\t\t" << "Print a header line." << endl; cerr << "\t\t\t(chrom/start/end + names of each file)." << endl << endl; - cerr << "\t-names\t\t" << "A list of names (one / file) to describe each file in -i." << endl; + cerr << "\t-names\t\t" << "A list of names (one/file) to describe each file in -i." << endl; cerr << "\t\t\tThese names will be printed in the header line." << endl << endl; cerr << "\t-g\t\t" << "Use genome file to calculate empty regions." << endl; @@ -188,14 +187,14 @@ void ShowHelp(void) { cerr << "\t\t\t- Requires the '-g FILE' parameter.\n" << endl; cerr << "\t-filler TEXT\t" << "Use TEXT when representing intervals having no value." << endl; - cerr << "\t\t\t- Default is '0', but you can use 'N/A' or any other text." << endl << endl; + cerr << "\t\t\t- Default is '0', but you can use 'N/A' or any text." << endl << endl; cerr << "\t-examples\t" << "Show detailed usage examples." << endl << endl; } -void ShowExamples() +void unionbedgraphs_showexamples() { cerr << "Example usage:\n\n" \ "== Input files: ==\n" \ @@ -276,7 +275,7 @@ void ShowExamples() ; } -std::string stl_basename(const std::string& path) +std::string ubg_stl_basename(const std::string& path) { string result; diff --git a/src/utils/BamTools/include/api/BamAlignment.h b/src/utils/BamTools/include/api/BamAlignment.h new file mode 100644 index 0000000000000000000000000000000000000000..7535d93f8f7a8fcd1062348b7d406a4082fa0abe --- /dev/null +++ b/src/utils/BamTools/include/api/BamAlignment.h @@ -0,0 +1,207 @@ +// *************************************************************************** +// BamAlignment.h (c) 2009 Derek Barnett +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 22 April 2011 (DB) +// --------------------------------------------------------------------------- +// Provides the BamAlignment data structure +// *************************************************************************** + +#ifndef BAMALIGNMENT_H +#define BAMALIGNMENT_H + +#include <api/api_global.h> +#include <api/BamAux.h> +#include <string> +#include <vector> + +namespace BamTools { + +// forward declaration of BamAlignment's friend classes +namespace Internal { + class BamReaderPrivate; + class BamWriterPrivate; +} // namespace Internal + +// BamAlignment data structure +struct API_EXPORT BamAlignment { + + // constructors & destructor + public: + BamAlignment(void); + BamAlignment(const BamAlignment& other); + ~BamAlignment(void); + + // queries against alignment flags + public: + bool IsDuplicate(void) const; // returns true if this read is a PCR duplicate + bool IsFailedQC(void) const; // returns true if this read failed quality control + bool IsFirstMate(void) const; // returns true if alignment is first mate on read + bool IsMapped(void) const; // returns true if alignment is mapped + bool IsMateMapped(void) const; // returns true if alignment's mate is mapped + bool IsMateReverseStrand(void) const; // returns true if alignment's mate mapped to reverse strand + bool IsPaired(void) const; // returns true if alignment part of paired-end read + bool IsPrimaryAlignment(void) const; // returns true if reported position is primary alignment + bool IsProperPair(void) const; // returns true if alignment is part of read that satisfied paired-end resolution + bool IsReverseStrand(void) const; // returns true if alignment mapped to reverse strand + bool IsSecondMate(void) const; // returns true if alignment is second mate on read + + // manipulate alignment flags + public: + void SetIsDuplicate(bool ok); // sets value of "PCR duplicate" flag + void SetIsFailedQC(bool ok); // sets value of "failed quality control" flag + void SetIsFirstMate(bool ok); // sets value of "alignment is first mate" flag + void SetIsMapped(bool ok); // sets value of "alignment is mapped" flag + void SetIsMateMapped(bool ok); // sets value of "alignment's mate is mapped" flag + void SetIsMateReverseStrand(bool ok); // sets value of "alignment's mate mapped to reverse strand" flag + void SetIsPaired(bool ok); // sets value of "alignment part of paired-end read" flag + void SetIsPrimaryAlignment(bool ok); // sets value of "position is primary alignment" flag + void SetIsProperPair(bool ok); // sets value of "alignment is part of read that satisfied paired-end resolution" flag + void SetIsReverseStrand(bool ok); // sets value of "alignment mapped to reverse strand" flag + void SetIsSecondMate(bool ok); // sets value of "alignment is second mate on read" flag + + // legacy methods (consider deprecated, but still available) + void SetIsMateUnmapped(bool ok); // complement of using SetIsMateMapped() + void SetIsSecondaryAlignment(bool ok); // complement of using SetIsPrimaryAlignment() + void SetIsUnmapped(bool ok); // complement of using SetIsMapped() + + // tag data access methods + public: + + // ------------------------------------------------------------------------------------- + // N.B. - The following tag access methods may not be used on BamAlignments fetched + // using BamReader::GetNextAlignmentCore(). Attempting to use them will not result in + // error message (to keep output clean) but will ALWAYS return false. Only user-created + // BamAlignments or those retrieved using BamReader::GetNextAlignment() are valid here. + // + // You can call BuildCharData() on such an alignment retrieved by GetNextAlignmentCore(). + // This populates all the character data, and will enable subsequent queries on tag data. + // ------------------------------------------------------------------------------------- + + // adds a tag + bool AddTag(const std::string& tag, const std::string& type, const std::string& value); + bool AddTag(const std::string& tag, const std::string& type, const uint32_t& value); + bool AddTag(const std::string& tag, const std::string& type, const int32_t& value); + bool AddTag(const std::string& tag, const std::string& type, const float& value); + + // adds a "binary array" tag + bool AddTag(const std::string& tag, const std::vector<uint8_t>& values); + bool AddTag(const std::string& tag, const std::vector<int8_t>& values); + bool AddTag(const std::string& tag, const std::vector<uint16_t>& values); + bool AddTag(const std::string& tag, const std::vector<int16_t>& values); + bool AddTag(const std::string& tag, const std::vector<uint32_t>& values); + bool AddTag(const std::string& tag, const std::vector<int32_t>& values); + bool AddTag(const std::string& tag, const std::vector<float>& values); + + // edits a tag + bool EditTag(const std::string& tag, const std::string& type, const std::string& value); + bool EditTag(const std::string& tag, const std::string& type, const uint32_t& value); + bool EditTag(const std::string& tag, const std::string& type, const int32_t& value); + bool EditTag(const std::string& tag, const std::string& type, const float& value); + + // edits a "binary array" tag + bool EditTag(const std::string& tag, const std::vector<uint8_t>& values); + bool EditTag(const std::string& tag, const std::vector<int8_t>& values); + bool EditTag(const std::string& tag, const std::vector<uint16_t>& values); + bool EditTag(const std::string& tag, const std::vector<int16_t>& values); + bool EditTag(const std::string& tag, const std::vector<uint32_t>& values); + bool EditTag(const std::string& tag, const std::vector<int32_t>& values); + bool EditTag(const std::string& tag, const std::vector<float>& values); + + // retrieves data for a tag + bool GetTag(const std::string& tag, std::string& destination) const; + bool GetTag(const std::string& tag, uint32_t& destination) const; + bool GetTag(const std::string& tag, int32_t& destination) const; + bool GetTag(const std::string& tag, float& destination) const; + + // retrieves data for a "binary array" tag + bool GetTag(const std::string& tag, std::vector<uint32_t>& destination) const; + bool GetTag(const std::string& tag, std::vector<int32_t>& destination) const; + bool GetTag(const std::string& tag, std::vector<float>& destination) const; + + // retrieves the BAM tag-type character for a tag + bool GetTagType(const std::string& tag, char& type) const; + + // legacy methods (consider deprecated, but still available) + bool GetEditDistance(uint32_t& editDistance) const; // retrieves value of "NM" tag + bool GetReadGroup(std::string& readGroup) const; // retrieves value of "RG" tag + + // returns true if alignment has a record for this tag name + bool HasTag(const std::string& tag) const; + + // removes a tag + bool RemoveTag(const std::string& tag); + + // additional methods + public: + // populates alignment string fields + bool BuildCharData(void); + // calculates alignment end position + int GetEndPosition(bool usePadded = false, bool zeroBased = true) const; + + // public data fields + public: + std::string Name; // read name + int32_t Length; // length of query sequence + std::string QueryBases; // 'original' sequence (as reported from sequencing machine) + std::string AlignedBases; // 'aligned' sequence (includes any indels, padding, clipping) + std::string Qualities; // FASTQ qualities (ASCII characters, not numeric values) + std::string TagData; // tag data (use provided methods to query/modify) + int32_t RefID; // ID number for reference sequence + int32_t Position; // position (0-based) where alignment starts + uint16_t Bin; // BAM (standard) index bin number for this alignment + uint16_t MapQuality; // mapping quality score + uint32_t AlignmentFlag; // alignment bit-flag (use provided methods to query/modify) + std::vector<CigarOp> CigarData; // CIGAR operations for this alignment + int32_t MateRefID; // ID number for reference sequence where alignment's mate was aligned + int32_t MatePosition; // position (0-based) where alignment's mate starts + int32_t InsertSize; // mate-pair insert size + std::string Filename; // name of BAM file which this alignment comes from + + //! \cond + // internal utility methods + private: + bool FindTag(const std::string& tag, + char*& pTagData, + const unsigned int& tagDataLength, + unsigned int& numBytesParsed) const; + bool IsValidSize(const std::string& tag, + const std::string& type) const; + bool SkipToNextTag(const char storageType, + char*& pTagData, + unsigned int& numBytesParsed) const; + + // internal data + private: + + struct BamAlignmentSupportData { + + // data members + std::string AllCharData; + uint32_t BlockLength; + uint32_t NumCigarOperations; + uint32_t QueryNameLength; + uint32_t QuerySequenceLength; + bool HasCoreOnly; + + // constructor + BamAlignmentSupportData(void) + : BlockLength(0) + , NumCigarOperations(0) + , QueryNameLength(0) + , QuerySequenceLength(0) + , HasCoreOnly(false) + { } + }; + BamAlignmentSupportData SupportData; + friend class Internal::BamReaderPrivate; + friend class Internal::BamWriterPrivate; + //! \endcond +}; + +typedef std::vector<BamAlignment> BamAlignmentVector; + +} // namespace BamTools + +#endif // BAMALIGNMENT_H diff --git a/src/utils/BamTools/include/api/BamAux.h b/src/utils/BamTools/include/api/BamAux.h new file mode 100644 index 0000000000000000000000000000000000000000..d171e7069db998da82ac346689cea68fee068611 --- /dev/null +++ b/src/utils/BamTools/include/api/BamAux.h @@ -0,0 +1,457 @@ +// *************************************************************************** +// BamAux.h (c) 2009 Derek Barnett, Michael Str�mberg +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 4 March 2011 (DB) +// --------------------------------------------------------------------------- +// Provides data structures & utility methods that are used throughout the API. +// *************************************************************************** + +#ifndef BAMAUX_H +#define BAMAUX_H + +#include <api/api_global.h> +#include <fstream> +#include <iostream> +#include <string> +#include <vector> + +/*! \file BamAux.h + + Provides data structures & utility methods that are used throughout the API. +*/ +/*! \namespace BamTools + \brief Contains all BamTools classes & methods. + + The BamTools API contained in this namespace contains classes and methods + for reading, writing, and manipulating BAM alignment files. +*/ +namespace BamTools { + +// ---------------------------------------------------------------- +// CigarOp + +/*! \struct BamTools::CigarOp + \brief Represents a CIGAR alignment operation. + + \sa http://samtools.sourceforge.net/SAM-1.3.pdf for more details on using CIGAR operations. +*/ +struct API_EXPORT CigarOp { + + char Type; //!< CIGAR operation type (MIDNSHP) + uint32_t Length; //!< CIGAR operation length (number of bases) + + //! constructor + CigarOp(const char type = '\0', + const uint32_t& length = 0) + : Type(type) + , Length(length) + { } +}; + +// ---------------------------------------------------------------- +// RefData + +/*! \struct BamTools::RefData + \brief Represents a reference sequence entry +*/ +struct API_EXPORT RefData { + + std::string RefName; //!< name of reference sequence + int32_t RefLength; //!< length of reference sequence + + //! constructor + RefData(const std::string& name = "", + const int32_t& length = 0) + : RefName(name) + , RefLength(length) + { } +}; + +//! convenience typedef for vector of RefData entries +typedef std::vector<RefData> RefVector; + +// ---------------------------------------------------------------- +// BamRegion + +/*! \struct BamTools::BamRegion + \brief Represents a sequential genomic region + + Allowed to span multiple (sequential) references. +*/ +struct API_EXPORT BamRegion { + + int LeftRefID; //!< reference ID for region's left boundary + int LeftPosition; //!< position for region's left boundary + int RightRefID; //!< reference ID for region's right boundary + int RightPosition; //!< position for region's right boundary + + //! constructor + BamRegion(const int& leftID = -1, + const int& leftPos = -1, + const int& rightID = -1, + const int& rightPos = -1) + : LeftRefID(leftID) + , LeftPosition(leftPos) + , RightRefID(rightID) + , RightPosition(rightPos) + { } + + //! copy constructor + BamRegion(const BamRegion& other) + : LeftRefID(other.LeftRefID) + , LeftPosition(other.LeftPosition) + , RightRefID(other.RightRefID) + , RightPosition(other.RightPosition) + { } + + //! Clears region boundaries + void clear(void) { + LeftRefID = -1; LeftPosition = -1; + RightRefID = -1; RightPosition = -1; + } + + //! Returns true if region has a left boundary + bool isLeftBoundSpecified(void) const { + return ( LeftRefID >= 0 && LeftPosition >= 0 ); + } + + //! Returns true if region boundaries are not defined + bool isNull(void) const { + return ( !isLeftBoundSpecified() && !isRightBoundSpecified() ); + } + + //! Returns true if region has a right boundary + bool isRightBoundSpecified(void) const { + return ( RightRefID >= 0 && RightPosition >= 0 ); + } +}; + +// ---------------------------------------------------------------- +// General utility methods + +/*! \fn bool FileExists(const std::string& filename) + \brief checks if file exists + + Attempts to open file in a read-only mode. + + \return \c true if file can be opened successfully +*/ +API_EXPORT inline bool FileExists(const std::string& filename) { + std::ifstream f(filename.c_str(), std::ifstream::in); + return !f.fail(); +} + +/*! \fn void SwapEndian_16(int16_t& x) + \brief swaps endianness of signed 16-bit integer, in place + + Swaps endian representation of value in \a x. +*/ +API_EXPORT inline void SwapEndian_16(int16_t& x) { + x = ((x >> 8) | (x << 8)); +} + +/*! \fn void SwapEndian_16(uint16_t& x) + \brief swaps endianness of unsigned 16-bit integer, in place + + Swaps endian representation of value in \a x. +*/ +API_EXPORT inline void SwapEndian_16(uint16_t& x) { + x = ((x >> 8) | (x << 8)); +} + +/*! \fn void SwapEndian_32(int32_t& x) + \brief swaps endianness of signed 32-bit integer, in place + + Swaps endian representation of value in \a x. +*/ +API_EXPORT inline void SwapEndian_32(int32_t& x) { + x = ( (x >> 24) | + ((x << 8) & 0x00FF0000) | + ((x >> 8) & 0x0000FF00) | + (x << 24) + ); +} + +/*! \fn void SwapEndian_32(uint32_t& x) + \brief swaps endianness of unsigned 32-bit integer, in place + + Swaps endian representation of value in \a x. +*/ +API_EXPORT inline void SwapEndian_32(uint32_t& x) { + x = ( (x >> 24) | + ((x << 8) & 0x00FF0000) | + ((x >> 8) & 0x0000FF00) | + (x << 24) + ); +} + +/*! \fn void SwapEndian_64(int64_t& x) + \brief swaps endianness of signed 64-bit integer, in place + + Swaps endian representation of value in \a x. +*/ +API_EXPORT inline void SwapEndian_64(int64_t& x) { + x = ( (x >> 56) | + ((x << 40) & 0x00FF000000000000ll) | + ((x << 24) & 0x0000FF0000000000ll) | + ((x << 8) & 0x000000FF00000000ll) | + ((x >> 8) & 0x00000000FF000000ll) | + ((x >> 24) & 0x0000000000FF0000ll) | + ((x >> 40) & 0x000000000000FF00ll) | + (x << 56) + ); +} + +/*! \fn void SwapEndian_64(uint64_t& x) + \brief swaps endianness of unsigned 64-bit integer, in place + + Swaps endian representation of value in \a x. +*/ +API_EXPORT inline void SwapEndian_64(uint64_t& x) { + x = ( (x >> 56) | + ((x << 40) & 0x00FF000000000000ll) | + ((x << 24) & 0x0000FF0000000000ll) | + ((x << 8) & 0x000000FF00000000ll) | + ((x >> 8) & 0x00000000FF000000ll) | + ((x >> 24) & 0x0000000000FF0000ll) | + ((x >> 40) & 0x000000000000FF00ll) | + (x << 56) + ); +} + +/*! \fn void SwapEndian_16p(char* data) + \brief swaps endianness of the next 2 bytes in a buffer, in place + + Swaps endian representation the next 2 bytes in \a data. +*/ +API_EXPORT inline void SwapEndian_16p(char* data) { + uint16_t& value = (uint16_t&)*data; + SwapEndian_16(value); +} + +/*! \fn void SwapEndian_32p(char* data) + \brief swaps endianness of the next 4 bytes in a buffer, in place + + Swaps endian representation the next 4 bytes in \a data. +*/ +API_EXPORT inline void SwapEndian_32p(char* data) { + uint32_t& value = (uint32_t&)*data; + SwapEndian_32(value); +} + +/*! \fn void SwapEndian_64p(char* data) + \brief swaps endianness of the next 8 bytes in a buffer, in place + + Swaps endian representation the next 8 bytes in \a data. +*/ +API_EXPORT inline void SwapEndian_64p(char* data) { + uint64_t& value = (uint64_t&)*data; + SwapEndian_64(value); +} + +/*! \fn bool SystemIsBigEndian(void) + \brief checks host architecture's byte order + \return \c true if system uses big-endian ordering +*/ +API_EXPORT inline bool SystemIsBigEndian(void) { + const uint16_t one = 0x0001; + return ((*(char*) &one) == 0 ); +} + +/*! \fn void PackUnsignedInt(char* buffer, unsigned int value) + \brief stores unsigned integer value in a byte buffer + + \param buffer destination buffer + \param value unsigned integer to 'pack' in buffer +*/ +API_EXPORT inline void PackUnsignedInt(char* buffer, unsigned int value) { + buffer[0] = (char)value; + buffer[1] = (char)(value >> 8); + buffer[2] = (char)(value >> 16); + buffer[3] = (char)(value >> 24); +} + +/*! \fn void PackUnsignedShort(char* buffer, unsigned short value) + \brief stores unsigned short integer value in a byte buffer + + \param buffer destination buffer + \param value unsigned short integer to 'pack' in buffer +*/ +API_EXPORT inline void PackUnsignedShort(char* buffer, unsigned short value) { + buffer[0] = (char)value; + buffer[1] = (char)(value >> 8); +} + +/*! \fn double UnpackDouble(const char* buffer) + \brief reads a double value from byte buffer + + \param buffer source byte buffer + \return the (double) value read from the buffer +*/ +API_EXPORT inline double UnpackDouble(const char* buffer) { + union { double value; unsigned char valueBuffer[sizeof(double)]; } un; + un.value = 0; + un.valueBuffer[0] = buffer[0]; + un.valueBuffer[1] = buffer[1]; + un.valueBuffer[2] = buffer[2]; + un.valueBuffer[3] = buffer[3]; + un.valueBuffer[4] = buffer[4]; + un.valueBuffer[5] = buffer[5]; + un.valueBuffer[6] = buffer[6]; + un.valueBuffer[7] = buffer[7]; + return un.value; +} + +/*! \fn double UnpackDouble(char* buffer) + \brief reads a double value from byte buffer + + This is an overloaded function. + + \param buffer source byte buffer + \return the (double) value read from the buffer +*/ +API_EXPORT inline double UnpackDouble(char* buffer) { + return UnpackDouble( (const char*)buffer ); +} + +/*! \fn double UnpackFloat(const char* buffer) + \brief reads a float value from byte buffer + + \param buffer source byte buffer + \return the (float) value read from the buffer +*/ +API_EXPORT inline float UnpackFloat(const char* buffer) { + union { float value; unsigned char valueBuffer[sizeof(float)]; } un; + un.value = 0; + un.valueBuffer[0] = buffer[0]; + un.valueBuffer[1] = buffer[1]; + un.valueBuffer[2] = buffer[2]; + un.valueBuffer[3] = buffer[3]; + return un.value; +} + +/*! \fn double UnpackFloat(char* buffer) + \brief reads a float value from byte buffer + + This is an overloaded function. + + \param buffer source byte buffer + \return the (float) value read from the buffer +*/ +API_EXPORT inline float UnpackFloat(char* buffer) { + return UnpackFloat( (const char*)buffer ); +} + +/*! \fn signed int UnpackSignedInt(const char* buffer) + \brief reads a signed integer value from byte buffer + + \param buffer source byte buffer + \return the (signed int) value read from the buffer +*/ +API_EXPORT inline signed int UnpackSignedInt(const char* buffer) { + union { signed int value; unsigned char valueBuffer[sizeof(signed int)]; } un; + un.value = 0; + un.valueBuffer[0] = buffer[0]; + un.valueBuffer[1] = buffer[1]; + un.valueBuffer[2] = buffer[2]; + un.valueBuffer[3] = buffer[3]; + return un.value; +} + +/*! \fn signed int UnpackSignedInt(char* buffer) + \brief reads a signed integer value from byte buffer + + This is an overloaded function. + + \param buffer source byte buffer + \return the (signed int) value read from the buffer +*/ +API_EXPORT inline signed int UnpackSignedInt(char* buffer) { + return UnpackSignedInt( (const char*) buffer ); +} + +/*! \fn signed short UnpackSignedShort(const char* buffer) + \brief reads a signed short integer value from byte buffer + + \param buffer source byte buffer + \return the (signed short) value read from the buffer +*/ +API_EXPORT inline signed short UnpackSignedShort(const char* buffer) { + union { signed short value; unsigned char valueBuffer[sizeof(signed short)]; } un; + un.value = 0; + un.valueBuffer[0] = buffer[0]; + un.valueBuffer[1] = buffer[1]; + return un.value; +} + +/*! \fn signed short UnpackSignedShort(char* buffer) + \brief reads a signed short integer value from byte buffer + + This is an overloaded function. + + \param buffer source byte buffer + \return the (signed short) value read from the buffer +*/ +API_EXPORT inline signed short UnpackSignedShort(char* buffer) { + return UnpackSignedShort( (const char*)buffer ); +} + +/*! \fn unsigned int UnpackUnsignedInt(const char* buffer) + \brief reads an unsigned integer value from byte buffer + + \param buffer source byte buffer + \return the (unsigned int) value read from the buffer +*/ +API_EXPORT inline unsigned int UnpackUnsignedInt(const char* buffer) { + union { unsigned int value; unsigned char valueBuffer[sizeof(unsigned int)]; } un; + un.value = 0; + un.valueBuffer[0] = buffer[0]; + un.valueBuffer[1] = buffer[1]; + un.valueBuffer[2] = buffer[2]; + un.valueBuffer[3] = buffer[3]; + return un.value; +} + +/*! \fn unsigned int UnpackUnsignedInt(char* buffer) + \brief reads an unsigned integer value from byte buffer + + This is an overloaded function. + + \param buffer source byte buffer + \return the (unsigned int) value read from the buffer +*/ +API_EXPORT inline unsigned int UnpackUnsignedInt(char* buffer) { + return UnpackUnsignedInt( (const char*)buffer ); +} + +/*! \fn unsigned short UnpackUnsignedShort(const char* buffer) + \brief reads an unsigned short integer value from byte buffer + + \param buffer source byte buffer + \return the (unsigned short) value read from the buffer +*/ +API_EXPORT inline unsigned short UnpackUnsignedShort(const char* buffer) { + union { unsigned short value; unsigned char valueBuffer[sizeof(unsigned short)]; } un; + un.value = 0; + un.valueBuffer[0] = buffer[0]; + un.valueBuffer[1] = buffer[1]; + return un.value; +} + +/*! \fn unsigned short UnpackUnsignedShort(char* buffer) + \brief reads an unsigned short integer value from byte buffer + + This is an overloaded function. + + \param buffer source byte buffer + \return the (unsigned short) value read from the buffer +*/ +API_EXPORT inline unsigned short UnpackUnsignedShort(char* buffer) { + return UnpackUnsignedShort( (const char*)buffer ); +} + +} // namespace BamTools + +#endif // BAMAUX_H diff --git a/src/utils/BamTools/include/api/BamConstants.h b/src/utils/BamTools/include/api/BamConstants.h new file mode 100644 index 0000000000000000000000000000000000000000..e433c8e79df37d318a6f4a9c7b94b060494b9a92 --- /dev/null +++ b/src/utils/BamTools/include/api/BamConstants.h @@ -0,0 +1,128 @@ +// *************************************************************************** +// BamConstants.h (c) 2011 Derek Barnett +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 19 April 2011 (DB) +// --------------------------------------------------------------------------- +// Provides basic constants for handling BAM files. +// *************************************************************************** + +#ifndef BAM_CONSTANTS_H +#define BAM_CONSTANTS_H + +#include <string> + +/*! \namespace BamTools::Constants + \brief Provides basic constants for handling BAM files. +*/ + +namespace BamTools { +namespace Constants { + +const int BAM_SIZEOF_INT = 4; + +// header magic number +const char* const BAM_HEADER_MAGIC = "BAM\1"; +const unsigned int BAM_HEADER_MAGIC_LENGTH = 4; + +// BAM alignment core size +const int BAM_CORE_SIZE = 32; +const int BAM_CORE_BUFFER_SIZE = 8; + +// BAM alignment flags +const int BAM_ALIGNMENT_PAIRED = 0x0001; +const int BAM_ALIGNMENT_PROPER_PAIR = 0x0002; +const int BAM_ALIGNMENT_UNMAPPED = 0x0004; +const int BAM_ALIGNMENT_MATE_UNMAPPED = 0x0008; +const int BAM_ALIGNMENT_REVERSE_STRAND = 0x0010; +const int BAM_ALIGNMENT_MATE_REVERSE_STRAND = 0x0020; +const int BAM_ALIGNMENT_READ_1 = 0x0040; +const int BAM_ALIGNMENT_READ_2 = 0x0080; +const int BAM_ALIGNMENT_SECONDARY = 0x0100; +const int BAM_ALIGNMENT_QC_FAILED = 0x0200; +const int BAM_ALIGNMENT_DUPLICATE = 0x0400; + +// CIGAR constants +const char* const BAM_CIGAR_LOOKUP = "MIDNSHP=X"; +const int BAM_CIGAR_MATCH = 0; +const int BAM_CIGAR_INS = 1; +const int BAM_CIGAR_DEL = 2; +const int BAM_CIGAR_REFSKIP = 3; +const int BAM_CIGAR_SOFTCLIP = 4; +const int BAM_CIGAR_HARDCLIP = 5; +const int BAM_CIGAR_PAD = 6; +const int BAM_CIGAR_SEQMATCH = 7; +const int BAM_CIGAR_MISMATCH = 8; + +const char BAM_CIGAR_MATCH_CHAR = 'M'; +const char BAM_CIGAR_INS_CHAR = 'I'; +const char BAM_CIGAR_DEL_CHAR = 'D'; +const char BAM_CIGAR_REFSKIP_CHAR = 'N'; +const char BAM_CIGAR_SOFTCLIP_CHAR = 'S'; +const char BAM_CIGAR_HARDCLIP_CHAR = 'H'; +const char BAM_CIGAR_PAD_CHAR = 'P'; +const char BAM_CIGAR_SEQMATCH_CHAR = '='; +const char BAM_CIGAR_MISMATCH_CHAR = 'X'; + +const int BAM_CIGAR_SHIFT = 4; +const int BAM_CIGAR_MASK = ((1 << BAM_CIGAR_SHIFT) - 1); + +// BAM tag types +const char BAM_TAG_TYPE_ASCII = 'A'; +const char BAM_TAG_TYPE_UINT8 = 'c'; +const char BAM_TAG_TYPE_INT8 = 'C'; +const char BAM_TAG_TYPE_UINT16 = 's'; +const char BAM_TAG_TYPE_INT16 = 'S'; +const char BAM_TAG_TYPE_UINT32 = 'i'; +const char BAM_TAG_TYPE_INT32 = 'I'; +const char BAM_TAG_TYPE_FLOAT = 'f'; +const char BAM_TAG_TYPE_STRING = 'Z'; +const char BAM_TAG_TYPE_HEX = 'H'; +const char BAM_TAG_TYPE_ARRAY = 'B'; + +const size_t BAM_TAG_TAGSIZE = 2; +const size_t BAM_TAG_TYPESIZE = 1; +const int BAM_TAG_ARRAYBASE_SIZE = 8; + +// DNA bases +const char* const BAM_DNA_LOOKUP = "=ACMGRSVTWYHKDBN"; +const unsigned char BAM_BASECODE_EQUAL = 0; +const unsigned char BAM_BASECODE_A = 1; +const unsigned char BAM_BASECODE_C = 2; +const unsigned char BAM_BASECODE_G = 4; +const unsigned char BAM_BASECODE_T = 8; +const unsigned char BAM_BASECODE_N = 15; + +const char BAM_DNA_EQUAL = '='; +const char BAM_DNA_A = 'A'; +const char BAM_DNA_C = 'C'; +const char BAM_DNA_G = 'G'; +const char BAM_DNA_T = 'T'; +const char BAM_DNA_N = 'N'; +const char BAM_DNA_DEL = '-'; +const char BAM_DNA_PAD = '*'; + +// zlib constants +const int GZIP_ID1 = 31; +const int GZIP_ID2 = 139; +const int CM_DEFLATE = 8; +const int FLG_FEXTRA = 4; +const int OS_UNKNOWN = 255; +const int BGZF_XLEN = 6; +const int BGZF_ID1 = 66; +const int BGZF_ID2 = 67; +const int BGZF_LEN = 2; +const int GZIP_WINDOW_BITS = -15; +const int Z_DEFAULT_MEM_LEVEL = 8; + +// BZGF constants +const int BGZF_BLOCK_HEADER_LENGTH = 18; +const int BGZF_BLOCK_FOOTER_LENGTH = 8; +const int BGZF_MAX_BLOCK_SIZE = 65536; +const int BGZF_DEFAULT_BLOCK_SIZE = 65536; + +} // namespace Constants +} // namespace BamTools + +#endif // BAM_CONSTANTS_H diff --git a/src/utils/BamTools/include/api/BamIndex.h b/src/utils/BamTools/include/api/BamIndex.h new file mode 100644 index 0000000000000000000000000000000000000000..00a8f0174458f542268944d30aa39997400d0338 --- /dev/null +++ b/src/utils/BamTools/include/api/BamIndex.h @@ -0,0 +1,80 @@ +// *************************************************************************** +// BamIndex.h (c) 2009 Derek Barnett +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 5 April 2011 (DB) +// --------------------------------------------------------------------------- +// Provides basic BAM index interface +// *************************************************************************** + +#ifndef BAM_INDEX_H +#define BAM_INDEX_H + +#include <api/api_global.h> +#include <api/BamAux.h> +#include <string> + +namespace BamTools { + +namespace Internal { + class BamReaderPrivate; +} // namespace Internal + +/*! \class BamTools::BamIndex + \brief Provides methods for generating & loading BAM index files. + + This class straddles the line between public API and internal + implementation detail. Most client code should never have to use this + class directly. + + It is exposed to the public API to allow advanced users to implement + their own custom indexing schemes. + + More documentation on methods & enums coming soon. +*/ + +class API_EXPORT BamIndex { + + // enums + public: + // specify index-caching behavior + enum IndexCacheMode { FullIndexCaching = 0 // store entire index file contents in memory + , LimitedIndexCaching // store only index data for current reference + , NoIndexCaching // do not store any index data between jumps + }; + + // list of supported BamIndex types + enum IndexType { BAMTOOLS = 0 + , STANDARD + }; + + // ctor & dtor + public: + BamIndex(Internal::BamReaderPrivate* reader) : m_reader(reader) { } + virtual ~BamIndex(void) { } + + // index interface + public: + // builds index from associated BAM file & writes out to index file + virtual bool Create(void) =0; // creates index file from BAM file + // returns whether reference has alignments or no + virtual bool HasAlignments(const int& referenceID) const =0; + // attempts to use index data to jump to @region, returns success/fail + // a "successful" jump indicates no error, but not whether this region has data + // * thus, the method sets a flag to indicate whether there are alignments + // available after the jump position + virtual bool Jump(const BamTools::BamRegion& region, bool* hasAlignmentsInRegion) =0; + // loads existing data from file into memory + virtual bool Load(const std::string& filename) =0; + // change the index caching behavior + virtual void SetCacheMode(const BamIndex::IndexCacheMode& mode) =0; + + // data members + protected: + Internal::BamReaderPrivate* m_reader; // copy, not ownedprivate: +}; + +} // namespace BamTools + +#endif // BAM_INDEX_H diff --git a/src/utils/BamTools/include/api/BamMultiReader.h b/src/utils/BamTools/include/api/BamMultiReader.h new file mode 100644 index 0000000000000000000000000000000000000000..cc49ec8eb2076469be2585bdf978bd603acec8a3 --- /dev/null +++ b/src/utils/BamTools/include/api/BamMultiReader.h @@ -0,0 +1,127 @@ +// *************************************************************************** +// BamMultiReader.h (c) 2010 Erik Garrison, Derek Barnett +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 15 March 2011 (DB) +// --------------------------------------------------------------------------- +// Convenience class for reading multiple BAM files. +// *************************************************************************** + +#ifndef BAMMULTIREADER_H +#define BAMMULTIREADER_H + +#include <api/api_global.h> +#include <api/BamReader.h> +#include <map> +#include <sstream> +#include <string> +#include <utility> + +namespace BamTools { + +namespace Internal { + class BamMultiReaderPrivate; +} // namespace Internal + +class API_EXPORT BamMultiReader { + + public: + enum SortOrder { SortedByPosition = 0 + , SortedByReadName + , Unsorted + }; + + // constructor / destructor + public: + BamMultiReader(void); + ~BamMultiReader(void); + + // public interface + public: + + // ---------------------- + // BAM file operations + // ---------------------- + + // closes all open BAM files + void Close(void); + // close only the requested BAM file + void CloseFile(const std::string& filename); + // returns list of filenames for all open BAM files + const std::vector<std::string> Filenames(void) const; + // returns true if multireader has any open BAM files + bool HasOpenReaders(void) const; + // performs random-access jump within current BAM files + bool Jump(int refID, int position = 0); + // opens BAM files + bool Open(const std::vector<std::string>& filenames); + // opens a single BAM file, adding to any other current BAM files + bool OpenFile(const std::string& filename); + // returns file pointers to beginning of alignments + bool Rewind(void); + // sets the target region of interest + bool SetRegion(const BamRegion& region); + // sets the target region of interest + bool SetRegion(const int& leftRefID, + const int& leftPosition, + const int& rightRefID, + const int& rightPosition); + + // ---------------------- + // access alignment data + // ---------------------- + + // retrieves next available alignment + bool GetNextAlignment(BamAlignment& alignment); + // retrieves next available alignmnet (without populating the alignment's string data fields) + bool GetNextAlignmentCore(BamAlignment& alignment); + + // sets the expected sorting order for reading across multiple BAM files + void SetSortOrder(const SortOrder& order); + + // ---------------------- + // access auxiliary data + // ---------------------- + + // returns unified SAM header for all files + SamHeader GetHeader(void) const; + // returns unified SAM header text for all files + std::string GetHeaderText(void) const; + // returns number of reference sequences + int GetReferenceCount(void) const; + // returns all reference sequence entries. + const BamTools::RefVector GetReferenceData(void) const; + // returns the ID of the reference with this name. + int GetReferenceID(const std::string& refName) const; + + // ---------------------- + // BAM index operations + // ---------------------- + + // creates index files for current BAM files + bool CreateIndexes(const BamIndex::IndexType& type = BamIndex::STANDARD); + // returns true if all BAM files have index data available + bool HasIndexes(void) const; + // looks for index files that match current BAM files + bool LocateIndexes(const BamIndex::IndexType& preferredType = BamIndex::STANDARD); + // opens index files for current BAM files. + bool OpenIndexes(const std::vector<std::string>& indexFilenames); + // changes the caching behavior of the index data + void SetIndexCacheMode(const BamIndex::IndexCacheMode& mode); + + // deprecated methods + public: + // returns \c true if all BAM files have index data available. + bool IsIndexLoaded(void) const; + // convenience method for printing filenames to stdout + void PrintFilenames(void) const; + + // private implementation + private: + Internal::BamMultiReaderPrivate* d; +}; + +} // namespace BamTools + +#endif // BAMMULTIREADER_H diff --git a/src/utils/BamTools/include/api/BamReader.h b/src/utils/BamTools/include/api/BamReader.h new file mode 100644 index 0000000000000000000000000000000000000000..85b0c0d5713ed15f4a616ec4a6f7e1c2ab9d3c1b --- /dev/null +++ b/src/utils/BamTools/include/api/BamReader.h @@ -0,0 +1,118 @@ +// *************************************************************************** +// BamReader.h (c) 2009 Derek Barnett, Michael Str�mberg +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 4 March 2011 (DB) +// --------------------------------------------------------------------------- +// Provides read access to BAM files. +// *************************************************************************** + +#ifndef BAMREADER_H +#define BAMREADER_H + +#include <api/api_global.h> +#include <api/BamAlignment.h> +#include <api/BamIndex.h> +#include <api/SamHeader.h> +#include <string> + +namespace BamTools { + +namespace Internal { + class BamReaderPrivate; +} // namespace Internal + +class API_EXPORT BamReader { + + // constructor / destructor + public: + BamReader(void); + ~BamReader(void); + + // public interface + public: + + // ---------------------- + // BAM file operations + // ---------------------- + + // closes the current BAM file + void Close(void); + // returns filename of current BAM file + const std::string GetFilename(void) const; + // returns true if a BAM file is open for reading + bool IsOpen(void) const; + // performs random-access jump within BAM file + bool Jump(int refID, int position = 0); + // opens a BAM file + bool Open(const std::string& filename); + // returns internal file pointer to beginning of alignment data + bool Rewind(void); + // sets the target region of interest + bool SetRegion(const BamRegion& region); + // sets the target region of interest + bool SetRegion(const int& leftRefID, + const int& leftPosition, + const int& rightRefID, + const int& rightPosition); + + // ---------------------- + // access alignment data + // ---------------------- + + // retrieves next available alignment + bool GetNextAlignment(BamAlignment& alignment); + // retrieves next available alignmnet (without populating the alignment's string data fields) + bool GetNextAlignmentCore(BamAlignment& alignment); + + // ---------------------- + // access header data + // ---------------------- + + // returns SAM header data + SamHeader GetHeader(void) const; + // returns SAM header data, as SAM-formatted text + std::string GetHeaderText(void) const; + + // ---------------------- + // access reference data + // ---------------------- + + // returns the number of reference sequences + int GetReferenceCount(void) const; + // returns all reference sequence entries + const RefVector& GetReferenceData(void) const; + // returns the ID of the reference with this name + int GetReferenceID(const std::string& refName) const; + + // ---------------------- + // BAM index operations + // ---------------------- + + // creates an index file for current BAM file, using the requested index type + bool CreateIndex(const BamIndex::IndexType& type = BamIndex::STANDARD); + // returns true if index data is available + bool HasIndex(void) const; + // looks in BAM file's directory for a matching index file + bool LocateIndex(const BamIndex::IndexType& preferredType = BamIndex::STANDARD); + // opens a BAM index file + bool OpenIndex(const std::string& indexFilename); + // sets a custom BamIndex on this reader + void SetIndex(BamIndex* index); + // changes the caching behavior of the index data + void SetIndexCacheMode(const BamIndex::IndexCacheMode& mode); + + // deprecated methods + public: + // returns true if index data is available + bool IsIndexLoaded(void) const; + + // private implementation + private: + Internal::BamReaderPrivate* d; +}; + +} // namespace BamTools + +#endif // BAMREADER_H diff --git a/src/utils/BamTools/include/api/BamWriter.h b/src/utils/BamTools/include/api/BamWriter.h new file mode 100644 index 0000000000000000000000000000000000000000..476dbecf271e35ea8db22883055faa69c62babf0 --- /dev/null +++ b/src/utils/BamTools/include/api/BamWriter.h @@ -0,0 +1,64 @@ +// *************************************************************************** +// BamWriter.h (c) 2009 Michael Str�mberg, Derek Barnett +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 4 March 2011 (DB) +// --------------------------------------------------------------------------- +// Provides the basic functionality for producing BAM files +// *************************************************************************** + +#ifndef BAMWRITER_H +#define BAMWRITER_H + +#include <api/api_global.h> +#include <api/BamAux.h> +#include <string> + +namespace BamTools { + +class BamAlignment; +class SamHeader; + +namespace Internal { + class BamWriterPrivate; +} // namespace Internal + +class API_EXPORT BamWriter { + + public: enum CompressionMode { Compressed = 0 + , Uncompressed + }; + + // ctor & dtor + public: + BamWriter(void); + ~BamWriter(void); + + // public interface + public: + // closes the current BAM file + void Close(void); + // returns true if BAM file is open for writing + bool IsOpen(void) const; + // opens a BAM file for writing + bool Open(const std::string& filename, + const std::string& samHeaderText, + const RefVector& referenceSequences); + // opens a BAM file for writing + bool Open(const std::string& filename, + const SamHeader& samHeader, + const RefVector& referenceSequences); + // saves the alignment to the alignment archive + void SaveAlignment(const BamAlignment& alignment); + // sets the output compression mode + void SetCompressionMode(const CompressionMode& compressionMode); + + // private implementation + private: + Internal::BamWriterPrivate* d; +}; + +} // namespace BamTools + +#endif // BAMWRITER_H diff --git a/src/utils/BamTools/include/api/SamConstants.h b/src/utils/BamTools/include/api/SamConstants.h new file mode 100644 index 0000000000000000000000000000000000000000..d34592027891a8233e6e27b6b4f2cb8a84a8f9a6 --- /dev/null +++ b/src/utils/BamTools/include/api/SamConstants.h @@ -0,0 +1,96 @@ +// *************************************************************************** +// SamConstants.h (c) 2010 Derek Barnett +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 19 April 2011 (DB) +// --------------------------------------------------------------------------- +// Provides constants for SAM header +// *************************************************************************** + +#ifndef SAM_CONSTANTS_H +#define SAM_CONSTANTS_H + +#include <api/api_global.h> +#include <string> + +namespace BamTools { +namespace Constants { + +// basic char constants used in SAM format +const char SAM_COLON = ':'; +const char SAM_EQUAL = '='; +const char SAM_PERIOD = '.'; +const char SAM_STAR = '*'; +const char SAM_TAB = '\t'; +const std::string SAM_DIGITS = "0123456789"; + +// HD entries +const std::string SAM_HD_BEGIN_TOKEN = "@HD"; +const std::string SAM_HD_VERSION_TAG = "VN"; +const std::string SAM_HD_SORTORDER_TAG = "SO"; +const std::string SAM_HD_GROUPORDER_TAG = "GO"; + +// SQ entries +const std::string SAM_SQ_BEGIN_TOKEN = "@SQ"; +const std::string SAM_SQ_ASSEMBLYID_TAG = "AS"; +const std::string SAM_SQ_CHECKSUM_TAG = "M5"; +const std::string SAM_SQ_LENGTH_TAG = "LN"; +const std::string SAM_SQ_NAME_TAG = "SN"; +const std::string SAM_SQ_SPECIES_TAG = "SP"; +const std::string SAM_SQ_URI_TAG = "UR"; + +// RG entries +const std::string SAM_RG_BEGIN_TOKEN = "@RG"; +const std::string SAM_RG_DESCRIPTION_TAG = "DS"; +const std::string SAM_RG_FLOWORDER_TAG = "FO"; +const std::string SAM_RG_ID_TAG = "ID"; +const std::string SAM_RG_KEYSEQUENCE_TAG = "KS"; +const std::string SAM_RG_LIBRARY_TAG = "LB"; +const std::string SAM_RG_PLATFORMUNIT_TAG = "PU"; +const std::string SAM_RG_PREDICTEDINSERTSIZE_TAG = "PI"; +const std::string SAM_RG_PRODUCTIONDATE_TAG = "DT"; +const std::string SAM_RG_PROGRAM_TAG = "PG"; +const std::string SAM_RG_SAMPLE_TAG = "SM"; +const std::string SAM_RG_SEQCENTER_TAG = "CN"; +const std::string SAM_RG_SEQTECHNOLOGY_TAG = "PL"; + +// PG entries +const std::string SAM_PG_BEGIN_TOKEN = "@PG"; +const std::string SAM_PG_COMMANDLINE_TAG = "CL"; +const std::string SAM_PG_ID_TAG = "ID"; +const std::string SAM_PG_NAME_TAG = "PN"; +const std::string SAM_PG_PREVIOUSPROGRAM_TAG = "PP"; +const std::string SAM_PG_VERSION_TAG = "VN"; + +// CO entries +const std::string SAM_CO_BEGIN_TOKEN = "@CO"; + +// HD:SO values +const std::string SAM_HD_SORTORDER_COORDINATE = "coordinate"; +const std::string SAM_HD_SORTORDER_QUERYNAME = "queryname"; +const std::string SAM_HD_SORTORDER_UNKNOWN = "unknown"; +const std::string SAM_HD_SORTORDER_UNSORTED = "unsorted"; + +// HD:GO values +const std::string SAM_HD_GROUPORDER_NONE = "none"; +const std::string SAM_HD_GROUPORDER_QUERY = "query"; +const std::string SAM_HD_GROUPORDER_REFERENCE = "reference"; + +// SQ:LN values +const unsigned int SAM_SQ_LENGTH_MIN = 1; +const unsigned int SAM_SQ_LENGTH_MAX = 536870911; // 2^29 - 1 + +// RG:PL values +const std::string SAM_RG_SEQTECHNOLOGY_CAPILLARY = "CAPILLARY"; +const std::string SAM_RG_SEQTECHNOLOGY_HELICOS = "HELICOS"; +const std::string SAM_RG_SEQTECHNOLOGY_ILLUMINA = "ILLUMINA"; +const std::string SAM_RG_SEQTECHNOLOGY_IONTORRENT = "IONTORRENT"; +const std::string SAM_RG_SEQTECHNOLOGY_LS454 = "LS454"; +const std::string SAM_RG_SEQTECHNOLOGY_PACBIO = "PACBIO"; +const std::string SAM_RG_SEQTECHNOLOGY_SOLID = "SOLID"; + +} // namespace Constants +} // namespace BamTools + +#endif // SAM_CONSTANTS_H diff --git a/src/utils/BamTools/include/api/SamHeader.h b/src/utils/BamTools/include/api/SamHeader.h new file mode 100644 index 0000000000000000000000000000000000000000..5c7a1019120f74981ad8ee3e73559d8247b569a9 --- /dev/null +++ b/src/utils/BamTools/include/api/SamHeader.h @@ -0,0 +1,69 @@ +// *************************************************************************** +// SamHeader.h (c) 2010 Derek Barnett +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 18 April 2011 (DB) +// --------------------------------------------------------------------------- +// Provides direct read/write access to the SAM header data fields. +// *************************************************************************** + +#ifndef SAM_HEADER_H +#define SAM_HEADER_H + +#include <api/api_global.h> +#include <api/SamProgramChain.h> +#include <api/SamReadGroupDictionary.h> +#include <api/SamSequenceDictionary.h> +#include <string> +#include <vector> + +namespace BamTools { + +struct API_EXPORT SamHeader { + + // ctor & dtor + SamHeader(const std::string& headerText = ""); + SamHeader(const SamHeader& other); + ~SamHeader(void); + + // query/modify entire SamHeader + void Clear(void); // clears all header contents + bool IsValid(bool verbose = false) const; // returns true if SAM header is well-formed + void SetHeaderText(const std::string& headerText); // replaces data fields with contents of SAM-formatted text + std::string ToString(void) const; // returns the printable, SAM-formatted header text + + // convenience query methods + bool HasVersion(void) const; // returns true if header contains format version entry + bool HasSortOrder(void) const; // returns true if header contains sort order entry + bool HasGroupOrder(void) const; // returns true if header contains group order entry + bool HasSequences(void) const; // returns true if header contains any sequence entries + bool HasReadGroups(void) const; // returns true if header contains any read group entries + bool HasPrograms(void) const; // returns true if header contains any program record entries + bool HasComments(void) const; // returns true if header contains comments + + // -------------- + // data members + // -------------- + + // header metadata (@HD line) + std::string Version; // VN:<Version> *Required for valid SAM header, if @HD record is present* + std::string SortOrder; // SO:<SortOrder> + std::string GroupOrder; // GO:<GroupOrder> + + // header sequences (@SQ entries) + SamSequenceDictionary Sequences; + + // header read groups (@RG entries) + SamReadGroupDictionary ReadGroups; + + // header program data (@PG entries) + SamProgramChain Programs; + + // header comments (@CO entries) + std::vector<std::string> Comments; +}; + +} // namespace BamTools + +#endif // SAM_HEADER_H diff --git a/src/utils/BamTools/include/api/SamProgram.h b/src/utils/BamTools/include/api/SamProgram.h new file mode 100644 index 0000000000000000000000000000000000000000..3c89059bdaedeeaf0b287b9c4fd3a2aae794002e --- /dev/null +++ b/src/utils/BamTools/include/api/SamProgram.h @@ -0,0 +1,62 @@ +// *************************************************************************** +// SamProgram.h (c) 2011 Derek Barnett +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 19 April 2011 (DB) +// --------------------------------------------------------------------------- +// Provides direct read/write access to the SAM header program records. +// *************************************************************************** + +#ifndef SAM_PROGRAM_H +#define SAM_PROGRAM_H + +#include "api/api_global.h" +#include <string> + +namespace BamTools { + +class SamProgramChain; + +struct API_EXPORT SamProgram { + + // ctor & dtor + SamProgram(void); + SamProgram(const std::string& id); + SamProgram(const SamProgram& other); + ~SamProgram(void); + + // query/modify entire program record + void Clear(void); // clears all data fields + + // convenience query methods + bool HasCommandLine(void) const; // returns true if program record has a command line entry + bool HasID(void) const; // returns true if program record has an ID + bool HasName(void) const; // returns true if program record has a name + bool HasPreviousProgramID(void) const; // returns true if program record has a 'previous program ID' + bool HasVersion(void) const; // returns true if program record has a version + + // data members + std::string CommandLine; // CL:<CommandLine> + std::string ID; // ID:<ID> *Required for valid SAM header* + std::string Name; // PN:<Name> + std::string PreviousProgramID; // PP:<PreviousProgramID> + std::string Version; // VN:<Version> + + // internal (non-standard) methods & fields + private: + bool HasNextProgramID(void) const; + std::string NextProgramID; + friend class BamTools::SamProgramChain; +}; + +/*! \fn bool operator==(const SamProgram& lhs, const SamProgram& rhs) + \brief tests equality by comparing program IDs +*/ +API_EXPORT inline bool operator==(const SamProgram& lhs, const SamProgram& rhs) { + return lhs.ID == rhs.ID; +} + +} // namespace BamTools + +#endif // SAM_PROGRAM_H diff --git a/src/utils/BamTools/include/api/SamProgramChain.h b/src/utils/BamTools/include/api/SamProgramChain.h new file mode 100644 index 0000000000000000000000000000000000000000..4cb16fc337fc2b834dded709804f8879f15968f2 --- /dev/null +++ b/src/utils/BamTools/include/api/SamProgramChain.h @@ -0,0 +1,86 @@ +// *************************************************************************** +// SamProgramChain.h (c) 2011 Derek Barnett +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 19 April 2011 (DB) +// --------------------------------------------------------------------------- +// Provides methods for operating on a SamProgram record "chain" +// *************************************************************************** + +#ifndef SAM_PROGRAMCHAIN_H +#define SAM_PROGRAMCHAIN_H + +#include <api/api_global.h> +#include <api/SamProgram.h> +#include <string> +#include <vector> + +namespace BamTools { + +// chain is *NOT* sorted in any order +// use First()/Last() to retrieve oldest/newest programs, respectively +typedef std::vector<SamProgram> SamProgramContainer; +typedef SamProgramContainer::iterator SamProgramIterator; +typedef SamProgramContainer::const_iterator SamProgramConstIterator; + +class API_EXPORT SamProgramChain { + + // ctor & dtor + public: + SamProgramChain(void); + SamProgramChain(const SamProgramChain& other); + ~SamProgramChain(void); + + // query/modify program data + public: + // appends a program record to the chain + void Add(SamProgram& program); + void Add(std::vector<SamProgram>& programs); + + // clears all read group entries + void Clear(void); + + // returns true if chain contains this program record (matches on ID) + bool Contains(const SamProgram& program) const; + bool Contains(const std::string& programId) const; + + // returns the first (oldest) program in the chain + SamProgram& First(void); + const SamProgram& First(void) const; + + // returns true if chain is empty + bool IsEmpty(void) const; + + // returns last (most recent) program in the chain + SamProgram& Last(void); + const SamProgram& Last(void) const; + + // returns number of program records in the chain + int Size(void) const; + + // retrieves a modifiable reference to the SamProgram object associated with this ID + SamProgram& operator[](const std::string& programId); + + // retrieve STL-compatible iterators + public: + SamProgramIterator Begin(void); // returns iterator to begin() + SamProgramConstIterator Begin(void) const; // returns const_iterator to begin() + SamProgramConstIterator ConstBegin(void) const; // returns const_iterator to begin() + SamProgramIterator End(void); // returns iterator to end() + SamProgramConstIterator End(void) const; // returns const_iterator to end() + SamProgramConstIterator ConstEnd(void) const; // returns const_iterator to end() + + // internal methods + private: + int IndexOf(const std::string& programId) const; + const std::string NextIdFor(const std::string& programId) const; + + // data members + private: + SamProgramContainer m_data; +}; + +} // namespace BamTools + +#endif // SAM_PROGRAMCHAIN_H diff --git a/src/utils/BamTools/include/api/SamReadGroup.h b/src/utils/BamTools/include/api/SamReadGroup.h new file mode 100644 index 0000000000000000000000000000000000000000..b203d3cdb16927c5363272c9810b74b84bd2ecba --- /dev/null +++ b/src/utils/BamTools/include/api/SamReadGroup.h @@ -0,0 +1,69 @@ +// *************************************************************************** +// SamReadGroup.h (c) 2010 Derek Barnett +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 18 April 2011 (DB) +// --------------------------------------------------------------------------- +// Provides direct read/write access to the SAM read group data fields. +// *************************************************************************** + +#ifndef SAM_READGROUP_H +#define SAM_READGROUP_H + +#include "api/api_global.h" +#include <string> + +namespace BamTools { + +struct API_EXPORT SamReadGroup { + + // ctor & dtor + SamReadGroup(void); + SamReadGroup(const std::string& id); + SamReadGroup(const SamReadGroup& other); + ~SamReadGroup(void); + + // query/modify entire read group + void Clear(void); // clears all data fields + + // convenience query methods + bool HasDescription(void) const; // returns true if read group has a description + bool HasFlowOrder(void) const; // returns true if read group has a flow order entry + bool HasID(void) const; // returns true if read group has a group ID + bool HasKeySequence(void) const; // returns true if read group has a key sequence + bool HasLibrary(void) const; // returns true if read group has a library name + bool HasPlatformUnit(void) const; // returns true if read group has a platform unit ID + bool HasPredictedInsertSize(void) const; // returns true if read group has a predicted insert size + bool HasProductionDate(void) const; // returns true if read group has a production date + bool HasProgram(void) const; // returns true if read group has a program entry + bool HasSample(void) const; // returns true if read group has a sample name + bool HasSequencingCenter(void) const; // returns true if read group has a sequencing center ID + bool HasSequencingTechnology(void) const; // returns true if read group has a sequencing technology ID + + + // data fields + std::string Description; // DS:<Description> + std::string FlowOrder; // FO:<FlowOrder> + std::string ID; // ID:<ID> *Required for valid SAM header* + std::string KeySequence; // KS:<KeySequence> + std::string Library; // LB:<Library> + std::string PlatformUnit; // PU:<PlatformUnit> + std::string PredictedInsertSize; // PI:<PredictedInsertSize> + std::string ProductionDate; // DT:<ProductionDate> + std::string Program; // PG:<Program> + std::string Sample; // SM:<Sample> + std::string SequencingCenter; // CN:<SequencingCenter> + std::string SequencingTechnology; // PL:<SequencingTechnology> +}; + +/*! \fn bool operator==(const SamReadGroup& lhs, const SamReadGroup& rhs) + \brief tests equality by comparing read group IDs +*/ +API_EXPORT inline bool operator==(const SamReadGroup& lhs, const SamReadGroup& rhs) { + return lhs.ID == rhs.ID; +} + +} // namespace BamTools + +#endif // SAM_READGROUP_H diff --git a/src/utils/BamTools/include/api/SamReadGroupDictionary.h b/src/utils/BamTools/include/api/SamReadGroupDictionary.h new file mode 100644 index 0000000000000000000000000000000000000000..8ec40e227ba5f020699cd1a0021a2785587e447c --- /dev/null +++ b/src/utils/BamTools/include/api/SamReadGroupDictionary.h @@ -0,0 +1,87 @@ +// *************************************************************************** +// SamReadGroupDictionary.h (c) 2010 Derek Barnett +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 18 April 2011 (DB) +// --------------------------------------------------------------------------- +// Provides methods for operating on a collection of SamReadGroup entries. +// *************************************************************************** + +#ifndef SAM_READGROUP_DICTIONARY_H +#define SAM_READGROUP_DICTIONARY_H + +#include <api/api_global.h> +#include <api/SamReadGroup.h> +#include <string> +#include <vector> + +namespace BamTools { + +typedef std::vector<SamReadGroup> SamReadGroupContainer; +typedef SamReadGroupContainer::iterator SamReadGroupIterator; +typedef SamReadGroupContainer::const_iterator SamReadGroupConstIterator; + +class API_EXPORT SamReadGroupDictionary { + + // ctor & dtor + public: + SamReadGroupDictionary(void); + SamReadGroupDictionary(const SamReadGroupDictionary& other); + ~SamReadGroupDictionary(void); + + // query/modify read group data + public: + // adds a read group + void Add(const SamReadGroup& readGroup); + void Add(const std::string& readGroupId); + + // adds multiple read groups + void Add(const std::vector<SamReadGroup>& readGroups); + void Add(const std::vector<std::string>& readGroupIds); + + // clears all read group entries + void Clear(void); + + // returns true if dictionary contains this read group + bool Contains(const SamReadGroup& readGroup) const; + bool Contains(const std::string& readGroupId) const; + + // returns true if dictionary is empty + bool IsEmpty(void) const; + + // removes read group, if found + void Remove(const SamReadGroup& readGroup); + void Remove(const std::string& readGroupId); + + // removes multiple read groups + void Remove(const std::vector<SamReadGroup>& readGroups); + void Remove(const std::vector<std::string>& readGroupIds); + + // returns number of read groups in dictionary + int Size(void) const; + + // retrieves a modifiable reference to the SamReadGroup object associated with this ID + SamReadGroup& operator[](const std::string& readGroupId); + + // retrieve STL-compatible iterators + public: + SamReadGroupIterator Begin(void); // returns iterator to begin() + SamReadGroupConstIterator Begin(void) const; // returns const_iterator to begin() + SamReadGroupConstIterator ConstBegin(void) const; // returns const_iterator to begin() + SamReadGroupIterator End(void); // returns iterator to end() + SamReadGroupConstIterator End(void) const; // returns const_iterator to end() + SamReadGroupConstIterator ConstEnd(void) const; // returns const_iterator to end() + + // internal methods + private: + int IndexOf(const std::string& readGroupId) const; + + // data members + private: + SamReadGroupContainer m_data; +}; + +} // namespace BamTools + +#endif // SAM_READGROUP_DICTIONARY_H diff --git a/src/utils/BamTools/include/api/SamSequence.h b/src/utils/BamTools/include/api/SamSequence.h new file mode 100644 index 0000000000000000000000000000000000000000..054e58f985ec40c74820f37a8318157202dfd2ed --- /dev/null +++ b/src/utils/BamTools/include/api/SamSequence.h @@ -0,0 +1,61 @@ +// *************************************************************************** +// SamSequence.h (c) 2010 Derek Barnett +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 18 April 2011 (DB) +// --------------------------------------------------------------------------- +// Provides direct read/write access to the SAM sequence data fields. +// *************************************************************************** + +#ifndef SAM_SEQUENCE_H +#define SAM_SEQUENCE_H + +#include <api/api_global.h> +#include <string> + +namespace BamTools { + +struct API_EXPORT SamSequence { + + // ctor & dtor + SamSequence(void); + SamSequence(const std::string& name, const int& length); + SamSequence(const std::string& name, const std::string& length); + SamSequence(const SamSequence& other); + ~SamSequence(void); + + // query/modify entire sequence + void Clear(void); // clears all contents + + // convenience query methods + bool HasAssemblyID(void) const; // returns true if sequence has an assembly ID + bool HasChecksum(void) const; // returns true if sequence has an MD5 checksum + bool HasLength(void) const; // returns true if sequence has a length + bool HasName(void) const; // returns true if sequence has a name + bool HasSpecies(void) const; // returns true if sequence has a species ID + bool HasURI(void) const; // returns true if sequence has a URI + + // data members + std::string AssemblyID; // AS:<AssemblyID> + std::string Checksum; // M5:<Checksum> + std::string Length; // LN:<Length> *Required for valid SAM header* + std::string Name; // SN:<Name> *Required for valid SAM header* + std::string Species; // SP:<Species> + std::string URI; // UR:<URI> +}; + +/*! \fn bool operator==(const SamSequence& lhs, const SamSequence& rhs) + \brief tests equality by comparing sequence names, lengths, & checksums (if available) +*/ +API_EXPORT inline bool operator==(const SamSequence& lhs, const SamSequence& rhs) { + if ( lhs.Name != rhs.Name ) return false; + if ( lhs.Length != rhs.Length ) return false; + if ( lhs.HasChecksum() && rhs.HasChecksum() ) + return (lhs.Checksum == rhs.Checksum); + else return true; +} + +} // namespace BamTools + +#endif // SAM_SEQUENCE_H diff --git a/src/utils/BamTools/include/api/SamSequenceDictionary.h b/src/utils/BamTools/include/api/SamSequenceDictionary.h new file mode 100644 index 0000000000000000000000000000000000000000..1ac73261fef989f3f38adf9d6a9d1db1c16701b7 --- /dev/null +++ b/src/utils/BamTools/include/api/SamSequenceDictionary.h @@ -0,0 +1,89 @@ +// *************************************************************************** +// SamSequenceDictionary.h (c) 2010 Derek Barnett +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 18 April 2011 +// --------------------------------------------------------------------------- +// Provides methods for operating on a collection of SamSequence entries. +// *************************************************************************** + +#ifndef SAM_SEQUENCE_DICTIONARY_H +#define SAM_SEQUENCE_DICTIONARY_H + +#include <api/api_global.h> +#include <api/SamSequence.h> +#include <string> +#include <map> +#include <vector> + +namespace BamTools { + +typedef std::vector<SamSequence> SamSequenceContainer; +typedef SamSequenceContainer::iterator SamSequenceIterator; +typedef SamSequenceContainer::const_iterator SamSequenceConstIterator; + +class API_EXPORT SamSequenceDictionary { + + // ctor & dtor + public: + SamSequenceDictionary(void); + SamSequenceDictionary(const SamSequenceDictionary& other); + ~SamSequenceDictionary(void); + + // query/modify sequence data + public: + // adds a sequence + void Add(const SamSequence& sequence); + void Add(const std::string& name, const int& length); + + // adds multiple sequences + void Add(const std::vector<SamSequence>& sequences); + void Add(const std::map<std::string, int>& sequenceMap); + + // clears all sequence entries + void Clear(void); + + // returns true if dictionary contains this sequence + bool Contains(const SamSequence& sequence) const; + bool Contains(const std::string& sequenceName) const; + + // returns true if dictionary is empty + bool IsEmpty(void) const; + + // removes sequence, if found + void Remove(const SamSequence& sequence); + void Remove(const std::string& sequenceName); + + // removes multiple sequences + void Remove(const std::vector<SamSequence>& sequences); + void Remove(const std::vector<std::string>& sequenceNames); + + // returns number of sequences in dictionary + int Size(void) const; + + // retrieves a modifiable reference to the SamSequence object associated with this name + SamSequence& operator[](const std::string& sequenceName); + + // retrieve STL-compatible iterators + public: + SamSequenceIterator Begin(void); // returns iterator to begin() + SamSequenceConstIterator Begin(void) const; // returns const_iterator to begin() + SamSequenceConstIterator ConstBegin(void) const; // returns const_iterator to begin() + SamSequenceIterator End(void); // returns iterator to end() + SamSequenceConstIterator End(void) const; // returns const_iterator to end() + SamSequenceConstIterator ConstEnd(void) const; // returns const_iterator to end() + + // internal methods + private: + int IndexOf(const std::string& name) const; + + // data members + private: + SamSequenceContainer m_data; +}; + +} // namespace BamTools + +#endif // SAM_SEQUENCE_DICTIONARY_H + diff --git a/src/utils/BamTools/include/api/api_global.h b/src/utils/BamTools/include/api/api_global.h new file mode 100644 index 0000000000000000000000000000000000000000..84fcad214c1e141d8f227dba3961e6570f03aec8 --- /dev/null +++ b/src/utils/BamTools/include/api/api_global.h @@ -0,0 +1,22 @@ +// *************************************************************************** +// api_global.h (c) 2010 Derek Barnett +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 19 November 2010 (DB) +// --------------------------------------------------------------------------- +// Provides macros for exporting & importing BamTools API library symbols +// *************************************************************************** + +#ifndef API_GLOBAL_H +#define API_GLOBAL_H + +#include "shared/bamtools_global.h" + +#ifdef BAMTOOLS_API_LIBRARY +# define API_EXPORT BAMTOOLS_LIBRARY_EXPORT +#else +# define API_EXPORT BAMTOOLS_LIBRARY_IMPORT +#endif + +#endif // API_GLOBAL_H diff --git a/src/utils/BamTools/include/shared/bamtools_global.h b/src/utils/BamTools/include/shared/bamtools_global.h new file mode 100644 index 0000000000000000000000000000000000000000..6e3cb39e5a69fca28ef2196cdb0407671e8805c0 --- /dev/null +++ b/src/utils/BamTools/include/shared/bamtools_global.h @@ -0,0 +1,79 @@ +// *************************************************************************** +// bamtools_global.h (c) 2010 Derek Barnett +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 3 March 2011 (DB) +// --------------------------------------------------------------------------- +// Provides the basic definitions for exporting & importing library symbols. +// Also provides some platform-specific rules for definitions. +// *************************************************************************** + +#ifndef BAMTOOLS_GLOBAL_H +#define BAMTOOLS_GLOBAL_H + +/*! \brief Library export macro + \internal +*/ +#ifndef BAMTOOLS_LIBRARY_EXPORT +# if defined(WIN32) +# define BAMTOOLS_LIBRARY_EXPORT __declspec(dllexport) +# else +# define BAMTOOLS_LIBRARY_EXPORT __attribute__((visibility("default"))) +# endif +#endif // BAMTOOLS_LIBRARY_EXPORT + +/*! \brief Library import macro + \internal +*/ +#ifndef BAMTOOLS_LIBRARY_IMPORT +# if defined(WIN32) +# define BAMTOOLS_LIBRARY_IMPORT __declspec(dllimport) +# else +# define BAMTOOLS_LIBRARY_IMPORT +# endif +#endif // BAMTOOLS_LIBRARY_IMPORT + +/*! \brief Platform-specific type definitions + \internal +*/ +#ifndef BAMTOOLS_LFS +#define BAMTOOLS_LFS + #ifdef WIN32 + #define ftell64(a) _ftelli64(a) + #define fseek64(a,b,c) _fseeki64(a,b,c) + #else + #define ftell64(a) ftello(a) + #define fseek64(a,b,c) fseeko(a,b,c) + #endif +#endif // BAMTOOLS_LFS + +/*! \def ftell64(a) + \brief Platform-independent tell() operation. + \internal +*/ +/*! \def fseek64(a,b,c) + \brief Platform-independent seek() operation. + \internal +*/ + +/*! \brief Platform-specific type definitions + \internal +*/ +#ifndef BAMTOOLS_TYPES +#define BAMTOOLS_TYPES + #ifdef _MSC_VER + typedef char int8_t; + typedef unsigned char uint8_t; + typedef short int16_t; + typedef unsigned short uint16_t; + typedef int int32_t; + typedef unsigned int uint32_t; + typedef long long int64_t; + typedef unsigned long long uint64_t; + #else + #include <stdint.h> + #endif +#endif // BAMTOOLS_TYPES + +#endif // BAMTOOLS_GLOBAL_H diff --git a/src/utils/BamTools/lib/libbamtools.a b/src/utils/BamTools/lib/libbamtools.a new file mode 100644 index 0000000000000000000000000000000000000000..ecf2d8ef5c48c40969a454a3b7ea5f34d422c7ba Binary files /dev/null and b/src/utils/BamTools/lib/libbamtools.a differ diff --git a/src/utils/BamTools/src/api/BamAlignment.o b/src/utils/BamTools/src/api/BamAlignment.o new file mode 100644 index 0000000000000000000000000000000000000000..36be1eced244916a6535ffda1c4eecb49d5bfcd9 Binary files /dev/null and b/src/utils/BamTools/src/api/BamAlignment.o differ diff --git a/src/utils/BamTools/src/api/BamMultiReader.o b/src/utils/BamTools/src/api/BamMultiReader.o new file mode 100644 index 0000000000000000000000000000000000000000..f053ec2ab82d48b489244296b413cd1e6091c4f4 Binary files /dev/null and b/src/utils/BamTools/src/api/BamMultiReader.o differ diff --git a/src/utils/BamTools/src/api/BamReader.o b/src/utils/BamTools/src/api/BamReader.o new file mode 100644 index 0000000000000000000000000000000000000000..1fd86c23022b6a281f4a1135690e3477e21e989e Binary files /dev/null and b/src/utils/BamTools/src/api/BamReader.o differ diff --git a/src/utils/BamTools/src/api/BamWriter.o b/src/utils/BamTools/src/api/BamWriter.o new file mode 100644 index 0000000000000000000000000000000000000000..9f7e8a4a859cf95c05edeb768a381936c4c96eba Binary files /dev/null and b/src/utils/BamTools/src/api/BamWriter.o differ diff --git a/src/utils/BamTools/src/api/SamHeader.o b/src/utils/BamTools/src/api/SamHeader.o new file mode 100644 index 0000000000000000000000000000000000000000..10e49204ad057a11f159aec86122566f75b9c651 Binary files /dev/null and b/src/utils/BamTools/src/api/SamHeader.o differ diff --git a/src/utils/BamTools/src/api/SamProgram.o b/src/utils/BamTools/src/api/SamProgram.o new file mode 100644 index 0000000000000000000000000000000000000000..b7d6c41bd895efdfc342560e2d97daca9cded631 Binary files /dev/null and b/src/utils/BamTools/src/api/SamProgram.o differ diff --git a/src/utils/BamTools/src/api/SamProgramChain.o b/src/utils/BamTools/src/api/SamProgramChain.o new file mode 100644 index 0000000000000000000000000000000000000000..ddda8067930d6db4f4bf7e095d82278b12ab1146 Binary files /dev/null and b/src/utils/BamTools/src/api/SamProgramChain.o differ diff --git a/src/utils/BamTools/src/api/SamReadGroup.o b/src/utils/BamTools/src/api/SamReadGroup.o new file mode 100644 index 0000000000000000000000000000000000000000..644aff69b9462791a36b3276be9da5f3eb5ad553 Binary files /dev/null and b/src/utils/BamTools/src/api/SamReadGroup.o differ diff --git a/src/utils/BamTools/src/api/SamReadGroupDictionary.o b/src/utils/BamTools/src/api/SamReadGroupDictionary.o new file mode 100644 index 0000000000000000000000000000000000000000..d30ca9b094b895cb8bbf27e8565b3ab58d1d2e48 Binary files /dev/null and b/src/utils/BamTools/src/api/SamReadGroupDictionary.o differ diff --git a/src/utils/BamTools/src/api/SamSequence.o b/src/utils/BamTools/src/api/SamSequence.o new file mode 100644 index 0000000000000000000000000000000000000000..2ecce255d2c6d056bd1a8ff79ecb5b29b3f64106 Binary files /dev/null and b/src/utils/BamTools/src/api/SamSequence.o differ diff --git a/src/utils/BamTools/src/api/SamSequenceDictionary.o b/src/utils/BamTools/src/api/SamSequenceDictionary.o new file mode 100644 index 0000000000000000000000000000000000000000..972c52becc0169c84f19efa0ba3b09057c1f1e72 Binary files /dev/null and b/src/utils/BamTools/src/api/SamSequenceDictionary.o differ diff --git a/src/utils/BamTools/src/api/internal/BamHeader_p.o b/src/utils/BamTools/src/api/internal/BamHeader_p.o new file mode 100644 index 0000000000000000000000000000000000000000..b2bbda4485bec554f64bc899b7c2e02e0fdf26ec Binary files /dev/null and b/src/utils/BamTools/src/api/internal/BamHeader_p.o differ diff --git a/src/utils/BamTools/src/api/internal/BamIndexFactory_p.o b/src/utils/BamTools/src/api/internal/BamIndexFactory_p.o new file mode 100644 index 0000000000000000000000000000000000000000..728bae8935b88c0924dce74d4e11bb7f2bcb02c2 Binary files /dev/null and b/src/utils/BamTools/src/api/internal/BamIndexFactory_p.o differ diff --git a/src/utils/BamTools/src/api/internal/BamMultiReader_p.o b/src/utils/BamTools/src/api/internal/BamMultiReader_p.o new file mode 100644 index 0000000000000000000000000000000000000000..c9099ab005622687bc8552bd18c7e738c6b35b22 Binary files /dev/null and b/src/utils/BamTools/src/api/internal/BamMultiReader_p.o differ diff --git a/src/utils/BamTools/src/api/internal/BamRandomAccessController_p.o b/src/utils/BamTools/src/api/internal/BamRandomAccessController_p.o new file mode 100644 index 0000000000000000000000000000000000000000..7e96470d377a791f130ee6b21b1bd424831a55dc Binary files /dev/null and b/src/utils/BamTools/src/api/internal/BamRandomAccessController_p.o differ diff --git a/src/utils/BamTools/src/api/internal/BamReader_p.o b/src/utils/BamTools/src/api/internal/BamReader_p.o new file mode 100644 index 0000000000000000000000000000000000000000..14568a96d3b7e4b02056d723ea996d1d35001ecf Binary files /dev/null and b/src/utils/BamTools/src/api/internal/BamReader_p.o differ diff --git a/src/utils/BamTools/src/api/internal/BamStandardIndex_p.o b/src/utils/BamTools/src/api/internal/BamStandardIndex_p.o new file mode 100644 index 0000000000000000000000000000000000000000..38afbbae0441bad94687b5146afcc17d303fa4da Binary files /dev/null and b/src/utils/BamTools/src/api/internal/BamStandardIndex_p.o differ diff --git a/src/utils/BamTools/src/api/internal/BamToolsIndex_p.o b/src/utils/BamTools/src/api/internal/BamToolsIndex_p.o new file mode 100644 index 0000000000000000000000000000000000000000..e81c1139a314fa4a0ff8997e8bd2769827cc250e Binary files /dev/null and b/src/utils/BamTools/src/api/internal/BamToolsIndex_p.o differ diff --git a/src/utils/BamTools/src/api/internal/BamWriter_p.o b/src/utils/BamTools/src/api/internal/BamWriter_p.o new file mode 100644 index 0000000000000000000000000000000000000000..d1900e310615606bd94fe45f0d0e43483c6a4488 Binary files /dev/null and b/src/utils/BamTools/src/api/internal/BamWriter_p.o differ diff --git a/src/utils/BamTools/src/api/internal/BgzfStream_p.o b/src/utils/BamTools/src/api/internal/BgzfStream_p.o new file mode 100644 index 0000000000000000000000000000000000000000..5160c6dee86ecb2a0c6ac6be1b8e5a816e72ef2d Binary files /dev/null and b/src/utils/BamTools/src/api/internal/BgzfStream_p.o differ diff --git a/src/utils/BamTools/src/api/internal/SamFormatParser_p.o b/src/utils/BamTools/src/api/internal/SamFormatParser_p.o new file mode 100644 index 0000000000000000000000000000000000000000..30a31ef4d208423fe10bba1abcb65e373187773d Binary files /dev/null and b/src/utils/BamTools/src/api/internal/SamFormatParser_p.o differ diff --git a/src/utils/BamTools/src/api/internal/SamFormatPrinter_p.o b/src/utils/BamTools/src/api/internal/SamFormatPrinter_p.o new file mode 100644 index 0000000000000000000000000000000000000000..ce79b555b00a19347a15c0a36240de9c5fe009be Binary files /dev/null and b/src/utils/BamTools/src/api/internal/SamFormatPrinter_p.o differ diff --git a/src/utils/BamTools/src/api/internal/SamHeaderValidator_p.o b/src/utils/BamTools/src/api/internal/SamHeaderValidator_p.o new file mode 100644 index 0000000000000000000000000000000000000000..3eefb6dfc51969914cffd6dade2bd086c375931b Binary files /dev/null and b/src/utils/BamTools/src/api/internal/SamHeaderValidator_p.o differ diff --git a/src/windowBed/Makefile b/src/windowBed/Makefile index 0b5303f3980c228c20294d984af3676877dc8e91..e32b09b3bbc1a3bf252a165bace9f53d21e6d434 100644 --- a/src/windowBed/Makefile +++ b/src/windowBed/Makefile @@ -24,14 +24,10 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) PROGRAM= windowBed -all: $(PROGRAM) +all: $(BUILT_OBJECTS) .PHONY: all -$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS) - @echo " * linking $(PROGRAM)" - @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ -L$(UTILITIES_DIR)/BamTools/lib/ -lbamtools $(LIBS) - $(BUILT_OBJECTS): $(SOURCES) @echo " * compiling" $(*F).cpp @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) diff --git a/src/windowBed/windowMain.cpp b/src/windowBed/windowMain.cpp index cbb5739a14120596893da0d89c26e34a78809249..9bf830ee129540f4343e05620fbe6b7f172eb8b2 100644 --- a/src/windowBed/windowMain.cpp +++ b/src/windowBed/windowMain.cpp @@ -15,16 +15,16 @@ using namespace std; // define the version -#define PROGRAM_NAME "windowBed" +#define PROGRAM_NAME "bedtools window" // define our parameter checking macro #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) // function declarations -void ShowHelp(void); +void window_help(void); -int main(int argc, char* argv[]) { +int window_main(int argc, char* argv[]) { // our configuration variables bool showHelp = false; @@ -65,7 +65,7 @@ int main(int argc, char* argv[]) { } } - if(showHelp) ShowHelp(); + if(showHelp) window_help(); // do some parsing (all of these parameters require 2 strings) for(int i = 1; i < argc; i++) { @@ -198,17 +198,16 @@ int main(int argc, char* argv[]) { return 0; } else { - ShowHelp(); + window_help(); } + return 0; } -void ShowHelp(void) { - - cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - - cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; +void window_help(void) { + cerr << "\nTool: bedtools window (aka windowBed)" << endl; + cerr << "Summary: Examines a \"window\" around each feature in A and" << endl; cerr << "\t reports all features in B that overlap the window. For each" << endl; cerr << "\t overlap the entire entry in A and B are reported." << endl << endl; @@ -219,7 +218,7 @@ void ShowHelp(void) { cerr << "\t-abam\t" << "The A input file is in BAM format. Output will be BAM as well." << endl << endl; - cerr << "\t-ubam\t" << "Write uncompressed BAM output. Default is to write compressed BAM." << endl << endl; + cerr << "\t-ubam\t" << "Write uncompressed BAM output. Default writes compressed BAM." << endl << endl; cerr << "\t-bed\t" << "When using BAM input (-abam), write output as BED. The default" << endl; cerr << "\t\tis to write output in BAM when using -abam." << endl << endl;