Mercurial > repos > chrisd > testshed
comparison gene_fraction/src/Sam.cpp @ 0:0fd352f62446 draft default tip
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
| author | chrisd |
|---|---|
| date | Sun, 21 Feb 2016 06:05:24 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:0fd352f62446 |
|---|---|
| 1 #include "Sam.h" | |
| 2 #include "dir_util.h" | |
| 3 #include "alignment_util.h" | |
| 4 | |
| 5 #include <iostream> | |
| 6 #include <fstream> | |
| 7 | |
| 8 Sam::Sam(std::string sam_fp) : _sam_fp(sam_fp) {} | |
| 9 | |
| 10 void Sam::read_sam(cmd_args args) { | |
| 11 if(args.bam_stream) read_from_stdin(); | |
| 12 else read_from_file(args.sam_fp); | |
| 13 } | |
| 14 | |
| 15 void Sam::read_from_stdin() { | |
| 16 std::string line; | |
| 17 while(std::getline(std::cin, line)) { | |
| 18 if(line[0] == '@') continue; | |
| 19 alignment.push_back(line); | |
| 20 } | |
| 21 } | |
| 22 | |
| 23 void Sam::read_from_file(const std::string &sam_fp) { | |
| 24 std::ifstream in(sam_fp.c_str()); | |
| 25 if(!in) { | |
| 26 std::cerr << "Could not open sam file " << sam_fp << std::endl; | |
| 27 exit(EXIT_FAILURE); | |
| 28 } | |
| 29 | |
| 30 std::string line; | |
| 31 while(getline(in, line)) { | |
| 32 if(line[0] == '@') continue; | |
| 33 if(is_good_alignment(line)) | |
| 34 alignment.push_back(line); | |
| 35 } | |
| 36 | |
| 37 in.close(); | |
| 38 } | |
| 39 | |
| 40 |
