/** * Project : CASAVA * Module : $RCSfile: IndelFinder.cpp,v $ * @author : Tony Cox * Copyright : Copyright (c) Illumina 2008, 2009. All rights reserved. * ** This software is covered by the "Illumina Genome Analyzer Software ** License Agreement" and the "Illumina Source Code License Agreement", ** and certain third party copyright/licenses, and any user of this ** source file is bound by the terms therein (see accompanying files ** Illumina_Genome_Analyzer_Software_License_Agreement.pdf and ** Illumina_Source_Code_License_Agreement.pdf and third party ** copyright/license notices). * */ #include "applications/IndelFinder.hh" #include "applications/CasavaOptions.hh" #include "variance/SampleStats.hh" #include "variance/SingletonEvent.hh" #include "variance/ClusterFinderImpl.hh" #include "common/Alignment.hh" #include "common/Exceptions.hh" #include "common/PairStats.hh" #include "variance/IndelFinderImpl.hh" #include "variance/BamAlignmentReader.hh" // Next #define prints out all shadows as export lines preceded by comments // #define LIST_SHADOWS 1 namespace ca { namespace applications { using namespace casava::common; using namespace ca::variance_detection; //TODO: Refactor int IndelFinder::run() { cout << "# Starting IndelFinder." << endl; #ifdef DEBUG_IDF cout << "# Input file : " << _options.inputReadsFilePath() << endl; cout << "# minGroupSize : " << _options.minGroupSize() << endl; cout << "# sras threshold : " << _options.srasThreshold() << endl; cout << "# pras threshold : " << _options.prasThreshold() << endl; cout << "# spRd threshold : " << _options.spReadThreshold() << endl; cout << "# isQphred : " << _options.isQphred << endl; #endif try { // Load PairStats. const boost::filesystem::path inputReadsFilePath(_options.inputReadsFilePath()); const boost::filesystem::path projDirPath(inputReadsFilePath.parent_path().parent_path(). parent_path().parent_path()); PairStats pairStats(projDirPath); pairStats.setNumSds(_options.numLowInsertSizeSds(), _options.numHighInsertSizeSds()); IndelFinderImpl indelFinder ( _options.prasThreshold(), _options.srasThreshold(), _options.spReadThreshold(), _options.outputFilePath(), _options.summaryFilePath(), _options.isQphred); map sampleStats; { BamAlignmentReader alignmentReader(_options.isFilterUnanchored); alignmentReader.Open(_options.inputReadsFilePath(), _options.refSequencePath(), _options.bamRegion()); cout << "# Computing sample stats." << endl; indelFinder.meanBaseQualityGoodPairs(alignmentReader, sampleStats); } //reads.rewind(); std::vector singletons; cout << "# Finding good singletons. " << endl; { BamAlignmentReader alignmentReader(_options.isFilterUnanchored); alignmentReader.Open(_options.inputReadsFilePath(), _options.refSequencePath(), _options.bamRegion()); indelFinder.findGoodSingletons ( alignmentReader, pairStats, sampleStats, singletons); } // ~scope of alignmentReader #ifdef LIST_SHADOWS for ( vector::iterator i(singletons.begin()); i!=singletons.end();++i) { cout << "# SHADOW" << "\t" << (*i)->minPos_ <<"\t" << (*i)->maxPos_ << "\t" << (*i)->alignment_; } // ~for #endif indelFinder.generateOutputFile( singletons ); indelFinder.generateStatsFile( sampleStats ); // ClusterFinderImpl clusterFinder // ( _options.maxDistance(), _options.minGroupSize() ); // clusterFinder( singletons ); } catch(const casava::common::CasavaException& e) { cerr << "ERROR: EXCEPTION: " << e.getContext() << ": " << e.getMessage() << std::endl; throw; } return 0; } // ~IndelFinder::run() } } // end namespace casava{ namespace { applications