Changeset 3160
- Timestamp:
- Jan 13, 2014, 8:08:30 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/bam.cc
r3055 r3160 1 1 // $Id$ 2 2 // 3 // Copyright (C) 2013 Peter Johansson3 // Copyright (C) 2013, 2014 Peter Johansson 4 4 // 5 5 // This program is free software; you can redistribute it and/or modify … … 192 192 193 193 194 void test_open3(test::Suite& suite, const BamHeader& header) 195 { 196 OutBamFile out("yaya.bam", header, 0); 197 out.close(); 198 out.open("yaya.bam", header, 9); 199 out.close(); 200 try { 201 out.open("yaya.bam", header, 10); 202 suite.add(false); 203 suite.err() << "open(\"yaya.bam\", header, 10): did not throw\n"; 204 } 205 catch (std::invalid_argument& e) { 206 suite.err() << "expected exception: " << e.what() << "\n"; 207 } 208 out.close(); 209 } 210 211 194 212 void test1(test::Suite& suite) 195 213 { … … 239 257 test_sequence(suite, bam); 240 258 test_name(suite, bam); 241 } 242 #endif 259 test_open3(suite, in.header()); 260 } 261 #endif -
trunk/yat/omic/BamFile.cc
r3080 r3160 2 2 3 3 /* 4 Copyright (C) 2012, 2013 Peter Johansson4 Copyright (C) 2012, 2013, 2014 Peter Johansson 5 5 6 6 This file is part of the yat library, http://dev.thep.lu.se/yat … … 132 132 133 133 134 OutBamFile::OutBamFile(const std::string& fn, const BamHeader& header, 135 unsigned int c) 136 { 137 open(fn, header, c); 138 } 139 140 134 141 void OutBamFile::open(const std::string& fn, const BamHeader& h) 135 142 { 136 143 open_base(fn, "wb", h.header_); 144 } 145 146 147 void OutBamFile::open(const std::string& fn, const BamHeader& h, 148 unsigned int compression) 149 { 150 std::string mode("wb"); 151 if (compression > 9) { 152 std::stringstream oss; 153 oss << "OutBamFile::open( " << fn << ", <header>, " << compression 154 << "): incorrect compression level\n"; 155 throw std::invalid_argument(oss.str()); 156 } 157 mode.push_back('0'+compression); 158 open_base(fn, mode, h.header_); 137 159 } 138 160 -
trunk/yat/omic/BamFile.h
r3078 r3160 5 5 6 6 /* 7 Copyright (C) 2012, 2013 Peter Johansson7 Copyright (C) 2012, 2013, 2014 Peter Johansson 8 8 9 9 This file is part of the yat library, http://dev.thep.lu.se/yat … … 193 193 194 194 /** 195 \brief Create an output bam file. 196 197 Equivalent to default constructor followed by a call to open(3). 198 199 \see open(const std::string&, const BamHeader&, unsigned int) 200 201 \since yat 0.12 202 */ 203 OutBamFile(const std::string&, const BamHeader& header, 204 unsigned int compression); 205 206 /** 195 207 \brief Open an output bam file. 196 208 … … 202 214 */ 203 215 void open(const std::string& fn, const BamHeader& hdr); 216 217 /** 218 \brief Open an output bam file. 219 220 Opens an output bam file and writes the header contained in \a 221 hdr. If \a fn is "-", \c stdout is used. 222 223 \param fn string specifying the filename 224 \param hdr header 225 \param compression a number [0,9] indicating level of 226 compression. 9 gives highest compression and 0 indicates no 227 compression (suitable for piping between applications) 228 229 \since yat 0.12 230 */ 231 void open(const std::string& fn, const BamHeader& hdr, 232 unsigned int compression); 204 233 205 234 /**
Note: See TracChangeset
for help on using the changeset viewer.