Skip to content
Snippets Groups Projects
Commit 9b2795ce authored by Aaron's avatar Aaron
Browse files

Added new logic to handle stdin or file in slopBed.

   This becomes the new model for handling files/stdin,
   rather than duplicating the main logic of each porgram
   in a block for files and a block for stdin.

   Much slicker.
parent 26653576
No related branches found
No related tags found
No related merge requests found
Version 2.3.2 (11/25/2009)
Fixed a bug in subtractBed that prevent a file from subtracting itself when the following is used:
$ subtractBed -a test.bed -b test.bed
Version 2.3.1 (11/19/2009)
Fixed a typo in closestBed that caused all nearby features to be returned instead of just the closest one.
......
No preview for this file type
chr1 247249719
chr1_random 1663265
chr10 135374737
chr10_random 113275
chr11 134452384
chr11_random 215294
chr12 132349534
chr13 114142980
chr13_random 186858
chr14 106368585
chr15 100338915
chr15_random 784346
chr16 88827254
chr16_random 105485
chr17 78774742
chr17_random 2617613
chr18 76117153
chr18_random 4262
chr19 63811651
chr19_random 301858
chr2 242951149
chr2_random 185571
chr20 62435964
chr21 46944323
chr21_random 1679693
chr22 49691432
chr22_random 257318
chr22_h2_hap1 63661
chr3 199501827
chr3_random 749256
chr4 191273063
chr4_random 842648
chr5 180857866
chr5_random 143687
chr5_h2_hap1 1794870
chr6 170899992
chr6_random 1875562
chr6_cox_hap1 4731698
chr6_qbl_hap2 4565931
chr7 158821424
chr7_random 549659
chr8 146274826
chr8_random 943810
chr9 140273252
chr9_random 1146434
chrM 16571
chrX 154913754
chrX_random 1719168
chrY 57772954
chr1 249250621
chr2 243199373
chr3 198022430
chr4 191154276
chr5 180915260
chr6 171115067
chr7 159138663
chrX 155270560
chr8 146364022
chr9 141213431
chr10 135534747
chr11 135006516
chr12 133851895
chr13 115169878
chr14 107349540
chr15 102531392
chr16 90354753
chr17 81195210
chr18 78077248
chr20 63025520
chrY 59373566
chr19 59128983
chr22 51304566
chr21 48129895
chr6_ssto_hap7 4928567
chr6_mcf_hap5 4833398
chr6_cox_hap2 4795371
chr6_mann_hap4 4683263
chr6_apd_hap1 4622290
chr6_qbl_hap6 4611984
chr6_dbb_hap3 4610396
chr17_ctg5_hap1 1680828
chr4_ctg9_hap1 590426
chr1_gl000192_random 547496
chrUn_gl000225 211173
chr4_gl000194_random 191469
chr4_gl000193_random 189789
chr9_gl000200_random 187035
chrUn_gl000222 186861
chrUn_gl000212 186858
chr7_gl000195_random 182896
chrUn_gl000223 180455
chrUn_gl000224 179693
chrUn_gl000219 179198
chr17_gl000205_random 174588
chrUn_gl000215 172545
chrUn_gl000216 172294
chrUn_gl000217 172149
chr9_gl000199_random 169874
chrUn_gl000211 166566
chrUn_gl000213 164239
chrUn_gl000220 161802
chrUn_gl000218 161147
chr19_gl000209_random 159169
chrUn_gl000221 155397
chrUn_gl000214 137718
chrUn_gl000228 129120
chrUn_gl000227 128374
chr1_gl000191_random 106433
chr19_gl000208_random 92689
chr9_gl000198_random 90085
chr17_gl000204_random 81310
chrUn_gl000233 45941
chrUn_gl000237 45867
chrUn_gl000230 43691
chrUn_gl000242 43523
chrUn_gl000243 43341
chrUn_gl000241 42152
chrUn_gl000236 41934
chrUn_gl000240 41933
chr17_gl000206_random 41001
chrUn_gl000232 40652
chrUn_gl000234 40531
chr11_gl000202_random 40103
chrUn_gl000238 39939
chrUn_gl000244 39929
chrUn_gl000248 39786
chr8_gl000196_random 38914
chrUn_gl000249 38502
chrUn_gl000246 38154
chr17_gl000203_random 37498
chr8_gl000197_random 37175
chrUn_gl000245 36651
chrUn_gl000247 36422
chr9_gl000201_random 36148
chrUn_gl000235 34474
chrUn_gl000239 33824
chr21_gl000210_random 27682
chrUn_gl000231 27386
chrUn_gl000229 19913
chrM 16571
chrUn_gl000226 15008
chr18_gl000207_random 4262
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -104,7 +104,7 @@ void ShowHelp(void) {
cerr << "\t" << "-db\t\t" << "The build. Default: hg18" << endl << endl;
cerr << "NOTES: " << endl;
cerr << "\t" << "-i stdin\t" << "Allows BED file A to be read from stdin. E.g.: cat a.bed | linksBed -i stdin > out.html" << endl << endl;
cerr << "\t" << "-i stdin\t" << "Allows BED file to be read from stdin. E.g.: cat a.bed | linksBed -i stdin > out.html" << endl << endl;
cerr << "\t***Only tab-delimited BED3 - BED6 formats allowed.***"<< endl << endl;
cerr << "EXAMPLE: " << endl;
......
......@@ -34,7 +34,7 @@ BedSlop::~BedSlop(void) {
void BedSlop::ProcessBed() {
void BedSlop::DetermineBedInput() {
/* open the GENOME file for reading.
......@@ -57,17 +57,27 @@ void BedSlop::ProcessBed() {
}
}
ifstream beds(this->bedFile.c_str(), ios::in);
if ( !beds ) {
cerr << "Error: The requested bed file (" <<this->bedFile << ") could not be opened. Exiting!" << endl;
exit (1);
if (this->bedFile != "stdin") { // process a file
ifstream beds(this->bedFile.c_str(), ios::in);
if ( !beds ) {
cerr << "Error: The requested bed file (" << this->bedFile << ") could not be opened. Exiting!" << endl;
exit (1);
}
ProcessBed(beds);
}
else { // process stdin
ProcessBed(cin);
}
}
void BedSlop::ProcessBed(istream &bedInput) {
BED bedEntry; // used to store the current BED line from the BED file.
int lineNum = 0;
string bedLine; // used to store the current (unparsed) line from the BED file.
while (getline(beds, bedLine)) {
while (getline(bedInput, bedLine)) {
vector<string> bedFields;
Tokenize(bedLine,bedFields);
......
......@@ -22,8 +22,10 @@ public:
// destructor
~BedSlop(void);
void ProcessBed();
void DetermineBedInput();
void ProcessBed(istream &bedInput);
// method to add requested "slop" to each BED entry
void AddSlop(BED &);
......
......@@ -106,7 +106,7 @@ int main(int argc, char* argv[]) {
}
if (!showHelp) {
BedSlop *bc = new BedSlop(bedFile, genomeFile, forceStrand, leftSlop, rightSlop);
bc->ProcessBed();
bc->DetermineBedInput();
return 0;
}
......@@ -134,13 +134,14 @@ void ShowHelp(void) {
cerr << "NOTES: " << endl;
cerr << "\t1. Starts will be corrected to 0 if the requested slop would force it below 0." << endl;
cerr << "\t2. Ends will be corrected to the chromosome length if the requested slop would force it above the max chrom length." << endl << endl;
cerr << "\t2. Ends will be corrected to the chromosome length if the requested slop would force it above the max chrom length." << endl;
cerr << "\t3. The genome file should tab delimited and structured as follows: <chr><TAB><size>. For example, Mus musculus:" << endl;
cerr << "\t\tchr1\t197195432" << endl;
cerr << "\t\tchr2\t181748087" << endl;
cerr << "\t\t..." << endl;
cerr << "\t\tchrY_random\t58682461" << endl << endl;
cerr << "\t4. ***Only tab-delimited BED3 - BED6 formats allowed.***"<< endl << endl;
cerr << "\t\tchrY_random\t58682461" << endl;
cerr << "\t4. -i stdin\t" << "Allows BED file to be read from stdin. E.g.: cat a.bed | slopBed -i stdin" << endl;
cerr << "\t5. ***Only tab-delimited BED3 - BED6 formats allowed.***"<< endl << endl;
cerr << "TIPS:" << endl;
cerr << "\tOne can use the UCSC Genome Browser's MySQL database to extract chromosome sizes. For example, H. sapiens:" << endl << endl;
......
chr1 100 200
chr1 150 250
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment