1 #ifndef _META_GRAPH_HH_
2 #define _META_GRAPH_HH_
3 #include "../Utils/Utils.hh"
4 #include "../VelvetAPI/VelvetGraph.hh"
5 #include "InfiniteLoopChecker.hh"
6 #include "SplitJudge.hh"
7 
8 #define META_GRAPH_MAX_NUM_INTER_LOOPS 100
9 #define META_GRAPH_MASK_UNVISITED 0
10 #define META_GRAPH_MASK_NOW_VISITING 1
11 #define META_GRAPH_MASK_PRIMARY 2
12 #define META_GRAPH_MASK_SECONDARY -1
13 #define META_GRAPH_MASK_DELETED -2
14 #define META_GRAPH_LN2 0.693147
15 #define META_GRAPH_LONG_NODE_CUTOFF 50
16 #define META_GRAPH_UNIQUE_PROBABILITY_CUTOFF 5
17 
18 using namespace std;
19 
20 class MetaGraph : public VelvetGraph {
21   int* subgraphMask;
22   SplitJudge* splitJudge;
23   string subgraphPrefix;
24   bool flagReportSubgraph;
25   void scaffoldingWithMultiPeakMode( boolean* flagMatePair, bool flagScaffolding, double maxChimeraRate, bool flagDiscardChimera );
26   void eliminateNullNodes();
27   void setSubgraphUniqueness();
28   void _computeConnections( boolean* flagMatePair );
29   void extractNextSubgraph( IDnum nodeID );
30   IDnum getUnvisitedNodeID() const;
31   void dfs( IDnum currentIndex );
32   bool isChimeraSubgraph( double primaryCoverage, double secondaryCoverage, double maxChimeraRate ) const;
33   bool isPrimarySubgraph( double primaryCoverage, double secondaryCoverage ) const;
34   int splitRepeats();
35   bool pushNeighboursInterRepeat( Node* inNode, Node* repNode, Node* outNode );
36   void absorbExtensionInterRepeat( Node * node, Node * extension );
37   void adjustShortReadsInterRepeat( Node * target, Node * source );
38   void forceSeparateChimericSubgraph( double primaryCoverage, double secondaryCoverage );
39   void identifyUniqueNodesSubgraph( double primaryCoverage );
40   bool isUniqueSubgraph(Node * node, double expCovSubgraph);
41   void readCoherentSubgraph( double primaryCoverage );
42   bool trimLongReadTipsSubgraph();
43   void changeSubgraphMask( int fromID, int toID );
44   long getSubgraphMaskSize() const;
45   bool checkLongReadExistence() const;
46   void resetNodeFlags();
47   void resetUniqueness();
48   IDnum getNumActiveNodes() const;
49   void saveSubgraph( size_t roundID, double cov ) const;
50 public:
MetaGraph(const string & seqFileName,const string & roadmapFileName,const string & pregraphFileName,bool flagReadTracking,int accelerationBits)51   MetaGraph( const string& seqFileName, const string& roadmapFileName, const string& pregraphFileName, bool flagReadTracking, int accelerationBits )
52     : VelvetGraph( seqFileName, roadmapFileName, pregraphFileName, flagReadTracking, accelerationBits ){}
MetaGraph(const string & seqFileName,const string & graphFileName)53   MetaGraph( const string& seqFileName, const string& graphFileName ) : VelvetGraph( seqFileName, graphFileName ){}
setSplitJudge(SplitJudge * sj)54   void setSplitJudge( SplitJudge* sj ) { splitJudge = sj; }
setSubgraphOptions(const string & prefix,bool flag)55   void setSubgraphOptions( const string& prefix, bool flag ) { subgraphPrefix = prefix; flagReportSubgraph = flag; }
56   void scaffolding( boolean* flagMatePair, bool flagScaffolding, double maxChimeraRate, bool flagDiscardChimera );
setExpectedCoverages(int num,const double * covs)57   void setExpectedCoverages( int num, const double* covs ){ splitJudge->setExpectedCoverages( num, covs ); }
showExpectedCoverages() const58   void showExpectedCoverages() const { splitJudge->showExpectedCoverages(); }
59 };
60 
61 #endif // _META_GRAPH_HH_
62