X-Git-Url: https://git.donarmstrong.com/?p=rsem.git;a=blobdiff_plain;f=bam2wig.cpp;h=d205e8f7f4e9fde1cacef0ace99b626b18cc01d4;hp=cb02bc2a9a6f575235dfe13bf9b581aca0852a12;hb=d13cdd443afbefff6f7c8c0be818e1edcbc9cb8d;hpb=53e8bbb15e0bfed6a0caae7b5ba6777a9a942266 diff --git a/bam2wig.cpp b/bam2wig.cpp index cb02bc2..d205e8f 100644 --- a/bam2wig.cpp +++ b/bam2wig.cpp @@ -1,15 +1,27 @@ #include +#include +#include + #include "wiggle.h" using namespace std; +void printUsage() { + printf("Usage: rsem-bam2wig sorted_bam_input wig_output wiggle_name [--no-fractional-weight]\n"); + printf("sorted_bam_input\t: Input BAM format file, must be sorted\n"); + printf("wig_output\t\t: Output wiggle file's name, e.g. output.wig\n"); + printf("wiggle_name\t\t: the name of this wiggle plot\n"); + printf("--no-fractional-weight\t: If this is set, RSEM will not look for \"ZW\" tag and each alignment appeared in the BAM file has weight 1. Set this if your BAM file is not generated by RSEM. Please note that this option must be at the end of the command line.\n"); + exit(-1); +} + int main(int argc, char* argv[]) { - if (argc != 4) { - printf("Usage: rsem-bam2wig sorted_bam_input wig_output wiggle_name\n"); - exit(-1); - } - UCSCWiggleTrackWriter track_writer(argv[2], argv[3]); - build_wiggles(argv[1], track_writer); + if (argc < 4 || argc > 5) { printf("Number of arguments is not correct!\n"); printUsage(); } + if (argc == 5 && strcmp(argv[4], "--no-fractional-weight")) { printf("Cannot recognize option %s!\n", argv[4]); printUsage(); } + + no_fractional_weight = (argc == 5 && !strcmp(argv[4], "--no-fractional-weight")); + UCSCWiggleTrackWriter track_writer(argv[2], argv[3]); + build_wiggles(argv[1], track_writer); return 0; }