/** * Project : CASAVA * Module : $RCSfile: AnomReadGroup.cpp,v $ * @author : Tony Cox (rearranged by Richard Shaw) * Copyright : Copyright (c) Illumina 2010. 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 "variance/AnomReadGroup.hh" /*****************************************************************************/ namespace ca { namespace variance_detection { /*****************************************************************************/ AnomReadGroup::AnomReadGroup() : anomReadType_(AnomalousRead::ShadowOrSemiAligned) { ; } /*****************************************************************************/ AnomReadGroup::AnomReadGroup(AnomalousRead::Type anomReadType) : anomReadType_(anomReadType) { ; } /*****************************************************************************/ void AnomReadGroup::print(const unsigned int minGroupSize, unsigned int& numGroups, ostream& outstr) { bool printGroup = false; int minGroupSizeForSemiAligned = ceil ( (double)minGroupSize /2.0); if (this->size() >= minGroupSize) printGroup= true; else { int numSemiAlignedReads = 0; for (AnomReadGroup::iterator j(this->begin()); j != this->end(); ++j) { if (dynamic_cast(*j)!=NULL) numSemiAlignedReads++; } if (numSemiAlignedReads >= minGroupSizeForSemiAligned) printGroup= true; } if (printGroup) { outstr << "CLUSTER_START Found cluster of size " << this->size() << " at " << static_cast(positionStats_.getMean()) << " type " << anomReadType_ << endl; } // printf("CLUSTER_START Found cluster of size %ld\n", this->size()); // positionStats_.clear(); minStats_.clear(); maxStats_.clear(); const Singleton* pAnomRead; for (AnomReadGroup::iterator j(this->begin()); j != this->end(); ++j) { // pAnomRead=&singletons[*j]; pAnomRead = *j; outstr << pAnomRead->minPos_ << "\t" << pAnomRead->maxPos_ << "\t" << pAnomRead->alignment_; // printf("CLUSTER %s %d %d\n", pAnomRead->read_.c_str(), // pAnomRead->minPos_, pAnomRead->maxPos_); minStats_.update(pAnomRead->minPos_); maxStats_.update(pAnomRead->maxPos_); // positionStats_.update((pAnomRead->minPos_ + pAnomRead->maxPos_) /2); } // ~for #ifdef DONT_BOTHER_WITH_THIS printf("# CLUSTER_MEAN "); positionStats_.print(); printf("# CLUSTER_MIN "); minStats_.print(); printf("# CLUSTER_MAX "); maxStats_.print(); #endif if (printGroup) outstr << "CLUSTER_END group=" << static_cast(++numGroups) << "|reads=" << static_cast(minStats_.getNumSamples()) << "|start=" << static_cast(minStats_.getMean()) << "|end=" << static_cast(maxStats_.getMean()) << endl; // printf("CLUSTER_END group=%d|reads=%d|start=%d|end=%d\n", ++numGroups, // positionStats_.getNumSamples(), (int)minStats_.getMean(), // (int)maxStats_.getMean()); } // ~print /*****************************************************************************/ } // namespace variance_detection } // namespace ca /*****************************************************************************/