void sUpdateCase(CDir& test_cases_dir, const string& test_name) { string input = CDir::ConcatPath( test_cases_dir.GetPath(), test_name + "." + extInput); string output = CDir::ConcatPath( test_cases_dir.GetPath(), test_name + "." + extOutput); string errors = CDir::ConcatPath( test_cases_dir.GetPath(), test_name + "." + extErrors); if (!CFile(input).Exists()) { BOOST_FAIL("input file " << input << " does not exist."); } cerr << "Creating new test case from " << input << " ..." << endl; CErrorLogger logger(errors); CGvfReader reader(0); CNcbiIfstream ifstr(input.c_str()); typedef CGff2Reader::TAnnotList ANNOTS; ANNOTS annots; try { reader.ReadSeqAnnots(annots, ifstr, &logger); } catch (...) { ifstr.close(); BOOST_FAIL("Error: " << input << " failed during conversion."); } ifstr.close(); cerr << " Produced new error listing " << output << "." << endl; CNcbiOfstream ofstr(output.c_str()); for (ANNOTS::iterator cit = annots.begin(); cit != annots.end(); ++cit){ ofstr << MSerial_AsnText << **cit; ofstr.flush(); } ofstr.close(); cerr << " Produced new ASN1 file " << output << "." << endl; cerr << " ... Done." << endl; }
void sUpdateCase(CDir& test_cases_dir, const string& test_name) { string input = CDir::ConcatPath( test_cases_dir.GetPath(), test_name + "." + extInput); string output = CDir::ConcatPath( test_cases_dir.GetPath(), test_name + "." + extOutput); string errors = CDir::ConcatPath( test_cases_dir.GetPath(), test_name + "." + extErrors); if (!CFile(input).Exists()) { BOOST_FAIL("input file " << input << " does not exist."); } string test_base, test_type; NStr::SplitInTwo(test_name, ".", test_base, test_type); cerr << "Creating new test case from " << input << " ..." << endl; CErrorLogger logger(errors); //get a scope CRef<CObjectManager> pObjMngr = CObjectManager::GetInstance(); CGBDataLoader::RegisterInObjectManager(*pObjMngr); CRef<CScope> pScope(new CScope(*pObjMngr)); pScope->AddDefaults(); //get a writer object CNcbiIfstream ifstr(input.c_str(), ios::binary); CObjectIStream* pI = CObjectIStream::Open(eSerial_AsnText, ifstr, eTakeOwnership); CNcbiOfstream ofstr(output.c_str()); CBedGraphWriter* pWriter = sGetWriter(*pScope, ofstr); if (test_type == "annot") { CRef<CSeq_annot> pAnnot(new CSeq_annot); *pI >> *pAnnot; pWriter->WriteHeader(); pWriter->WriteAnnot(*pAnnot); pWriter->WriteFooter(); delete pWriter; ofstr.flush(); }