Changeset 2979 for branches/0.10-stable


Ignore:
Timestamp:
Jan 31, 2013, 8:15:40 AM (8 years ago)
Author:
Peter
Message:

extending test for BamRead::cigar

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/0.10-stable/test/bam.cc

    r2972 r2979  
    5252using namespace omic;
    5353
     54void test_cigar(test::Suite& suite, const BamRead& b, const BamHeader& hdr)
     55{
     56  BamRead bam(b);
     57
     58  suite.out() << "test cigar:\n";
     59  suite.out() << bam.cigar_str() << "\n";
     60  OutBamFile os("cigar_test.bam", hdr);
     61  std::vector<uint32_t> cig;
     62
     63  bam.cigar(cig);
     64  suite.out() << bam.cigar_str() << "\n";
     65  suite.add(bam.cigar_str()=="");
     66  os.write(bam);
     67
     68  cig.resize(1);
     69  cig[0] = bam_cigar_gen(bam.sequence_length(), BAM_CMATCH);
     70  bam.cigar(cig);
     71  suite.out() << bam.cigar_str() << "\n";
     72  suite.add(bam.cigar_str()=="100M");
     73  os.write(bam);
     74
     75  cig.resize(3);
     76  cig[0] = bam_cigar_gen(50, BAM_CMATCH);
     77  cig[1] = bam_cigar_gen(2, BAM_CDEL);
     78  cig[2] = bam_cigar_gen(50, BAM_CMATCH);
     79  bam.cigar(cig);
     80  suite.out() << bam.cigar_str() << "\n";
     81  suite.add(bam.cigar_str()=="50M2D50M");
     82  os.write(bam);
     83
     84  // check that other elements in data* is preserved
     85  if (!suite.add(same_query_name(b, bam)))
     86    suite.err() << "error: \n'" << b.name() << "'\n'" << bam.name() << "'\n";
     87
     88  if (!suite.add(b.sequence()==bam.sequence()))
     89    suite.err() << "error: \n'" << b.sequence() << "'\n'"
     90                << bam.sequence() << "'\n";
     91
     92  for (int32_t i=0; i<b.core().l_qseq; ++i)
     93    if (bam.qual(i) != b.qual(i)) {
     94      suite.err() << "error: qual: " << i << " " << bam.qual(i)
     95                  << " not euqal " << b.qual(i) << "\n";
     96      suite.add(false);
     97    }
     98
     99  os.close();
     100}
     101
    54102void test1(test::Suite& suite)
    55103{
     
    68116    suite.add(false);
    69117  }
     118  test_cigar(suite, bam, in.header());
    70119}
    71120#endif
Note: See TracChangeset for help on using the changeset viewer.