Ignore:
Timestamp:
Apr 17, 2015, 3:07:04 AM (8 years ago)
Author:
Peter
Message:

refs #817. Fix bug that struct was not updated in text(1) function (in libbam mode); add test to catch bug.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/bam_header.cc

    r3408 r3409  
    11// $Id$
    22//
    3 // Copyright (C) 2013, 2014 Peter Johansson
     3// Copyright (C) 2013, 2014, 2015 Peter Johansson
    44//
    55// This program is free software; you can redistribute it and/or modify
     
    100100  }
    101101
     102  int32_t n_chr = hdr.n_targets();
     103
     104  // check that we can add another chromosomevia a @SG field
     105  std::stringstream ss(hdr.text());
     106  std::string str3;
     107  std::string line;
     108  int32_t n_targ = 0;
     109  while (getline(ss, line)) {
     110    str3 += line + "\n";
     111    if (line.substr(0,3) == "@SQ") {
     112      ++n_targ;
     113      if (n_targ == n_chr)
     114        str3 += "@SQ\tSN:Zbababababa\tLN:123\n";
     115    }
     116  }
     117  hdr.text(str3);
     118
     119  int32_t n = hdr.n_targets();
     120  if (n != n_chr+1) {
     121    suite.add(false);
     122    suite.err() << "error: incorrect number of targets: " << n
     123                << " expected " << (n_chr+1) << "\n";
     124    suite.err() << "header text:\n" << hdr.text() << "===\n";
     125  }
     126
    102127#endif
    103128}
Note: See TracChangeset for help on using the changeset viewer.