Mercurial > repos > chrisd > testshed
comparison snp_caller/src/FastaRecord.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 <algorithm> | |
2 | |
3 #include "FastaRecord.h" | |
4 | |
5 FastaRecord::FastaRecord(std::string gene_id, std::string gene) : | |
6 _gene_id(gene_id), _gene(gene) {} | |
7 | |
8 int FastaRecord::find_gene(const std::vector<FastaRecord> & records, | |
9 const std::string &gene_id, | |
10 const std::string seq) { | |
11 int gene_index; | |
12 | |
13 std::vector<FastaRecord>::const_iterator low; | |
14 low = std::lower_bound(records.begin(), records.end(), | |
15 FastaRecord(gene_id, seq), | |
16 [](const FastaRecord &a, const FastaRecord &b) | |
17 { return a.gene_id() < b.gene_id(); }); | |
18 gene_index = (low - records.begin()); | |
19 | |
20 return gene_index; | |
21 } | |
22 | |
23 void FastaRecord::sort_by_gene_id(std::vector<FastaRecord> &records) { | |
24 sort(records.begin(), records.end(), | |
25 [](const FastaRecord &a, const FastaRecord &b) | |
26 { return a.gene_id() < b.gene_id(); }); | |
27 } |