Mercurial > repos > aaronquinlan > multi_intersect
comparison BEDTools-Version-2.14.3/src/complementBed/complementMain.cpp @ 1:bec36315bd12 default tip
Deleted selected files
| author | aaronquinlan |
|---|---|
| date | Sat, 19 Nov 2011 14:17:03 -0500 |
| parents | dfcd8b6c1bda |
| children |
comparison
equal
deleted
inserted
replaced
| 0:dfcd8b6c1bda | 1:bec36315bd12 |
|---|---|
| 1 /***************************************************************************** | |
| 2 complementBedMain.cpp | |
| 3 | |
| 4 (c) 2009 - Aaron Quinlan | |
| 5 Hall Laboratory | |
| 6 Department of Biochemistry and Molecular Genetics | |
| 7 University of Virginia | |
| 8 aaronquinlan@gmail.com | |
| 9 | |
| 10 Licenced under the GNU General Public License 2.0 license. | |
| 11 ******************************************************************************/ | |
| 12 #include "complementBed.h" | |
| 13 #include "version.h" | |
| 14 | |
| 15 using namespace std; | |
| 16 | |
| 17 // define our program name | |
| 18 #define PROGRAM_NAME "complementBed" | |
| 19 | |
| 20 | |
| 21 // define our parameter checking macro | |
| 22 #define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen) | |
| 23 | |
| 24 // function declarations | |
| 25 void ShowHelp(void); | |
| 26 | |
| 27 int main(int argc, char* argv[]) { | |
| 28 | |
| 29 // our configuration variables | |
| 30 bool showHelp = false; | |
| 31 | |
| 32 // input files | |
| 33 string bedFile = "stdin"; | |
| 34 string genomeFile; | |
| 35 | |
| 36 bool haveBed = true; | |
| 37 bool haveGenome = false; | |
| 38 | |
| 39 for(int i = 1; i < argc; i++) { | |
| 40 int parameterLength = (int)strlen(argv[i]); | |
| 41 | |
| 42 if((PARAMETER_CHECK("-h", 2, parameterLength)) || | |
| 43 (PARAMETER_CHECK("--help", 5, parameterLength))) { | |
| 44 showHelp = true; | |
| 45 } | |
| 46 } | |
| 47 | |
| 48 if(showHelp) ShowHelp(); | |
| 49 | |
| 50 // do some parsing (all of these parameters require 2 strings) | |
| 51 for(int i = 1; i < argc; i++) { | |
| 52 | |
| 53 int parameterLength = (int)strlen(argv[i]); | |
| 54 | |
| 55 if(PARAMETER_CHECK("-i", 2, parameterLength)) { | |
| 56 if ((i+1) < argc) { | |
| 57 bedFile = argv[i + 1]; | |
| 58 i++; | |
| 59 } | |
| 60 } | |
| 61 else if(PARAMETER_CHECK("-g", 2, parameterLength)) { | |
| 62 if ((i+1) < argc) { | |
| 63 haveGenome = true; | |
| 64 genomeFile = argv[i + 1]; | |
| 65 i++; | |
| 66 } | |
| 67 } | |
| 68 else { | |
| 69 cerr << endl << "*****ERROR: Unrecognized parameter: " << argv[i] << " *****" << endl << endl; | |
| 70 showHelp = true; | |
| 71 } | |
| 72 } | |
| 73 | |
| 74 // make sure we have both input files | |
| 75 if (!haveBed || !haveGenome) { | |
| 76 cerr << endl << "*****" << endl << "*****ERROR: Need -i BED file and -g Genome file. " << endl << "*****" << endl; | |
| 77 showHelp = true; | |
| 78 } | |
| 79 if (!showHelp) { | |
| 80 BedComplement *bc = new BedComplement(bedFile, genomeFile); | |
| 81 bc->ComplementBed(); | |
| 82 return 0; | |
| 83 } | |
| 84 else { | |
| 85 ShowHelp(); | |
| 86 } | |
| 87 } | |
| 88 | |
| 89 void ShowHelp(void) { | |
| 90 | |
| 91 cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; | |
| 92 | |
| 93 cerr << "Author: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; | |
| 94 | |
| 95 cerr << "Summary: Returns the base pair complement of a feature file." << endl << endl; | |
| 96 | |
| 97 cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -i <bed/gff/vcf> -g <genome>" << endl << endl; | |
| 98 | |
| 99 cerr << "Notes: " << endl; | |
| 100 cerr << "\t(1) The genome file should tab delimited and structured as follows:" << endl; | |
| 101 cerr << "\t <chromName><TAB><chromSize>" << endl << endl; | |
| 102 cerr << "\tFor example, Human (hg19):" << endl; | |
| 103 cerr << "\tchr1\t249250621" << endl; | |
| 104 cerr << "\tchr2\t243199373" << endl; | |
| 105 cerr << "\t..." << endl; | |
| 106 cerr << "\tchr18_gl000207_random\t4262" << endl << endl; | |
| 107 | |
| 108 cerr << "Tips: " << endl; | |
| 109 cerr << "\tOne can use the UCSC Genome Browser's MySQL database to extract" << endl; | |
| 110 cerr << "\tchromosome sizes. For example, H. sapiens:" << endl << endl; | |
| 111 cerr << "\tmysql --user=genome --host=genome-mysql.cse.ucsc.edu -A -e \\" << endl; | |
| 112 cerr << "\t\"select chrom, size from hg19.chromInfo\" > hg19.genome" << endl << endl; | |
| 113 | |
| 114 exit(1); | |
| 115 | |
| 116 } |
