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