Skip to content

Commit

Permalink
fixed issue 22, issue 17
Browse files Browse the repository at this point in the history
  • Loading branch information
walaj committed Mar 10, 2018
1 parent 9c1a539 commit f0d2a24
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/bxconvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void runConvert(int argc, char** argv) {
}

if (opt::verbose)
std::cerr << "...starting first pass to tally unique " << opt::tag << " tag" << std::endl;
std::cerr << "...starting first pass to tally unique " << opt::tag << " tags" << std::endl;

// Loop through file once to grab all BX tags and store in string to generate header
ss << "@HD" << "\t" << "VN:1.4" << " " << "GO:none\tSO:unsorted" << std::endl;
Expand All @@ -80,6 +80,9 @@ void runConvert(int argc, char** argv) {
//write new header based on string generated from BX tags
SeqLib::BamHeader bxbamheader (ss.str());

if (opt::verbose)
std::cerr << "Found " << unique_bx << " unique barcodes" << std::endl;

w.Open("-");
w.SetHeader(bxbamheader);
w.WriteHeader();
Expand All @@ -92,18 +95,17 @@ void runConvert(int argc, char** argv) {
if (opt::verbose)
std::cerr << "...starting second pass to flip chr and BX" << std::endl;

while (reader2.GetNextRecord(r)){
while (reader2.GetNextRecord(r)) {

if (opt::keeptags)
r.AddZTag("CR", r.ChrID() >= 0 ? hdr.IDtoName(r.ChrID()) : "*");

read_bx(bx, r); // read the BX tag. Set default if not present
BXLOOPCHECK(r, true, opt::tag) // read and check we have a BX
r.SetChrID(bxtags[bx]);

r.SetChrIDMate(-1);
r.SetPosition(0);

if (opt::keeptags)
r.AddZTag("CR", r.ChrID() >= 0 ? hdr.IDtoName(r.ChrID()) : "*");
else
if (!opt::keeptags)
r.RemoveAllTags();

w.WriteRecord(r);
Expand Down

0 comments on commit f0d2a24

Please sign in to comment.