#ifndef SINGLETON_EVENT_HH_ #define SINGLETON_EVENT_HH_ /** * Project : CASAVA * Module : $RCSfile: SingletonEvent.hh,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 #include #include #include #include #include #include "common/Alignment.hh" using namespace casava::common; using namespace std; namespace ca { namespace variance_detection { typedef map < int, float > IndelMetricStore; class Singleton; // fwd dec so next bit doesn't barf // SingletonEvent represents either start or end of the set of possible positions // in which an indel might lie, as suggested by either a shadow or semi-aligning read struct SingletonEvent { SingletonEvent(double pos, Singleton* pRead) : pos_(pos), pRead_(pRead) {} // position in genome (bp) double pos_; // pointer to read pair that this event pertains to Singleton* pRead_; }; // ~struct SingletonEvent #ifdef PROBABLY_NOT_A_GOOD_IDEA // SingletonEventComposite allows things and clusters of things to be // sorted together. TBD - dodgy design, have SingletonEvent and // SingletonEventComposite inherit from the same abstract base class struct SingletonEventComposite : public SingletonEvent { SingletonEventComposite( double pos ) : SingletonEvent( pos, NULL ) {} vector reads_; }; // ~struct SingletonEventComposite : public SingletonEvent #endif // Singleton: represents either a non-matching or semi-aligning read struct Singleton { Singleton(const char* read, const char* quality, Alignment alignment ) : read_(read), quality_(quality), alignment_(alignment) {} virtual ~Singleton() {} std::string read_; std::string quality_; int minPos_; int maxPos_; Alignment alignment_; // Singleton is responsible for telling the world the start and end of // the interval within which it might lie ... virtual void populateBounds ( vector& eventStarts, vector& eventEnds )=0; // ... and for assigning a p-value to every position within that interval virtual void populateMetric( IndelMetricStore& indelMetric )=0; }; // ~struct Singleton class SampleStats; struct SingletonNotMatched : public Singleton { SingletonNotMatched ( const Alignment& alignment, const Alignment& alignmentPrevious, map& sampleStats ); SingletonNotMatched ( const Alignment& alignment, const int minPos, const int maxPos, const double standardDeviation ); virtual void populateBounds ( vector& eventStarts, vector& eventEnds ); virtual void populateMetric( IndelMetricStore& indelMetric ); double standardDeviation_; // Alignment alignment_; Alignment alignmentPrevious_; }; // ~struct SingletonNotMatched struct SingletonSemiAligned : public Singleton { SingletonSemiAligned ( const Alignment& alignment ); virtual void populateBounds ( vector& eventStarts, vector& eventEnds ); virtual void populateMetric( IndelMetricStore& indelMetric ); // Alignment alignment_; }; // ~struct SingletonSemiAligned class Sorter { public: bool operator()(const SingletonEvent& p1, const SingletonEvent& p2) { return (p1.pos_