comparison gene_fraction/src/Fasta.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 "Fasta.h"
2 #include "args.h"
3
4 #include <iostream>
5 #include <fstream>
6 #include <vector>
7 #include <string>
8
9 Fasta::Fasta(std::string amr_fp) : _amr_fp(amr_fp) {}
10
11 void Fasta::read_fasta(const std::string &amr_fp) {
12 std::ifstream in(amr_fp.c_str());
13 if(!in) {
14 usage();
15 exit(EXIT_FAILURE);
16 }
17
18 std::string gene_id, gene, line;
19 while(std::getline(in, line)) {
20 std::size_t gene_idx = line.find(" ");
21
22 if(gene_idx != std::string::npos)
23 gene_id = line.substr(1, gene_idx-1);
24 else
25 gene_id = line.substr(1, line.length());
26
27 std::getline(in, gene);
28 records.push_back(FastaRecord(gene_id, gene));
29 }
30 in.close();
31
32 FastaRecord::sort_by_gene_id(records);
33 }
34
35
36
37
38
39