Mercurial > repos > chrisd > testshed
annotate 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 |
rev | line source |
---|---|
0
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
1 #include <algorithm> |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
2 |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
3 #include "FastaRecord.h" |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
4 |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
5 FastaRecord::FastaRecord(std::string gene_id, std::string gene) : |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
6 _gene_id(gene_id), _gene(gene) {} |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
7 |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
8 int FastaRecord::find_gene(const std::vector<FastaRecord> & records, |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
9 const std::string &gene_id, |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
10 const std::string seq) { |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
11 int gene_index; |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
12 |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
13 std::vector<FastaRecord>::const_iterator low; |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
14 low = std::lower_bound(records.begin(), records.end(), |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
15 FastaRecord(gene_id, seq), |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
16 [](const FastaRecord &a, const FastaRecord &b) |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
17 { return a.gene_id() < b.gene_id(); }); |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
18 gene_index = (low - records.begin()); |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
19 |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
20 return gene_index; |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
21 } |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
22 |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
23 void FastaRecord::sort_by_gene_id(std::vector<FastaRecord> &records) { |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
24 sort(records.begin(), records.end(), |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
25 [](const FastaRecord &a, const FastaRecord &b) |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
26 { return a.gene_id() < b.gene_id(); }); |
0fd352f62446
planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
chrisd
parents:
diff
changeset
|
27 } |