Mercurial > repos > chrisd > testing
diff gene_fraction/src/Alignments.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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gene_fraction/src/Alignments.cpp Sun Feb 21 23:31:55 2016 -0500 @@ -0,0 +1,35 @@ +#include "Alignments.h" +#include "int_util.h" + +#include <boost/algorithm/string.hpp> + +#include <iostream> +#include <sstream> + +Alignments::Alignments(std::string alignment) : _alignment(alignment) { + fill_alignment_fields(alignment); +} + +void Alignments::fill_alignment_fields(const std::string &alignment) { + std::istringstream ss(alignment); + ss >> field.QNAME >> field.FLAG >> field.RNAME >> field.POS >> + field.MAPQ >> field.CIGAR >> field.RNEXT >> field.PNEXT >> + field.TLEN >> field.SEQ >> field.QUAL; +} + +std::vector<std::pair<int,char>> Alignments::cigar() { + return get_cigar_operations(field.CIGAR); +} + +std::vector<std::pair<int,char>> Alignments::get_cigar_operations(const std::string &cigar) { + std::vector<std::pair<int,char>> p; + int count; + char operation; + + std::istringstream ss(cigar); + while(ss >> count >> operation) { + p.push_back(std::make_pair(count, operation)); + } + + return p; +}